fetch2/ssh.py: Fix url code for +

Message ID 20220419174243.44519-1-liezhi.yang@windriver.com
State New
Headers show
Series fetch2/ssh.py: Fix url code for + | expand

Commit Message

Robert Yang April 19, 2022, 5:42 p.m. UTC
Fixed when fetch from PREMIRRORS via ssh:
$ bitbake bonnie++ libsigc++-2.0 -cfetch

scp: /paht/to/downloads/libsigc%2B%2B-2.10.7.tar.xz: No such file or directory

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 lib/bb/fetch2/ssh.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Richard Purdie April 20, 2022, 2:11 p.m. UTC | #1
On Tue, 2022-04-19 at 10:42 -0700, Robert Yang wrote:
> Fixed when fetch from PREMIRRORS via ssh:
> $ bitbake bonnie++ libsigc++-2.0 -cfetch
> 
> scp: /paht/to/downloads/libsigc%2B%2B-2.10.7.tar.xz: No such file or directory
> 
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  lib/bb/fetch2/ssh.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
> index 484453088f..2836d7c884 100644
> --- a/lib/bb/fetch2/ssh.py
> +++ b/lib/bb/fetch2/ssh.py
> @@ -70,6 +70,7 @@ class SSH(FetchMethod):
>                  "git:// prefix with protocol=ssh", urldata.url)
>          m = __pattern__.match(urldata.url)
>          path = m.group('path')
> +        path = path.replace("%3A", ":").replace("%2B", "+")
>          host = m.group('host')
>          urldata.localpath = os.path.join(d.getVar('DL_DIR'),
>                  os.path.basename(os.path.normpath(path)))
> @@ -99,7 +100,7 @@ class SSH(FetchMethod):
>  
>          if path[0] != '~':
>              path = '/%s' % path
> -        path = path.replace("%3A", ":")
> +        path = path.replace("%3A", ":").replace("%2B", "+")
>  
>          fr += ':%s' % path
>  
> @@ -139,7 +140,7 @@ class SSH(FetchMethod):
>  
>          if path[0] != '~':
>              path = '/%s' % path
> -        path = path.replace("%3A", ":")
> +        path = path.replace("%3A", ":").replace("%2B", "+")
>  
>          cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (
>              portarg,

Do we need to be doing some kind of url decode on this?

Cheers,

Richard
Robert Yang April 21, 2022, 9:08 a.m. UTC | #2
On 4/20/22 10:11 PM, Richard Purdie wrote:
> On Tue, 2022-04-19 at 10:42 -0700, Robert Yang wrote:
>> Fixed when fetch from PREMIRRORS via ssh:
>> $ bitbake bonnie++ libsigc++-2.0 -cfetch
>>
>> scp: /paht/to/downloads/libsigc%2B%2B-2.10.7.tar.xz: No such file or directory
>>
>> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>> ---
>>   lib/bb/fetch2/ssh.py | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
>> index 484453088f..2836d7c884 100644
>> --- a/lib/bb/fetch2/ssh.py
>> +++ b/lib/bb/fetch2/ssh.py
>> @@ -70,6 +70,7 @@ class SSH(FetchMethod):
>>                   "git:// prefix with protocol=ssh", urldata.url)
>>           m = __pattern__.match(urldata.url)
>>           path = m.group('path')
>> +        path = path.replace("%3A", ":").replace("%2B", "+")
>>           host = m.group('host')
>>           urldata.localpath = os.path.join(d.getVar('DL_DIR'),
>>                   os.path.basename(os.path.normpath(path)))
>> @@ -99,7 +100,7 @@ class SSH(FetchMethod):
>>   
>>           if path[0] != '~':
>>               path = '/%s' % path
>> -        path = path.replace("%3A", ":")
>> +        path = path.replace("%3A", ":").replace("%2B", "+")
>>   
>>           fr += ':%s' % path
>>   
>> @@ -139,7 +140,7 @@ class SSH(FetchMethod):
>>   
>>           if path[0] != '~':
>>               path = '/%s' % path
>> -        path = path.replace("%3A", ":")
>> +        path = path.replace("%3A", ":").replace("%2B", "+")
>>   
>>           cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (
>>               portarg,
> 
> Do we need to be doing some kind of url decode on this?

Yes, I think that's better, I've done a world fetch build after 
urllib.parse.unquote(path).

V2 is coming.

// Robert

> 
> Cheers,
> 
> Richard
>

Patch

diff --git a/lib/bb/fetch2/ssh.py b/lib/bb/fetch2/ssh.py
index 484453088f..2836d7c884 100644
--- a/lib/bb/fetch2/ssh.py
+++ b/lib/bb/fetch2/ssh.py
@@ -70,6 +70,7 @@  class SSH(FetchMethod):
                 "git:// prefix with protocol=ssh", urldata.url)
         m = __pattern__.match(urldata.url)
         path = m.group('path')
+        path = path.replace("%3A", ":").replace("%2B", "+")
         host = m.group('host')
         urldata.localpath = os.path.join(d.getVar('DL_DIR'),
                 os.path.basename(os.path.normpath(path)))
@@ -99,7 +100,7 @@  class SSH(FetchMethod):
 
         if path[0] != '~':
             path = '/%s' % path
-        path = path.replace("%3A", ":")
+        path = path.replace("%3A", ":").replace("%2B", "+")
 
         fr += ':%s' % path
 
@@ -139,7 +140,7 @@  class SSH(FetchMethod):
 
         if path[0] != '~':
             path = '/%s' % path
-        path = path.replace("%3A", ":")
+        path = path.replace("%3A", ":").replace("%2B", "+")
 
         cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (
             portarg,