diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/ssh.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/ssh.py | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/ssh.py b/bitbake/lib/bb/fetch2/ssh.py index 2c8557e1f8..2a0f2cb44b 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 | ||
33 | import re, os | 33 | import re, os |
34 | from bb.fetch2 import check_network_access, FetchMethod, ParameterError, runfetchcmd | 34 | from bb.fetch2 import check_network_access, FetchMethod, ParameterError, runfetchcmd |
35 | import 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,9 +71,9 @@ 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.localfile = os.path.basename(os.path.normpath(path)) |
75 | os.path.basename(os.path.normpath(path))) | ||
76 | 77 | ||
77 | def download(self, urldata, d): | 78 | def download(self, urldata, d): |
78 | dldir = d.getVar('DL_DIR') | 79 | dldir = d.getVar('DL_DIR') |
@@ -96,6 +97,11 @@ class SSH(FetchMethod): | |||
96 | fr += '@%s' % host | 97 | fr += '@%s' % host |
97 | else: | 98 | else: |
98 | fr = host | 99 | fr = host |
100 | |||
101 | if path[0] != '~': | ||
102 | path = '/%s' % path | ||
103 | path = urllib.parse.unquote(path) | ||
104 | |||
99 | fr += ':%s' % path | 105 | fr += ':%s' % path |
100 | 106 | ||
101 | cmd = 'scp -B -r %s %s %s/' % ( | 107 | cmd = 'scp -B -r %s %s %s/' % ( |
@@ -108,3 +114,41 @@ class SSH(FetchMethod): | |||
108 | 114 | ||
109 | runfetchcmd(cmd, d) | 115 | runfetchcmd(cmd, d) |
110 | 116 | ||
117 | def checkstatus(self, fetch, urldata, d): | ||
118 | """ | ||
119 | Check the status of the url | ||
120 | """ | ||
121 | m = __pattern__.match(urldata.url) | ||
122 | path = m.group('path') | ||
123 | host = m.group('host') | ||
124 | port = m.group('port') | ||
125 | user = m.group('user') | ||
126 | password = m.group('pass') | ||
127 | |||
128 | if port: | ||
129 | portarg = '-P %s' % port | ||
130 | else: | ||
131 | portarg = '' | ||
132 | |||
133 | if user: | ||
134 | fr = user | ||
135 | if password: | ||
136 | fr += ':%s' % password | ||
137 | fr += '@%s' % host | ||
138 | else: | ||
139 | fr = host | ||
140 | |||
141 | if path[0] != '~': | ||
142 | path = '/%s' % path | ||
143 | path = urllib.parse.unquote(path) | ||
144 | |||
145 | cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % ( | ||
146 | portarg, | ||
147 | fr, | ||
148 | path | ||
149 | ) | ||
150 | |||
151 | check_network_access(d, cmd, urldata.url) | ||
152 | runfetchcmd(cmd, d) | ||
153 | |||
154 | return True | ||