diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/ssh.py')
| -rw-r--r-- | bitbake/lib/bb/fetch2/ssh.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/bitbake/lib/bb/fetch2/ssh.py b/bitbake/lib/bb/fetch2/ssh.py index 8d6434a7eb..8b5acbf6db 100644 --- a/bitbake/lib/bb/fetch2/ssh.py +++ b/bitbake/lib/bb/fetch2/ssh.py | |||
| @@ -10,6 +10,12 @@ IETF secsh internet draft: | |||
| 10 | Currently does not support the sftp parameters, as this uses scp | 10 | Currently does not support the sftp parameters, as this uses scp |
| 11 | Also does not support the 'fingerprint' connection parameter. | 11 | Also does not support the 'fingerprint' connection parameter. |
| 12 | 12 | ||
| 13 | Please note that '/' is used as host, path separator not ':' as you may | ||
| 14 | be used to, also '~' can be used to specify user HOME, but again after '/' | ||
| 15 | |||
| 16 | Example SRC_URI: | ||
| 17 | SRC_URI = "ssh://user@host.example.com/dir/path/file.txt" | ||
| 18 | SRC_URI = "ssh://user@host.example.com/~/file.txt" | ||
| 13 | ''' | 19 | ''' |
| 14 | 20 | ||
| 15 | # Copyright (C) 2006 OpenedHand Ltd. | 21 | # Copyright (C) 2006 OpenedHand Ltd. |
| @@ -72,15 +78,19 @@ class SSH(FetchMethod): | |||
| 72 | def supports_checksum(self, urldata): | 78 | def supports_checksum(self, urldata): |
| 73 | return False | 79 | return False |
| 74 | 80 | ||
| 75 | def localpath(self, url, urldata, d): | 81 | def urldata_init(self, urldata, d): |
| 82 | if 'protocol' in urldata.parm and urldata.parm['protocol'] == 'git': | ||
| 83 | raise bb.fetch2.ParameterError( | ||
| 84 | "Invalid protocol - if you wish to fetch from a git " + | ||
| 85 | "repository using ssh, you need to use " + | ||
| 86 | "git:// prefix with protocol=ssh", urldata.url) | ||
| 76 | m = __pattern__.match(urldata.url) | 87 | m = __pattern__.match(urldata.url) |
| 77 | path = m.group('path') | 88 | path = m.group('path') |
| 78 | host = m.group('host') | 89 | host = m.group('host') |
| 79 | lpath = os.path.join(data.getVar('DL_DIR', d, True), host, os.path.basename(path)) | 90 | urldata.localpath = os.path.join(d.getVar('DL_DIR', True), os.path.basename(path)) |
| 80 | return lpath | ||
| 81 | 91 | ||
| 82 | def download(self, url, urldata, d): | 92 | def download(self, url, urldata, d): |
| 83 | dldir = data.getVar('DL_DIR', d, True) | 93 | dldir = d.getVar('DL_DIR', True) |
| 84 | 94 | ||
| 85 | m = __pattern__.match(url) | 95 | m = __pattern__.match(url) |
| 86 | path = m.group('path') | 96 | path = m.group('path') |
| @@ -89,16 +99,10 @@ class SSH(FetchMethod): | |||
| 89 | user = m.group('user') | 99 | user = m.group('user') |
| 90 | password = m.group('pass') | 100 | password = m.group('pass') |
| 91 | 101 | ||
| 92 | ldir = os.path.join(dldir, host) | ||
| 93 | lpath = os.path.join(ldir, os.path.basename(path)) | ||
| 94 | |||
| 95 | if not os.path.exists(ldir): | ||
| 96 | os.makedirs(ldir) | ||
| 97 | |||
| 98 | if port: | 102 | if port: |
| 99 | port = '-P %s' % port | 103 | portarg = '-P %s' % port |
| 100 | else: | 104 | else: |
| 101 | port = '' | 105 | portarg = '' |
| 102 | 106 | ||
| 103 | if user: | 107 | if user: |
| 104 | fr = user | 108 | fr = user |
| @@ -112,9 +116,9 @@ class SSH(FetchMethod): | |||
| 112 | 116 | ||
| 113 | import commands | 117 | import commands |
| 114 | cmd = 'scp -B -r %s %s %s/' % ( | 118 | cmd = 'scp -B -r %s %s %s/' % ( |
| 115 | port, | 119 | portarg, |
| 116 | commands.mkarg(fr), | 120 | commands.mkarg(fr), |
| 117 | commands.mkarg(ldir) | 121 | commands.mkarg(dldir) |
| 118 | ) | 122 | ) |
| 119 | 123 | ||
| 120 | bb.fetch2.check_network_access(d, cmd, urldata.url) | 124 | bb.fetch2.check_network_access(d, cmd, urldata.url) |
