summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/ssh.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/ssh.py')
-rw-r--r--bitbake/lib/bb/fetch2/ssh.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/ssh.py b/bitbake/lib/bb/fetch2/ssh.py
index 2c8557e1f8..0cbb2a6f25 100644
--- a/bitbake/lib/bb/fetch2/ssh.py
+++ b/bitbake/lib/bb/fetch2/ssh.py
@@ -32,6 +32,7 @@ IETF secsh internet draft:
32 32
33import re, os 33import re, os
34from bb.fetch2 import check_network_access, FetchMethod, ParameterError, runfetchcmd 34from bb.fetch2 import check_network_access, FetchMethod, ParameterError, runfetchcmd
35import urllib
35 36
36 37
37__pattern__ = re.compile(r''' 38__pattern__ = re.compile(r'''
@@ -40,9 +41,9 @@ __pattern__ = re.compile(r'''
40 ( # Optional username/password block 41 ( # Optional username/password block
41 (?P<user>\S+) # username 42 (?P<user>\S+) # username
42 (:(?P<pass>\S+))? # colon followed by the password (optional) 43 (:(?P<pass>\S+))? # colon followed by the password (optional)
43 )?
44 (?P<cparam>(;[^;]+)*)? # connection parameters block (optional) 44 (?P<cparam>(;[^;]+)*)? # connection parameters block (optional)
45 @ 45 @
46 )?
46 (?P<host>\S+?) # non-greedy match of the host 47 (?P<host>\S+?) # non-greedy match of the host
47 (:(?P<port>[0-9]+))? # colon followed by the port (optional) 48 (:(?P<port>[0-9]+))? # colon followed by the port (optional)
48 / 49 /
@@ -70,6 +71,7 @@ class SSH(FetchMethod):
70 "git:// prefix with protocol=ssh", urldata.url) 71 "git:// prefix with protocol=ssh", urldata.url)
71 m = __pattern__.match(urldata.url) 72 m = __pattern__.match(urldata.url)
72 path = m.group('path') 73 path = m.group('path')
74 path = urllib.parse.unquote(path)
73 host = m.group('host') 75 host = m.group('host')
74 urldata.localpath = os.path.join(d.getVar('DL_DIR'), 76 urldata.localpath = os.path.join(d.getVar('DL_DIR'),
75 os.path.basename(os.path.normpath(path))) 77 os.path.basename(os.path.normpath(path)))
@@ -96,6 +98,11 @@ class SSH(FetchMethod):
96 fr += '@%s' % host 98 fr += '@%s' % host
97 else: 99 else:
98 fr = host 100 fr = host
101
102 if path[0] != '~':
103 path = '/%s' % path
104 path = urllib.parse.unquote(path)
105
99 fr += ':%s' % path 106 fr += ':%s' % path
100 107
101 cmd = 'scp -B -r %s %s %s/' % ( 108 cmd = 'scp -B -r %s %s %s/' % (
@@ -108,3 +115,41 @@ class SSH(FetchMethod):
108 115
109 runfetchcmd(cmd, d) 116 runfetchcmd(cmd, d)
110 117
118 def checkstatus(self, fetch, urldata, d):
119 """
120 Check the status of the url
121 """
122 m = __pattern__.match(urldata.url)
123 path = m.group('path')
124 host = m.group('host')
125 port = m.group('port')
126 user = m.group('user')
127 password = m.group('pass')
128
129 if port:
130 portarg = '-P %s' % port
131 else:
132 portarg = ''
133
134 if user:
135 fr = user
136 if password:
137 fr += ':%s' % password
138 fr += '@%s' % host
139 else:
140 fr = host
141
142 if path[0] != '~':
143 path = '/%s' % path
144 path = urllib.parse.unquote(path)
145
146 cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (
147 portarg,
148 fr,
149 path
150 )
151
152 check_network_access(d, cmd, urldata.url)
153 runfetchcmd(cmd, d)
154
155 return True