Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | """ |
| 2 | BitBake 'Fetch' implementations |
| 3 | |
| 4 | Classes for obtaining upstream sources for the |
| 5 | BitBake build tools. |
| 6 | """ |
| 7 | |
| 8 | # Copyright (C) 2003, 2004 Chris Larson |
| 9 | # Copyright (C) 2012 Intel Corporation |
| 10 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 11 | # SPDX-License-Identifier: GPL-2.0-only |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | # |
| 13 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig |
| 14 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | import os, re |
| 16 | import signal |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | import logging |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 18 | import urllib.request, urllib.parse, urllib.error |
| 19 | if 'git' not in urllib.parse.uses_netloc: |
| 20 | urllib.parse.uses_netloc.append('git') |
| 21 | import operator |
| 22 | import collections |
| 23 | import subprocess |
| 24 | import pickle |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | import errno |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | import bb.persist_data, bb.utils |
| 27 | import bb.checksum |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | import bb.process |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 29 | import bb.event |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | |
| 31 | __version__ = "2" |
| 32 | _checksum_cache = bb.checksum.FileChecksumCache() |
| 33 | |
| 34 | logger = logging.getLogger("BitBake.Fetcher") |
| 35 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | class BBFetchException(Exception): |
| 37 | """Class all fetch exceptions inherit from""" |
| 38 | def __init__(self, message): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 39 | self.msg = message |
| 40 | Exception.__init__(self, message) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 42 | def __str__(self): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 43 | return self.msg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | |
| 45 | class UntrustedUrl(BBFetchException): |
| 46 | """Exception raised when encountering a host not listed in BB_ALLOWED_NETWORKS""" |
| 47 | def __init__(self, url, message=''): |
| 48 | if message: |
| 49 | msg = message |
| 50 | else: |
| 51 | msg = "The URL: '%s' is not trusted and cannot be used" % url |
| 52 | self.url = url |
| 53 | BBFetchException.__init__(self, msg) |
| 54 | self.args = (url,) |
| 55 | |
| 56 | class MalformedUrl(BBFetchException): |
| 57 | """Exception raised when encountering an invalid url""" |
| 58 | def __init__(self, url, message=''): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 59 | if message: |
| 60 | msg = message |
| 61 | else: |
| 62 | msg = "The URL: '%s' is invalid and cannot be interpreted" % url |
| 63 | self.url = url |
| 64 | BBFetchException.__init__(self, msg) |
| 65 | self.args = (url,) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | |
| 67 | class FetchError(BBFetchException): |
| 68 | """General fetcher exception when something happens incorrectly""" |
| 69 | def __init__(self, message, url = None): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | if url: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | msg = "Fetcher failure for URL: '%s'. %s" % (url, message) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 72 | else: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | msg = "Fetcher failure: %s" % message |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 74 | self.url = url |
| 75 | BBFetchException.__init__(self, msg) |
| 76 | self.args = (message, url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | |
| 78 | class ChecksumError(FetchError): |
| 79 | """Exception when mismatched checksum encountered""" |
| 80 | def __init__(self, message, url = None, checksum = None): |
| 81 | self.checksum = checksum |
| 82 | FetchError.__init__(self, message, url) |
| 83 | |
| 84 | class NoChecksumError(FetchError): |
| 85 | """Exception when no checksum is specified, but BB_STRICT_CHECKSUM is set""" |
| 86 | |
| 87 | class UnpackError(BBFetchException): |
| 88 | """General fetcher exception when something happens incorrectly when unpacking""" |
| 89 | def __init__(self, message, url): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | msg = "Unpack failure for URL: '%s'. %s" % (url, message) |
| 91 | self.url = url |
| 92 | BBFetchException.__init__(self, msg) |
| 93 | self.args = (message, url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | |
| 95 | class NoMethodError(BBFetchException): |
| 96 | """Exception raised when there is no method to obtain a supplied url or set of urls""" |
| 97 | def __init__(self, url): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 98 | msg = "Could not find a fetcher which supports the URL: '%s'" % url |
| 99 | self.url = url |
| 100 | BBFetchException.__init__(self, msg) |
| 101 | self.args = (url,) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 102 | |
| 103 | class MissingParameterError(BBFetchException): |
| 104 | """Exception raised when a fetch method is missing a critical parameter in the url""" |
| 105 | def __init__(self, missing, url): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 106 | msg = "URL: '%s' is missing the required parameter '%s'" % (url, missing) |
| 107 | self.url = url |
| 108 | self.missing = missing |
| 109 | BBFetchException.__init__(self, msg) |
| 110 | self.args = (missing, url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 111 | |
| 112 | class ParameterError(BBFetchException): |
| 113 | """Exception raised when a url cannot be proccessed due to invalid parameters.""" |
| 114 | def __init__(self, message, url): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 115 | msg = "URL: '%s' has invalid parameters. %s" % (url, message) |
| 116 | self.url = url |
| 117 | BBFetchException.__init__(self, msg) |
| 118 | self.args = (message, url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | |
| 120 | class NetworkAccess(BBFetchException): |
| 121 | """Exception raised when network access is disabled but it is required.""" |
| 122 | def __init__(self, url, cmd): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 123 | msg = "Network access disabled through BB_NO_NETWORK (or set indirectly due to use of BB_FETCH_PREMIRRORONLY) but access requested with command %s (for url %s)" % (cmd, url) |
| 124 | self.url = url |
| 125 | self.cmd = cmd |
| 126 | BBFetchException.__init__(self, msg) |
| 127 | self.args = (url, cmd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | |
| 129 | class NonLocalMethod(Exception): |
| 130 | def __init__(self): |
| 131 | Exception.__init__(self) |
| 132 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 133 | class MissingChecksumEvent(bb.event.Event): |
| 134 | def __init__(self, url, md5sum, sha256sum): |
| 135 | self.url = url |
| 136 | self.checksums = {'md5sum': md5sum, |
| 137 | 'sha256sum': sha256sum} |
| 138 | bb.event.Event.__init__(self) |
| 139 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | |
| 141 | class URI(object): |
| 142 | """ |
| 143 | A class representing a generic URI, with methods for |
| 144 | accessing the URI components, and stringifies to the |
| 145 | URI. |
| 146 | |
| 147 | It is constructed by calling it with a URI, or setting |
| 148 | the attributes manually: |
| 149 | |
| 150 | uri = URI("http://example.com/") |
| 151 | |
| 152 | uri = URI() |
| 153 | uri.scheme = 'http' |
| 154 | uri.hostname = 'example.com' |
| 155 | uri.path = '/' |
| 156 | |
| 157 | It has the following attributes: |
| 158 | |
| 159 | * scheme (read/write) |
| 160 | * userinfo (authentication information) (read/write) |
| 161 | * username (read/write) |
| 162 | * password (read/write) |
| 163 | |
| 164 | Note, password is deprecated as of RFC 3986. |
| 165 | |
| 166 | * hostname (read/write) |
| 167 | * port (read/write) |
| 168 | * hostport (read only) |
| 169 | "hostname:port", if both are set, otherwise just "hostname" |
| 170 | * path (read/write) |
| 171 | * path_quoted (read/write) |
| 172 | A URI quoted version of path |
| 173 | * params (dict) (read/write) |
| 174 | * query (dict) (read/write) |
| 175 | * relative (bool) (read only) |
| 176 | True if this is a "relative URI", (e.g. file:foo.diff) |
| 177 | |
| 178 | It stringifies to the URI itself. |
| 179 | |
| 180 | Some notes about relative URIs: while it's specified that |
| 181 | a URI beginning with <scheme>:// should either be directly |
| 182 | followed by a hostname or a /, the old URI handling of the |
| 183 | fetch2 library did not comform to this. Therefore, this URI |
| 184 | class has some kludges to make sure that URIs are parsed in |
| 185 | a way comforming to bitbake's current usage. This URI class |
| 186 | supports the following: |
| 187 | |
| 188 | file:relative/path.diff (IETF compliant) |
| 189 | git:relative/path.git (IETF compliant) |
| 190 | git:///absolute/path.git (IETF compliant) |
| 191 | file:///absolute/path.diff (IETF compliant) |
| 192 | |
| 193 | file://relative/path.diff (not IETF compliant) |
| 194 | |
| 195 | But it does not support the following: |
| 196 | |
| 197 | file://hostname/absolute/path.diff (would be IETF compliant) |
| 198 | |
| 199 | Note that the last case only applies to a list of |
| 200 | "whitelisted" schemes (currently only file://), that requires |
| 201 | its URIs to not have a network location. |
| 202 | """ |
| 203 | |
| 204 | _relative_schemes = ['file', 'git'] |
| 205 | _netloc_forbidden = ['file'] |
| 206 | |
| 207 | def __init__(self, uri=None): |
| 208 | self.scheme = '' |
| 209 | self.userinfo = '' |
| 210 | self.hostname = '' |
| 211 | self.port = None |
| 212 | self._path = '' |
| 213 | self.params = {} |
| 214 | self.query = {} |
| 215 | self.relative = False |
| 216 | |
| 217 | if not uri: |
| 218 | return |
| 219 | |
| 220 | # We hijack the URL parameters, since the way bitbake uses |
| 221 | # them are not quite RFC compliant. |
| 222 | uri, param_str = (uri.split(";", 1) + [None])[:2] |
| 223 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 224 | urlp = urllib.parse.urlparse(uri) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | self.scheme = urlp.scheme |
| 226 | |
| 227 | reparse = 0 |
| 228 | |
| 229 | # Coerce urlparse to make URI scheme use netloc |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 230 | if not self.scheme in urllib.parse.uses_netloc: |
| 231 | urllib.parse.uses_params.append(self.scheme) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 232 | reparse = 1 |
| 233 | |
| 234 | # Make urlparse happy(/ier) by converting local resources |
| 235 | # to RFC compliant URL format. E.g.: |
| 236 | # file://foo.diff -> file:foo.diff |
| 237 | if urlp.scheme in self._netloc_forbidden: |
| 238 | uri = re.sub("(?<=:)//(?!/)", "", uri, 1) |
| 239 | reparse = 1 |
| 240 | |
| 241 | if reparse: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 242 | urlp = urllib.parse.urlparse(uri) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | |
| 244 | # Identify if the URI is relative or not |
| 245 | if urlp.scheme in self._relative_schemes and \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 246 | re.compile(r"^\w+:(?!//)").match(uri): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 | self.relative = True |
| 248 | |
| 249 | if not self.relative: |
| 250 | self.hostname = urlp.hostname or '' |
| 251 | self.port = urlp.port |
| 252 | |
| 253 | self.userinfo += urlp.username or '' |
| 254 | |
| 255 | if urlp.password: |
| 256 | self.userinfo += ':%s' % urlp.password |
| 257 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 258 | self.path = urllib.parse.unquote(urlp.path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 259 | |
| 260 | if param_str: |
| 261 | self.params = self._param_str_split(param_str, ";") |
| 262 | if urlp.query: |
| 263 | self.query = self._param_str_split(urlp.query, "&") |
| 264 | |
| 265 | def __str__(self): |
| 266 | userinfo = self.userinfo |
| 267 | if userinfo: |
| 268 | userinfo += '@' |
| 269 | |
| 270 | return "%s:%s%s%s%s%s%s" % ( |
| 271 | self.scheme, |
| 272 | '' if self.relative else '//', |
| 273 | userinfo, |
| 274 | self.hostport, |
| 275 | self.path_quoted, |
| 276 | self._query_str(), |
| 277 | self._param_str()) |
| 278 | |
| 279 | def _param_str(self): |
| 280 | return ( |
| 281 | ''.join([';', self._param_str_join(self.params, ";")]) |
| 282 | if self.params else '') |
| 283 | |
| 284 | def _query_str(self): |
| 285 | return ( |
| 286 | ''.join(['?', self._param_str_join(self.query, "&")]) |
| 287 | if self.query else '') |
| 288 | |
| 289 | def _param_str_split(self, string, elmdelim, kvdelim="="): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 290 | ret = collections.OrderedDict() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 291 | for k, v in [x.split(kvdelim, 1) for x in string.split(elmdelim)]: |
| 292 | ret[k] = v |
| 293 | return ret |
| 294 | |
| 295 | def _param_str_join(self, dict_, elmdelim, kvdelim="="): |
| 296 | return elmdelim.join([kvdelim.join([k, v]) for k, v in dict_.items()]) |
| 297 | |
| 298 | @property |
| 299 | def hostport(self): |
| 300 | if not self.port: |
| 301 | return self.hostname |
| 302 | return "%s:%d" % (self.hostname, self.port) |
| 303 | |
| 304 | @property |
| 305 | def path_quoted(self): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 306 | return urllib.parse.quote(self.path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 307 | |
| 308 | @path_quoted.setter |
| 309 | def path_quoted(self, path): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 310 | self.path = urllib.parse.unquote(path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 311 | |
| 312 | @property |
| 313 | def path(self): |
| 314 | return self._path |
| 315 | |
| 316 | @path.setter |
| 317 | def path(self, path): |
| 318 | self._path = path |
| 319 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 320 | if not path or re.compile("^/").match(path): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 321 | self.relative = False |
| 322 | else: |
| 323 | self.relative = True |
| 324 | |
| 325 | @property |
| 326 | def username(self): |
| 327 | if self.userinfo: |
| 328 | return (self.userinfo.split(":", 1))[0] |
| 329 | return '' |
| 330 | |
| 331 | @username.setter |
| 332 | def username(self, username): |
| 333 | password = self.password |
| 334 | self.userinfo = username |
| 335 | if password: |
| 336 | self.userinfo += ":%s" % password |
| 337 | |
| 338 | @property |
| 339 | def password(self): |
| 340 | if self.userinfo and ":" in self.userinfo: |
| 341 | return (self.userinfo.split(":", 1))[1] |
| 342 | return '' |
| 343 | |
| 344 | @password.setter |
| 345 | def password(self, password): |
| 346 | self.userinfo = "%s:%s" % (self.username, password) |
| 347 | |
| 348 | def decodeurl(url): |
| 349 | """Decodes an URL into the tokens (scheme, network location, path, |
| 350 | user, password, parameters). |
| 351 | """ |
| 352 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 353 | m = re.compile('(?P<type>[^:]*)://((?P<user>[^/;]+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 354 | if not m: |
| 355 | raise MalformedUrl(url) |
| 356 | |
| 357 | type = m.group('type') |
| 358 | location = m.group('location') |
| 359 | if not location: |
| 360 | raise MalformedUrl(url) |
| 361 | user = m.group('user') |
| 362 | parm = m.group('parm') |
| 363 | |
| 364 | locidx = location.find('/') |
| 365 | if locidx != -1 and type.lower() != 'file': |
| 366 | host = location[:locidx] |
| 367 | path = location[locidx:] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 368 | elif type.lower() == 'file': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 369 | host = "" |
| 370 | path = location |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 371 | else: |
| 372 | host = location |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 373 | path = "/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 374 | if user: |
| 375 | m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user) |
| 376 | if m: |
| 377 | user = m.group('user') |
| 378 | pswd = m.group('pswd') |
| 379 | else: |
| 380 | user = '' |
| 381 | pswd = '' |
| 382 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 383 | p = collections.OrderedDict() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 384 | if parm: |
| 385 | for s in parm.split(';'): |
| 386 | if s: |
| 387 | if not '=' in s: |
| 388 | raise MalformedUrl(url, "The URL: '%s' is invalid: parameter %s does not specify a value (missing '=')" % (url, s)) |
| 389 | s1, s2 = s.split('=') |
| 390 | p[s1] = s2 |
| 391 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 392 | return type, host, urllib.parse.unquote(path), user, pswd, p |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 393 | |
| 394 | def encodeurl(decoded): |
| 395 | """Encodes a URL from tokens (scheme, network location, path, |
| 396 | user, password, parameters). |
| 397 | """ |
| 398 | |
| 399 | type, host, path, user, pswd, p = decoded |
| 400 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 401 | if not type: |
| 402 | raise MissingParameterError('type', "encoded from the data %s" % str(decoded)) |
| 403 | url = '%s://' % type |
| 404 | if user and type != "file": |
| 405 | url += "%s" % user |
| 406 | if pswd: |
| 407 | url += ":%s" % pswd |
| 408 | url += "@" |
| 409 | if host and type != "file": |
| 410 | url += "%s" % host |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 411 | if path: |
| 412 | # Standardise path to ensure comparisons work |
| 413 | while '//' in path: |
| 414 | path = path.replace("//", "/") |
| 415 | url += "%s" % urllib.parse.quote(path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 416 | if p: |
| 417 | for parm in p: |
| 418 | url += ";%s=%s" % (parm, p[parm]) |
| 419 | |
| 420 | return url |
| 421 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 422 | def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 423 | if not ud.url or not uri_find or not uri_replace: |
| 424 | logger.error("uri_replace: passed an undefined value, not replacing") |
| 425 | return None |
| 426 | uri_decoded = list(decodeurl(ud.url)) |
| 427 | uri_find_decoded = list(decodeurl(uri_find)) |
| 428 | uri_replace_decoded = list(decodeurl(uri_replace)) |
| 429 | logger.debug(2, "For url %s comparing %s to %s" % (uri_decoded, uri_find_decoded, uri_replace_decoded)) |
| 430 | result_decoded = ['', '', '', '', '', {}] |
| 431 | for loc, i in enumerate(uri_find_decoded): |
| 432 | result_decoded[loc] = uri_decoded[loc] |
| 433 | regexp = i |
| 434 | if loc == 0 and regexp and not regexp.endswith("$"): |
| 435 | # Leaving the type unanchored can mean "https" matching "file" can become "files" |
| 436 | # which is clearly undesirable. |
| 437 | regexp += "$" |
| 438 | if loc == 5: |
| 439 | # Handle URL parameters |
| 440 | if i: |
| 441 | # Any specified URL parameters must match |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 442 | for k in uri_find_decoded[loc]: |
| 443 | if uri_decoded[loc][k] != uri_find_decoded[loc][k]: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 444 | return None |
| 445 | # Overwrite any specified replacement parameters |
| 446 | for k in uri_replace_decoded[loc]: |
| 447 | for l in replacements: |
| 448 | uri_replace_decoded[loc][k] = uri_replace_decoded[loc][k].replace(l, replacements[l]) |
| 449 | result_decoded[loc][k] = uri_replace_decoded[loc][k] |
| 450 | elif (re.match(regexp, uri_decoded[loc])): |
| 451 | if not uri_replace_decoded[loc]: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 452 | result_decoded[loc] = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 453 | else: |
| 454 | for k in replacements: |
| 455 | uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k]) |
| 456 | #bb.note("%s %s %s" % (regexp, uri_replace_decoded[loc], uri_decoded[loc])) |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 457 | result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc], uri_decoded[loc], 1) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 458 | if loc == 2: |
| 459 | # Handle path manipulations |
| 460 | basename = None |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 461 | if uri_decoded[0] != uri_replace_decoded[0] and mirrortarball: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 462 | # If the source and destination url types differ, must be a mirrortarball mapping |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 463 | basename = os.path.basename(mirrortarball) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 464 | # Kill parameters, they make no sense for mirror tarballs |
| 465 | uri_decoded[5] = {} |
| 466 | elif ud.localpath and ud.method.supports_checksum(ud): |
| 467 | basename = os.path.basename(ud.localpath) |
| 468 | if basename and not result_decoded[loc].endswith(basename): |
| 469 | result_decoded[loc] = os.path.join(result_decoded[loc], basename) |
| 470 | else: |
| 471 | return None |
| 472 | result = encodeurl(result_decoded) |
| 473 | if result == ud.url: |
| 474 | return None |
| 475 | logger.debug(2, "For url %s returning %s" % (ud.url, result)) |
| 476 | return result |
| 477 | |
| 478 | methods = [] |
| 479 | urldata_cache = {} |
| 480 | saved_headrevs = {} |
| 481 | |
| 482 | def fetcher_init(d): |
| 483 | """ |
| 484 | Called to initialize the fetchers once the configuration data is known. |
| 485 | Calls before this must not hit the cache. |
| 486 | """ |
| 487 | # When to drop SCM head revisions controlled by user policy |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 488 | srcrev_policy = d.getVar('BB_SRCREV_POLICY') or "clear" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 489 | if srcrev_policy == "cache": |
| 490 | logger.debug(1, "Keeping SRCREV cache due to cache policy of: %s", srcrev_policy) |
| 491 | elif srcrev_policy == "clear": |
| 492 | logger.debug(1, "Clearing SRCREV cache due to cache policy of: %s", srcrev_policy) |
| 493 | revs = bb.persist_data.persist('BB_URI_HEADREVS', d) |
| 494 | try: |
| 495 | bb.fetch2.saved_headrevs = revs.items() |
| 496 | except: |
| 497 | pass |
| 498 | revs.clear() |
| 499 | else: |
| 500 | raise FetchError("Invalid SRCREV cache policy of: %s" % srcrev_policy) |
| 501 | |
| 502 | _checksum_cache.init_cache(d) |
| 503 | |
| 504 | for m in methods: |
| 505 | if hasattr(m, "init"): |
| 506 | m.init(d) |
| 507 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 508 | def fetcher_parse_save(): |
| 509 | _checksum_cache.save_extras() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 510 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 511 | def fetcher_parse_done(): |
| 512 | _checksum_cache.save_merge() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 513 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 514 | def fetcher_compare_revisions(d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 515 | """ |
| 516 | Compare the revisions in the persistant cache with current values and |
| 517 | return true/false on whether they've changed. |
| 518 | """ |
| 519 | |
| 520 | data = bb.persist_data.persist('BB_URI_HEADREVS', d).items() |
| 521 | data2 = bb.fetch2.saved_headrevs |
| 522 | |
| 523 | changed = False |
| 524 | for key in data: |
| 525 | if key not in data2 or data2[key] != data[key]: |
| 526 | logger.debug(1, "%s changed", key) |
| 527 | changed = True |
| 528 | return True |
| 529 | else: |
| 530 | logger.debug(2, "%s did not change", key) |
| 531 | return False |
| 532 | |
| 533 | def mirror_from_string(data): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 534 | mirrors = (data or "").replace('\\n',' ').split() |
| 535 | # Split into pairs |
| 536 | if len(mirrors) % 2 != 0: |
| 537 | bb.warn('Invalid mirror data %s, should have paired members.' % data) |
| 538 | return list(zip(*[iter(mirrors)]*2)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 539 | |
| 540 | def verify_checksum(ud, d, precomputed={}): |
| 541 | """ |
| 542 | verify the MD5 and SHA256 checksum for downloaded src |
| 543 | |
| 544 | Raises a FetchError if one or both of the SRC_URI checksums do not match |
| 545 | the downloaded file, or if BB_STRICT_CHECKSUM is set and there are no |
| 546 | checksums specified. |
| 547 | |
| 548 | Returns a dict of checksums that can be stored in a done stamp file and |
| 549 | passed in as precomputed parameter in a later call to avoid re-computing |
| 550 | the checksums from the file. This allows verifying the checksums of the |
| 551 | file against those in the recipe each time, rather than only after |
| 552 | downloading. See https://bugzilla.yoctoproject.org/show_bug.cgi?id=5571. |
| 553 | """ |
| 554 | |
| 555 | _MD5_KEY = "md5" |
| 556 | _SHA256_KEY = "sha256" |
| 557 | |
| 558 | if ud.ignore_checksums or not ud.method.supports_checksum(ud): |
| 559 | return {} |
| 560 | |
| 561 | if _MD5_KEY in precomputed: |
| 562 | md5data = precomputed[_MD5_KEY] |
| 563 | else: |
| 564 | md5data = bb.utils.md5_file(ud.localpath) |
| 565 | |
| 566 | if _SHA256_KEY in precomputed: |
| 567 | sha256data = precomputed[_SHA256_KEY] |
| 568 | else: |
| 569 | sha256data = bb.utils.sha256_file(ud.localpath) |
| 570 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 571 | if ud.method.recommends_checksum(ud) and not ud.md5_expected and not ud.sha256_expected: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 572 | # If strict checking enabled and neither sum defined, raise error |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 573 | strict = d.getVar("BB_STRICT_CHECKSUM") or "0" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 574 | if strict == "1": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 575 | logger.error('No checksum specified for %s, please add at least one to the recipe:\n' |
| 576 | 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' % |
| 577 | (ud.localpath, ud.md5_name, md5data, |
| 578 | ud.sha256_name, sha256data)) |
| 579 | raise NoChecksumError('Missing SRC_URI checksum', ud.url) |
| 580 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 581 | bb.event.fire(MissingChecksumEvent(ud.url, md5data, sha256data), d) |
| 582 | |
| 583 | if strict == "ignore": |
| 584 | return { |
| 585 | _MD5_KEY: md5data, |
| 586 | _SHA256_KEY: sha256data |
| 587 | } |
| 588 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 589 | # Log missing sums so user can more easily add them |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 590 | logger.warning('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n' |
| 591 | 'SRC_URI[%s] = "%s"', |
| 592 | ud.localpath, ud.md5_name, md5data) |
| 593 | logger.warning('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n' |
| 594 | 'SRC_URI[%s] = "%s"', |
| 595 | ud.localpath, ud.sha256_name, sha256data) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 596 | |
| 597 | # We want to alert the user if a checksum is defined in the recipe but |
| 598 | # it does not match. |
| 599 | msg = "" |
| 600 | mismatch = False |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 601 | if ud.md5_expected and ud.md5_expected != md5data: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 602 | msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'md5', md5data, ud.md5_expected) |
| 603 | mismatch = True; |
| 604 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 605 | if ud.sha256_expected and ud.sha256_expected != sha256data: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 606 | msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'sha256', sha256data, ud.sha256_expected) |
| 607 | mismatch = True; |
| 608 | |
| 609 | if mismatch: |
| 610 | msg = msg + '\nIf this change is expected (e.g. you have upgraded to a new version without updating the checksums) then you can use these lines within the recipe:\nSRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"\nOtherwise you should retry the download and/or check with upstream to determine if the file has become corrupted or otherwise unexpectedly modified.\n' % (ud.md5_name, md5data, ud.sha256_name, sha256data) |
| 611 | |
| 612 | if len(msg): |
| 613 | raise ChecksumError('Checksum mismatch!%s' % msg, ud.url, md5data) |
| 614 | |
| 615 | return { |
| 616 | _MD5_KEY: md5data, |
| 617 | _SHA256_KEY: sha256data |
| 618 | } |
| 619 | |
| 620 | |
| 621 | def verify_donestamp(ud, d, origud=None): |
| 622 | """ |
| 623 | Check whether the done stamp file has the right checksums (if the fetch |
| 624 | method supports them). If it doesn't, delete the done stamp and force |
| 625 | a re-download. |
| 626 | |
| 627 | Returns True, if the donestamp exists and is valid, False otherwise. When |
| 628 | returning False, any existing done stamps are removed. |
| 629 | """ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 630 | if not ud.needdonestamp or (origud and not origud.needdonestamp): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 631 | return True |
| 632 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 633 | if not os.path.exists(ud.localpath): |
| 634 | # local path does not exist |
| 635 | if os.path.exists(ud.donestamp): |
| 636 | # done stamp exists, but the downloaded file does not; the done stamp |
| 637 | # must be incorrect, re-trigger the download |
| 638 | bb.utils.remove(ud.donestamp) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 639 | return False |
| 640 | |
| 641 | if (not ud.method.supports_checksum(ud) or |
| 642 | (origud and not origud.method.supports_checksum(origud))): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 643 | # if done stamp exists and checksums not supported; assume the local |
| 644 | # file is current |
| 645 | return os.path.exists(ud.donestamp) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 646 | |
| 647 | precomputed_checksums = {} |
| 648 | # Only re-use the precomputed checksums if the donestamp is newer than the |
| 649 | # file. Do not rely on the mtime of directories, though. If ud.localpath is |
| 650 | # a directory, there will probably not be any checksums anyway. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 651 | if os.path.exists(ud.donestamp) and (os.path.isdir(ud.localpath) or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 652 | os.path.getmtime(ud.localpath) < os.path.getmtime(ud.donestamp)): |
| 653 | try: |
| 654 | with open(ud.donestamp, "rb") as cachefile: |
| 655 | pickled = pickle.Unpickler(cachefile) |
| 656 | precomputed_checksums.update(pickled.load()) |
| 657 | except Exception as e: |
| 658 | # Avoid the warnings on the upgrade path from emtpy done stamp |
| 659 | # files to those containing the checksums. |
| 660 | if not isinstance(e, EOFError): |
| 661 | # Ignore errors, they aren't fatal |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 662 | logger.warning("Couldn't load checksums from donestamp %s: %s " |
| 663 | "(msg: %s)" % (ud.donestamp, type(e).__name__, |
| 664 | str(e))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 665 | |
| 666 | try: |
| 667 | checksums = verify_checksum(ud, d, precomputed_checksums) |
| 668 | # If the cache file did not have the checksums, compute and store them |
| 669 | # as an upgrade path from the previous done stamp file format. |
| 670 | if checksums != precomputed_checksums: |
| 671 | with open(ud.donestamp, "wb") as cachefile: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 672 | p = pickle.Pickler(cachefile, 2) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 673 | p.dump(checksums) |
| 674 | return True |
| 675 | except ChecksumError as e: |
| 676 | # Checksums failed to verify, trigger re-download and remove the |
| 677 | # incorrect stamp file. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 678 | logger.warning("Checksum mismatch for local file %s\n" |
| 679 | "Cleaning and trying again." % ud.localpath) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 680 | if os.path.exists(ud.localpath): |
| 681 | rename_bad_checksum(ud, e.checksum) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 682 | bb.utils.remove(ud.donestamp) |
| 683 | return False |
| 684 | |
| 685 | |
| 686 | def update_stamp(ud, d): |
| 687 | """ |
| 688 | donestamp is file stamp indicating the whole fetching is done |
| 689 | this function update the stamp after verifying the checksum |
| 690 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 691 | if not ud.needdonestamp: |
| 692 | return |
| 693 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 694 | if os.path.exists(ud.donestamp): |
| 695 | # Touch the done stamp file to show active use of the download |
| 696 | try: |
| 697 | os.utime(ud.donestamp, None) |
| 698 | except: |
| 699 | # Errors aren't fatal here |
| 700 | pass |
| 701 | else: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 702 | try: |
| 703 | checksums = verify_checksum(ud, d) |
| 704 | # Store the checksums for later re-verification against the recipe |
| 705 | with open(ud.donestamp, "wb") as cachefile: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 706 | p = pickle.Pickler(cachefile, 2) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 707 | p.dump(checksums) |
| 708 | except ChecksumError as e: |
| 709 | # Checksums failed to verify, trigger re-download and remove the |
| 710 | # incorrect stamp file. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 711 | logger.warning("Checksum mismatch for local file %s\n" |
| 712 | "Cleaning and trying again." % ud.localpath) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 713 | if os.path.exists(ud.localpath): |
| 714 | rename_bad_checksum(ud, e.checksum) |
| 715 | bb.utils.remove(ud.donestamp) |
| 716 | raise |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 717 | |
| 718 | def subprocess_setup(): |
| 719 | # Python installs a SIGPIPE handler by default. This is usually not what |
| 720 | # non-Python subprocesses expect. |
| 721 | # SIGPIPE errors are known issues with gzip/bash |
| 722 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
| 723 | |
| 724 | def get_autorev(d): |
| 725 | # only not cache src rev in autorev case |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 726 | if d.getVar('BB_SRCREV_POLICY') != "cache": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 727 | d.setVar('BB_DONT_CACHE', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 728 | return "AUTOINC" |
| 729 | |
| 730 | def get_srcrev(d, method_name='sortable_revision'): |
| 731 | """ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 732 | Return the revision string, usually for use in the version string (PV) of the current package |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 733 | Most packages usually only have one SCM so we just pass on the call. |
| 734 | In the multi SCM case, we build a value based on SRCREV_FORMAT which must |
| 735 | have been set. |
| 736 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 737 | The idea here is that we put the string "AUTOINC+" into return value if the revisions are not |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 738 | incremental, other code is then responsible for turning that into an increasing value (if needed) |
| 739 | |
| 740 | A method_name can be supplied to retrieve an alternatively formatted revision from a fetcher, if |
| 741 | that fetcher provides a method with the given name and the same signature as sortable_revision. |
| 742 | """ |
| 743 | |
| 744 | scms = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 745 | fetcher = Fetch(d.getVar('SRC_URI').split(), d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 746 | urldata = fetcher.ud |
| 747 | for u in urldata: |
| 748 | if urldata[u].method.supports_srcrev(): |
| 749 | scms.append(u) |
| 750 | |
| 751 | if len(scms) == 0: |
| 752 | raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") |
| 753 | |
| 754 | if len(scms) == 1 and len(urldata[scms[0]].names) == 1: |
| 755 | autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) |
| 756 | if len(rev) > 10: |
| 757 | rev = rev[:10] |
| 758 | if autoinc: |
| 759 | return "AUTOINC+" + rev |
| 760 | return rev |
| 761 | |
| 762 | # |
| 763 | # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT |
| 764 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 765 | format = d.getVar('SRCREV_FORMAT') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 766 | if not format: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 767 | raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.\n"\ |
| 768 | "The SCMs are:\n%s" % '\n'.join(scms)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 769 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 770 | name_to_rev = {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 771 | seenautoinc = False |
| 772 | for scm in scms: |
| 773 | ud = urldata[scm] |
| 774 | for name in ud.names: |
| 775 | autoinc, rev = getattr(ud.method, method_name)(ud, d, name) |
| 776 | seenautoinc = seenautoinc or autoinc |
| 777 | if len(rev) > 10: |
| 778 | rev = rev[:10] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 779 | name_to_rev[name] = rev |
| 780 | # Replace names by revisions in the SRCREV_FORMAT string. The approach used |
| 781 | # here can handle names being prefixes of other names and names appearing |
| 782 | # as substrings in revisions (in which case the name should not be |
| 783 | # expanded). The '|' regular expression operator tries matches from left to |
| 784 | # right, so we need to sort the names with the longest ones first. |
| 785 | names_descending_len = sorted(name_to_rev, key=len, reverse=True) |
| 786 | name_to_rev_re = "|".join(re.escape(name) for name in names_descending_len) |
| 787 | format = re.sub(name_to_rev_re, lambda match: name_to_rev[match.group(0)], format) |
| 788 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 789 | if seenautoinc: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 790 | format = "AUTOINC+" + format |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 791 | |
| 792 | return format |
| 793 | |
| 794 | def localpath(url, d): |
| 795 | fetcher = bb.fetch2.Fetch([url], d) |
| 796 | return fetcher.localpath(url) |
| 797 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 798 | def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 799 | """ |
| 800 | Run cmd returning the command output |
| 801 | Raise an error if interrupted or cmd fails |
| 802 | Optionally echo command output to stdout |
| 803 | Optionally remove the files/directories listed in cleanup upon failure |
| 804 | """ |
| 805 | |
| 806 | # Need to export PATH as binary could be in metadata paths |
| 807 | # rather than host provided |
| 808 | # Also include some other variables. |
| 809 | # FIXME: Should really include all export varaiables? |
| 810 | exportvars = ['HOME', 'PATH', |
| 811 | 'HTTP_PROXY', 'http_proxy', |
| 812 | 'HTTPS_PROXY', 'https_proxy', |
| 813 | 'FTP_PROXY', 'ftp_proxy', |
| 814 | 'FTPS_PROXY', 'ftps_proxy', |
| 815 | 'NO_PROXY', 'no_proxy', |
| 816 | 'ALL_PROXY', 'all_proxy', |
| 817 | 'GIT_PROXY_COMMAND', |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 818 | 'GIT_SSH', |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 819 | 'GIT_SSL_CAINFO', |
| 820 | 'GIT_SMART_HTTP', |
| 821 | 'SSH_AUTH_SOCK', 'SSH_AGENT_PID', |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 822 | 'SOCKS5_USER', 'SOCKS5_PASSWD', |
| 823 | 'DBUS_SESSION_BUS_ADDRESS', |
| 824 | 'P4CONFIG'] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 825 | |
| 826 | if not cleanup: |
| 827 | cleanup = [] |
| 828 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 829 | # If PATH contains WORKDIR which contains PV-PR which contains SRCPV we |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 830 | # can end up in circular recursion here so give the option of breaking it |
| 831 | # in a data store copy. |
| 832 | try: |
| 833 | d.getVar("PV") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 834 | d.getVar("PR") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 835 | except bb.data_smart.ExpansionError: |
| 836 | d = bb.data.createCopy(d) |
| 837 | d.setVar("PV", "fetcheravoidrecurse") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 838 | d.setVar("PR", "fetcheravoidrecurse") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 839 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 840 | origenv = d.getVar("BB_ORIGENV", False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 841 | for var in exportvars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 842 | val = d.getVar(var) or (origenv and origenv.getVar(var)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 843 | if val: |
| 844 | cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd) |
| 845 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame^] | 846 | # Ensure that a _PYTHON_SYSCONFIGDATA_NAME value set by a recipe |
| 847 | # (for example via python3native.bbclass since warrior) is not set for |
| 848 | # host Python (otherwise tools like git-make-shallow will fail) |
| 849 | cmd = 'unset _PYTHON_SYSCONFIGDATA_NAME; ' + cmd |
| 850 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 851 | # Disable pseudo as it may affect ssh, potentially causing it to hang. |
| 852 | cmd = 'export PSEUDO_DISABLED=1; ' + cmd |
| 853 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 854 | if workdir: |
| 855 | logger.debug(1, "Running '%s' in %s" % (cmd, workdir)) |
| 856 | else: |
| 857 | logger.debug(1, "Running %s", cmd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 858 | |
| 859 | success = False |
| 860 | error_message = "" |
| 861 | |
| 862 | try: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 863 | (output, errors) = bb.process.run(cmd, log=log, shell=True, stderr=subprocess.PIPE, cwd=workdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 864 | success = True |
| 865 | except bb.process.NotFoundError as e: |
| 866 | error_message = "Fetch command %s" % (e.command) |
| 867 | except bb.process.ExecutionError as e: |
| 868 | if e.stdout: |
| 869 | output = "output:\n%s\n%s" % (e.stdout, e.stderr) |
| 870 | elif e.stderr: |
| 871 | output = "output:\n%s" % e.stderr |
| 872 | else: |
| 873 | output = "no output" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 874 | error_message = "Fetch command %s failed with exit code %s, %s" % (e.command, e.exitcode, output) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 875 | except bb.process.CmdError as e: |
| 876 | error_message = "Fetch command %s could not be run:\n%s" % (e.command, e.msg) |
| 877 | if not success: |
| 878 | for f in cleanup: |
| 879 | try: |
| 880 | bb.utils.remove(f, True) |
| 881 | except OSError: |
| 882 | pass |
| 883 | |
| 884 | raise FetchError(error_message) |
| 885 | |
| 886 | return output |
| 887 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 888 | def check_network_access(d, info, url): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 889 | """ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 890 | log remote network access, and error if BB_NO_NETWORK is set or the given |
| 891 | URI is untrusted |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 892 | """ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 893 | if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 894 | raise NetworkAccess(url, info) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 895 | elif not trusted_network(d, url): |
| 896 | raise UntrustedUrl(url, info) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 897 | else: |
| 898 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) |
| 899 | |
| 900 | def build_mirroruris(origud, mirrors, ld): |
| 901 | uris = [] |
| 902 | uds = [] |
| 903 | |
| 904 | replacements = {} |
| 905 | replacements["TYPE"] = origud.type |
| 906 | replacements["HOST"] = origud.host |
| 907 | replacements["PATH"] = origud.path |
| 908 | replacements["BASENAME"] = origud.path.split("/")[-1] |
| 909 | replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.').replace('*', '.') |
| 910 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 911 | def adduri(ud, uris, uds, mirrors, tarballs): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 912 | for line in mirrors: |
| 913 | try: |
| 914 | (find, replace) = line |
| 915 | except ValueError: |
| 916 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 917 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 918 | for tarball in tarballs: |
| 919 | newuri = uri_replace(ud, find, replace, replacements, ld, tarball) |
| 920 | if not newuri or newuri in uris or newuri == origud.url: |
| 921 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 922 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 923 | if not trusted_network(ld, newuri): |
| 924 | logger.debug(1, "Mirror %s not in the list of trusted networks, skipping" % (newuri)) |
| 925 | continue |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 926 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 927 | # Create a local copy of the mirrors minus the current line |
| 928 | # this will prevent us from recursively processing the same line |
| 929 | # as well as indirect recursion A -> B -> C -> A |
| 930 | localmirrors = list(mirrors) |
| 931 | localmirrors.remove(line) |
| 932 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 933 | try: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 934 | newud = FetchData(newuri, ld) |
| 935 | newud.setup_localpath(ld) |
| 936 | except bb.fetch2.BBFetchException as e: |
| 937 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) |
| 938 | logger.debug(1, str(e)) |
| 939 | try: |
| 940 | # setup_localpath of file:// urls may fail, we should still see |
| 941 | # if mirrors of the url exist |
| 942 | adduri(newud, uris, uds, localmirrors, tarballs) |
| 943 | except UnboundLocalError: |
| 944 | pass |
| 945 | continue |
| 946 | uris.append(newuri) |
| 947 | uds.append(newud) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 948 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 949 | adduri(newud, uris, uds, localmirrors, tarballs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 950 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 951 | adduri(origud, uris, uds, mirrors, origud.mirrortarballs or [None]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 952 | |
| 953 | return uris, uds |
| 954 | |
| 955 | def rename_bad_checksum(ud, suffix): |
| 956 | """ |
| 957 | Renames files to have suffix from parameter |
| 958 | """ |
| 959 | |
| 960 | if ud.localpath is None: |
| 961 | return |
| 962 | |
| 963 | new_localpath = "%s_bad-checksum_%s" % (ud.localpath, suffix) |
| 964 | bb.warn("Renaming %s to %s" % (ud.localpath, new_localpath)) |
| 965 | bb.utils.movefile(ud.localpath, new_localpath) |
| 966 | |
| 967 | |
| 968 | def try_mirror_url(fetch, origud, ud, ld, check = False): |
| 969 | # Return of None or a value means we're finished |
| 970 | # False means try another url |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 971 | |
| 972 | if ud.lockfile and ud.lockfile != origud.lockfile: |
| 973 | lf = bb.utils.lockfile(ud.lockfile) |
| 974 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 975 | try: |
| 976 | if check: |
| 977 | found = ud.method.checkstatus(fetch, ud, ld) |
| 978 | if found: |
| 979 | return found |
| 980 | return False |
| 981 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 982 | if not verify_donestamp(ud, ld, origud) or ud.method.need_update(ud, ld): |
| 983 | ud.method.download(ud, ld) |
| 984 | if hasattr(ud.method,"build_mirror_data"): |
| 985 | ud.method.build_mirror_data(ud, ld) |
| 986 | |
| 987 | if not ud.localpath or not os.path.exists(ud.localpath): |
| 988 | return False |
| 989 | |
| 990 | if ud.localpath == origud.localpath: |
| 991 | return ud.localpath |
| 992 | |
| 993 | # We may be obtaining a mirror tarball which needs further processing by the real fetcher |
| 994 | # If that tarball is a local file:// we need to provide a symlink to it |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 995 | dldir = ld.getVar("DL_DIR") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 996 | |
| 997 | if origud.mirrortarballs and os.path.basename(ud.localpath) in origud.mirrortarballs and os.path.basename(ud.localpath) != os.path.basename(origud.localpath): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 998 | # Create donestamp in old format to avoid triggering a re-download |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 999 | if ud.donestamp: |
| 1000 | bb.utils.mkdirhier(os.path.dirname(ud.donestamp)) |
| 1001 | open(ud.donestamp, 'w').close() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1002 | dest = os.path.join(dldir, os.path.basename(ud.localpath)) |
| 1003 | if not os.path.exists(dest): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1004 | # In case this is executing without any file locks held (as is |
| 1005 | # the case for file:// URLs), two tasks may end up here at the |
| 1006 | # same time, in which case we do not want the second task to |
| 1007 | # fail when the link has already been created by the first task. |
| 1008 | try: |
| 1009 | os.symlink(ud.localpath, dest) |
| 1010 | except FileExistsError: |
| 1011 | pass |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1012 | if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld): |
| 1013 | origud.method.download(origud, ld) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1014 | if hasattr(origud.method, "build_mirror_data"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1015 | origud.method.build_mirror_data(origud, ld) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 1016 | return origud.localpath |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1017 | # Otherwise the result is a local file:// and we symlink to it |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1018 | ensure_symlink(ud.localpath, origud.localpath) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1019 | update_stamp(origud, ld) |
| 1020 | return ud.localpath |
| 1021 | |
| 1022 | except bb.fetch2.NetworkAccess: |
| 1023 | raise |
| 1024 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1025 | except IOError as e: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1026 | if e.errno in [errno.ESTALE]: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1027 | logger.warning("Stale Error Observed %s." % ud.url) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1028 | return False |
| 1029 | raise |
| 1030 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1031 | except bb.fetch2.BBFetchException as e: |
| 1032 | if isinstance(e, ChecksumError): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1033 | logger.warning("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (ud.url, origud.url)) |
| 1034 | logger.warning(str(e)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1035 | if os.path.exists(ud.localpath): |
| 1036 | rename_bad_checksum(ud, e.checksum) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1037 | elif isinstance(e, NoChecksumError): |
| 1038 | raise |
| 1039 | else: |
| 1040 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (ud.url, origud.url)) |
| 1041 | logger.debug(1, str(e)) |
| 1042 | try: |
| 1043 | ud.method.clean(ud, ld) |
| 1044 | except UnboundLocalError: |
| 1045 | pass |
| 1046 | return False |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1047 | finally: |
| 1048 | if ud.lockfile and ud.lockfile != origud.lockfile: |
| 1049 | bb.utils.unlockfile(lf) |
| 1050 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1051 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1052 | def ensure_symlink(target, link_name): |
| 1053 | if not os.path.exists(link_name): |
| 1054 | if os.path.islink(link_name): |
| 1055 | # Broken symbolic link |
| 1056 | os.unlink(link_name) |
| 1057 | |
| 1058 | # In case this is executing without any file locks held (as is |
| 1059 | # the case for file:// URLs), two tasks may end up here at the |
| 1060 | # same time, in which case we do not want the second task to |
| 1061 | # fail when the link has already been created by the first task. |
| 1062 | try: |
| 1063 | os.symlink(target, link_name) |
| 1064 | except FileExistsError: |
| 1065 | pass |
| 1066 | |
| 1067 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1068 | def try_mirrors(fetch, d, origud, mirrors, check = False): |
| 1069 | """ |
| 1070 | Try to use a mirrored version of the sources. |
| 1071 | This method will be automatically called before the fetchers go. |
| 1072 | |
| 1073 | d Is a bb.data instance |
| 1074 | uri is the original uri we're trying to download |
| 1075 | mirrors is the list of mirrors we're going to try |
| 1076 | """ |
| 1077 | ld = d.createCopy() |
| 1078 | |
| 1079 | uris, uds = build_mirroruris(origud, mirrors, ld) |
| 1080 | |
| 1081 | for index, uri in enumerate(uris): |
| 1082 | ret = try_mirror_url(fetch, origud, uds[index], ld, check) |
| 1083 | if ret != False: |
| 1084 | return ret |
| 1085 | return None |
| 1086 | |
| 1087 | def trusted_network(d, url): |
| 1088 | """ |
| 1089 | Use a trusted url during download if networking is enabled and |
| 1090 | BB_ALLOWED_NETWORKS is set globally or for a specific recipe. |
| 1091 | Note: modifies SRC_URI & mirrors. |
| 1092 | """ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1093 | if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1094 | return True |
| 1095 | |
| 1096 | pkgname = d.expand(d.getVar('PN', False)) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1097 | trusted_hosts = None |
| 1098 | if pkgname: |
| 1099 | trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1100 | |
| 1101 | if not trusted_hosts: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1102 | trusted_hosts = d.getVar('BB_ALLOWED_NETWORKS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1103 | |
| 1104 | # Not enabled. |
| 1105 | if not trusted_hosts: |
| 1106 | return True |
| 1107 | |
| 1108 | scheme, network, path, user, passwd, param = decodeurl(url) |
| 1109 | |
| 1110 | if not network: |
| 1111 | return True |
| 1112 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1113 | network = network.split(':')[0] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1114 | network = network.lower() |
| 1115 | |
| 1116 | for host in trusted_hosts.split(" "): |
| 1117 | host = host.lower() |
| 1118 | if host.startswith("*.") and ("." + network).endswith(host[1:]): |
| 1119 | return True |
| 1120 | if host == network: |
| 1121 | return True |
| 1122 | |
| 1123 | return False |
| 1124 | |
| 1125 | def srcrev_internal_helper(ud, d, name): |
| 1126 | """ |
| 1127 | Return: |
| 1128 | a) a source revision if specified |
| 1129 | b) latest revision if SRCREV="AUTOINC" |
| 1130 | c) None if not specified |
| 1131 | """ |
| 1132 | |
| 1133 | srcrev = None |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1134 | pn = d.getVar("PN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1135 | attempts = [] |
| 1136 | if name != '' and pn: |
| 1137 | attempts.append("SRCREV_%s_pn-%s" % (name, pn)) |
| 1138 | if name != '': |
| 1139 | attempts.append("SRCREV_%s" % name) |
| 1140 | if pn: |
| 1141 | attempts.append("SRCREV_pn-%s" % pn) |
| 1142 | attempts.append("SRCREV") |
| 1143 | |
| 1144 | for a in attempts: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1145 | srcrev = d.getVar(a) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1146 | if srcrev and srcrev != "INVALID": |
| 1147 | break |
| 1148 | |
| 1149 | if 'rev' in ud.parm and 'tag' in ud.parm: |
| 1150 | raise FetchError("Please specify a ;rev= parameter or a ;tag= parameter in the url %s but not both." % (ud.url)) |
| 1151 | |
| 1152 | if 'rev' in ud.parm or 'tag' in ud.parm: |
| 1153 | if 'rev' in ud.parm: |
| 1154 | parmrev = ud.parm['rev'] |
| 1155 | else: |
| 1156 | parmrev = ud.parm['tag'] |
| 1157 | if srcrev == "INVALID" or not srcrev: |
| 1158 | return parmrev |
| 1159 | if srcrev != parmrev: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1160 | raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please specify one valid value" % (srcrev, parmrev)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1161 | return parmrev |
| 1162 | |
| 1163 | if srcrev == "INVALID" or not srcrev: |
| 1164 | raise FetchError("Please set a valid SRCREV for url %s (possible key names are %s, or use a ;rev=X URL parameter)" % (str(attempts), ud.url), ud.url) |
| 1165 | if srcrev == "AUTOINC": |
| 1166 | srcrev = ud.method.latest_revision(ud, d, name) |
| 1167 | |
| 1168 | return srcrev |
| 1169 | |
| 1170 | def get_checksum_file_list(d): |
| 1171 | """ Get a list of files checksum in SRC_URI |
| 1172 | |
| 1173 | Returns the resolved local paths of all local file entries in |
| 1174 | SRC_URI as a space-separated string |
| 1175 | """ |
| 1176 | fetch = Fetch([], d, cache = False, localonly = True) |
| 1177 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1178 | dl_dir = d.getVar('DL_DIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1179 | filelist = [] |
| 1180 | for u in fetch.urls: |
| 1181 | ud = fetch.ud[u] |
| 1182 | |
| 1183 | if ud and isinstance(ud.method, local.Local): |
| 1184 | paths = ud.method.localpaths(ud, d) |
| 1185 | for f in paths: |
| 1186 | pth = ud.decodedurl |
| 1187 | if '*' in pth: |
| 1188 | f = os.path.join(os.path.abspath(f), pth) |
| 1189 | if f.startswith(dl_dir): |
| 1190 | # The local fetcher's behaviour is to return a path under DL_DIR if it couldn't find the file anywhere else |
| 1191 | if os.path.exists(f): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1192 | bb.warn("Getting checksum for %s SRC_URI entry %s: file not found except in DL_DIR" % (d.getVar('PN'), os.path.basename(f))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1193 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1194 | bb.warn("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), os.path.basename(f))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1195 | filelist.append(f + ":" + str(os.path.exists(f))) |
| 1196 | |
| 1197 | return " ".join(filelist) |
| 1198 | |
| 1199 | def get_file_checksums(filelist, pn): |
| 1200 | """Get a list of the checksums for a list of local files |
| 1201 | |
| 1202 | Returns the checksums for a list of local files, caching the results as |
| 1203 | it proceeds |
| 1204 | |
| 1205 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1206 | return _checksum_cache.get_checksums(filelist, pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1207 | |
| 1208 | |
| 1209 | class FetchData(object): |
| 1210 | """ |
| 1211 | A class which represents the fetcher state for a given URI. |
| 1212 | """ |
| 1213 | def __init__(self, url, d, localonly = False): |
| 1214 | # localpath is the location of a downloaded result. If not set, the file is local. |
| 1215 | self.donestamp = None |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1216 | self.needdonestamp = True |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1217 | self.localfile = "" |
| 1218 | self.localpath = None |
| 1219 | self.lockfile = None |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1220 | self.mirrortarballs = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1221 | self.basename = None |
| 1222 | self.basepath = None |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1223 | (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(d.expand(url)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1224 | self.date = self.getSRCDate(d) |
| 1225 | self.url = url |
| 1226 | if not self.user and "user" in self.parm: |
| 1227 | self.user = self.parm["user"] |
| 1228 | if not self.pswd and "pswd" in self.parm: |
| 1229 | self.pswd = self.parm["pswd"] |
| 1230 | self.setup = False |
| 1231 | |
| 1232 | if "name" in self.parm: |
| 1233 | self.md5_name = "%s.md5sum" % self.parm["name"] |
| 1234 | self.sha256_name = "%s.sha256sum" % self.parm["name"] |
| 1235 | else: |
| 1236 | self.md5_name = "md5sum" |
| 1237 | self.sha256_name = "sha256sum" |
| 1238 | if self.md5_name in self.parm: |
| 1239 | self.md5_expected = self.parm[self.md5_name] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1240 | elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3"]: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1241 | self.md5_expected = None |
| 1242 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1243 | self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1244 | if self.sha256_name in self.parm: |
| 1245 | self.sha256_expected = self.parm[self.sha256_name] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1246 | elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3"]: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1247 | self.sha256_expected = None |
| 1248 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1249 | self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1250 | self.ignore_checksums = False |
| 1251 | |
| 1252 | self.names = self.parm.get("name",'default').split(',') |
| 1253 | |
| 1254 | self.method = None |
| 1255 | for m in methods: |
| 1256 | if m.supports(self, d): |
| 1257 | self.method = m |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1258 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1259 | |
| 1260 | if not self.method: |
| 1261 | raise NoMethodError(url) |
| 1262 | |
| 1263 | if localonly and not isinstance(self.method, local.Local): |
| 1264 | raise NonLocalMethod() |
| 1265 | |
| 1266 | if self.parm.get("proto", None) and "protocol" not in self.parm: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1267 | logger.warning('Consider updating %s recipe to use "protocol" not "proto" in SRC_URI.', d.getVar('PN')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1268 | self.parm["protocol"] = self.parm.get("proto", None) |
| 1269 | |
| 1270 | if hasattr(self.method, "urldata_init"): |
| 1271 | self.method.urldata_init(self, d) |
| 1272 | |
| 1273 | if "localpath" in self.parm: |
| 1274 | # if user sets localpath for file, use it instead. |
| 1275 | self.localpath = self.parm["localpath"] |
| 1276 | self.basename = os.path.basename(self.localpath) |
| 1277 | elif self.localfile: |
| 1278 | self.localpath = self.method.localpath(self, d) |
| 1279 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1280 | dldir = d.getVar("DL_DIR") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1281 | |
| 1282 | if not self.needdonestamp: |
| 1283 | return |
| 1284 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1285 | # Note: .done and .lock files should always be in DL_DIR whereas localpath may not be. |
| 1286 | if self.localpath and self.localpath.startswith(dldir): |
| 1287 | basepath = self.localpath |
| 1288 | elif self.localpath: |
| 1289 | basepath = dldir + os.sep + os.path.basename(self.localpath) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1290 | elif self.basepath or self.basename: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1291 | basepath = dldir + os.sep + (self.basepath or self.basename) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1292 | else: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1293 | bb.fatal("Can't determine lock path for url %s" % url) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1294 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1295 | self.donestamp = basepath + '.done' |
| 1296 | self.lockfile = basepath + '.lock' |
| 1297 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1298 | def setup_revisions(self, d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1299 | self.revisions = {} |
| 1300 | for name in self.names: |
| 1301 | self.revisions[name] = srcrev_internal_helper(self, d, name) |
| 1302 | |
| 1303 | # add compatibility code for non name specified case |
| 1304 | if len(self.names) == 1: |
| 1305 | self.revision = self.revisions[self.names[0]] |
| 1306 | |
| 1307 | def setup_localpath(self, d): |
| 1308 | if not self.localpath: |
| 1309 | self.localpath = self.method.localpath(self, d) |
| 1310 | |
| 1311 | def getSRCDate(self, d): |
| 1312 | """ |
| 1313 | Return the SRC Date for the component |
| 1314 | |
| 1315 | d the bb.data module |
| 1316 | """ |
| 1317 | if "srcdate" in self.parm: |
| 1318 | return self.parm['srcdate'] |
| 1319 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1320 | pn = d.getVar("PN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1321 | |
| 1322 | if pn: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1323 | return d.getVar("SRCDATE_%s" % pn) or d.getVar("SRCDATE") or d.getVar("DATE") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1324 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1325 | return d.getVar("SRCDATE") or d.getVar("DATE") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1326 | |
| 1327 | class FetchMethod(object): |
| 1328 | """Base class for 'fetch'ing data""" |
| 1329 | |
| 1330 | def __init__(self, urls=None): |
| 1331 | self.urls = [] |
| 1332 | |
| 1333 | def supports(self, urldata, d): |
| 1334 | """ |
| 1335 | Check to see if this fetch class supports a given url. |
| 1336 | """ |
| 1337 | return 0 |
| 1338 | |
| 1339 | def localpath(self, urldata, d): |
| 1340 | """ |
| 1341 | Return the local filename of a given url assuming a successful fetch. |
| 1342 | Can also setup variables in urldata for use in go (saving code duplication |
| 1343 | and duplicate code execution) |
| 1344 | """ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1345 | return os.path.join(d.getVar("DL_DIR"), urldata.localfile) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1346 | |
| 1347 | def supports_checksum(self, urldata): |
| 1348 | """ |
| 1349 | Is localpath something that can be represented by a checksum? |
| 1350 | """ |
| 1351 | |
| 1352 | # We cannot compute checksums for directories |
| 1353 | if os.path.isdir(urldata.localpath) == True: |
| 1354 | return False |
| 1355 | if urldata.localpath.find("*") != -1: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1356 | return False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1357 | |
| 1358 | return True |
| 1359 | |
| 1360 | def recommends_checksum(self, urldata): |
| 1361 | """ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1362 | Is the backend on where checksumming is recommended (should warnings |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1363 | be displayed if there is no checksum)? |
| 1364 | """ |
| 1365 | return False |
| 1366 | |
| 1367 | def _strip_leading_slashes(self, relpath): |
| 1368 | """ |
| 1369 | Remove leading slash as os.path.join can't cope |
| 1370 | """ |
| 1371 | while os.path.isabs(relpath): |
| 1372 | relpath = relpath[1:] |
| 1373 | return relpath |
| 1374 | |
| 1375 | def setUrls(self, urls): |
| 1376 | self.__urls = urls |
| 1377 | |
| 1378 | def getUrls(self): |
| 1379 | return self.__urls |
| 1380 | |
| 1381 | urls = property(getUrls, setUrls, None, "Urls property") |
| 1382 | |
| 1383 | def need_update(self, ud, d): |
| 1384 | """ |
| 1385 | Force a fetch, even if localpath exists? |
| 1386 | """ |
| 1387 | if os.path.exists(ud.localpath): |
| 1388 | return False |
| 1389 | return True |
| 1390 | |
| 1391 | def supports_srcrev(self): |
| 1392 | """ |
| 1393 | The fetcher supports auto source revisions (SRCREV) |
| 1394 | """ |
| 1395 | return False |
| 1396 | |
| 1397 | def download(self, urldata, d): |
| 1398 | """ |
| 1399 | Fetch urls |
| 1400 | Assumes localpath was called first |
| 1401 | """ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1402 | raise NoMethodError(urldata.url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1403 | |
| 1404 | def unpack(self, urldata, rootdir, data): |
| 1405 | iterate = False |
| 1406 | file = urldata.localpath |
| 1407 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1408 | # Localpath can't deal with 'dir/*' entries, so it converts them to '.', |
| 1409 | # but it must be corrected back for local files copying |
| 1410 | if urldata.basename == '*' and file.endswith('/.'): |
| 1411 | file = '%s/%s' % (file.rstrip('/.'), urldata.path) |
| 1412 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1413 | try: |
| 1414 | unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True) |
| 1415 | except ValueError as exc: |
| 1416 | bb.fatal("Invalid value for 'unpack' parameter for %s: %s" % |
| 1417 | (file, urldata.parm.get('unpack'))) |
| 1418 | |
| 1419 | base, ext = os.path.splitext(file) |
| 1420 | if ext in ['.gz', '.bz2', '.Z', '.xz', '.lz']: |
| 1421 | efile = os.path.join(rootdir, os.path.basename(base)) |
| 1422 | else: |
| 1423 | efile = file |
| 1424 | cmd = None |
| 1425 | |
| 1426 | if unpack: |
| 1427 | if file.endswith('.tar'): |
| 1428 | cmd = 'tar x --no-same-owner -f %s' % file |
| 1429 | elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): |
| 1430 | cmd = 'tar xz --no-same-owner -f %s' % file |
| 1431 | elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'): |
| 1432 | cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file |
| 1433 | elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'): |
| 1434 | cmd = 'gzip -dc %s > %s' % (file, efile) |
| 1435 | elif file.endswith('.bz2'): |
| 1436 | cmd = 'bzip2 -dc %s > %s' % (file, efile) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1437 | elif file.endswith('.txz') or file.endswith('.tar.xz'): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1438 | cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file |
| 1439 | elif file.endswith('.xz'): |
| 1440 | cmd = 'xz -dc %s > %s' % (file, efile) |
| 1441 | elif file.endswith('.tar.lz'): |
| 1442 | cmd = 'lzip -dc %s | tar x --no-same-owner -f -' % file |
| 1443 | elif file.endswith('.lz'): |
| 1444 | cmd = 'lzip -dc %s > %s' % (file, efile) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1445 | elif file.endswith('.tar.7z'): |
| 1446 | cmd = '7z x -so %s | tar x --no-same-owner -f -' % file |
| 1447 | elif file.endswith('.7z'): |
| 1448 | cmd = '7za x -y %s 1>/dev/null' % file |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1449 | elif file.endswith('.zip') or file.endswith('.jar'): |
| 1450 | try: |
| 1451 | dos = bb.utils.to_boolean(urldata.parm.get('dos'), False) |
| 1452 | except ValueError as exc: |
| 1453 | bb.fatal("Invalid value for 'dos' parameter for %s: %s" % |
| 1454 | (file, urldata.parm.get('dos'))) |
| 1455 | cmd = 'unzip -q -o' |
| 1456 | if dos: |
| 1457 | cmd = '%s -a' % cmd |
| 1458 | cmd = "%s '%s'" % (cmd, file) |
| 1459 | elif file.endswith('.rpm') or file.endswith('.srpm'): |
| 1460 | if 'extract' in urldata.parm: |
| 1461 | unpack_file = urldata.parm.get('extract') |
| 1462 | cmd = 'rpm2cpio.sh %s | cpio -id %s' % (file, unpack_file) |
| 1463 | iterate = True |
| 1464 | iterate_file = unpack_file |
| 1465 | else: |
| 1466 | cmd = 'rpm2cpio.sh %s | cpio -id' % (file) |
| 1467 | elif file.endswith('.deb') or file.endswith('.ipk'): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 1468 | output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1469 | datafile = None |
| 1470 | if output: |
| 1471 | for line in output.decode().splitlines(): |
| 1472 | if line.startswith('data.tar.'): |
| 1473 | datafile = line |
| 1474 | break |
| 1475 | else: |
| 1476 | raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) |
| 1477 | else: |
| 1478 | raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) |
| 1479 | cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1480 | |
| 1481 | # If 'subdir' param exists, create a dir and use it as destination for unpack cmd |
| 1482 | if 'subdir' in urldata.parm: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1483 | subdir = urldata.parm.get('subdir') |
| 1484 | if os.path.isabs(subdir): |
| 1485 | if not os.path.realpath(subdir).startswith(os.path.realpath(rootdir)): |
| 1486 | raise UnpackError("subdir argument isn't a subdirectory of unpack root %s" % rootdir, urldata.url) |
| 1487 | unpackdir = subdir |
| 1488 | else: |
| 1489 | unpackdir = os.path.join(rootdir, subdir) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1490 | bb.utils.mkdirhier(unpackdir) |
| 1491 | else: |
| 1492 | unpackdir = rootdir |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1493 | |
| 1494 | if not unpack or not cmd: |
| 1495 | # If file == dest, then avoid any copies, as we already put the file into dest! |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1496 | dest = os.path.join(unpackdir, os.path.basename(file)) |
| 1497 | if file != dest and not (os.path.exists(dest) and os.path.samefile(file, dest)): |
| 1498 | destdir = '.' |
| 1499 | # For file:// entries all intermediate dirs in path must be created at destination |
| 1500 | if urldata.type == "file": |
| 1501 | # Trailing '/' does a copying to wrong place |
| 1502 | urlpath = urldata.path.rstrip('/') |
| 1503 | # Want files places relative to cwd so no leading '/' |
| 1504 | urlpath = urlpath.lstrip('/') |
| 1505 | if urlpath.find("/") != -1: |
| 1506 | destdir = urlpath.rsplit("/", 1)[0] + '/' |
| 1507 | bb.utils.mkdirhier("%s/%s" % (unpackdir, destdir)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1508 | cmd = 'cp -fpPRH %s %s' % (file, destdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1509 | |
| 1510 | if not cmd: |
| 1511 | return |
| 1512 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1513 | path = data.getVar('PATH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1514 | if path: |
| 1515 | cmd = "PATH=\"%s\" %s" % (path, cmd) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1516 | bb.note("Unpacking %s to %s/" % (file, unpackdir)) |
| 1517 | ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=unpackdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1518 | |
| 1519 | if ret != 0: |
| 1520 | raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url) |
| 1521 | |
| 1522 | if iterate is True: |
| 1523 | iterate_urldata = urldata |
| 1524 | iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file) |
| 1525 | self.unpack(urldata, rootdir, data) |
| 1526 | |
| 1527 | return |
| 1528 | |
| 1529 | def clean(self, urldata, d): |
| 1530 | """ |
| 1531 | Clean any existing full or partial download |
| 1532 | """ |
| 1533 | bb.utils.remove(urldata.localpath) |
| 1534 | |
| 1535 | def try_premirror(self, urldata, d): |
| 1536 | """ |
| 1537 | Should premirrors be used? |
| 1538 | """ |
| 1539 | return True |
| 1540 | |
| 1541 | def checkstatus(self, fetch, urldata, d): |
| 1542 | """ |
| 1543 | Check the status of a URL |
| 1544 | Assumes localpath was called first |
| 1545 | """ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1546 | logger.info("URL %s could not be checked for status since no method exists.", urldata.url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1547 | return True |
| 1548 | |
| 1549 | def latest_revision(self, ud, d, name): |
| 1550 | """ |
| 1551 | Look in the cache for the latest revision, if not present ask the SCM. |
| 1552 | """ |
| 1553 | if not hasattr(self, "_latest_revision"): |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1554 | raise ParameterError("The fetcher for this URL does not support _latest_revision", ud.url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1555 | |
| 1556 | revs = bb.persist_data.persist('BB_URI_HEADREVS', d) |
| 1557 | key = self.generate_revision_key(ud, d, name) |
| 1558 | try: |
| 1559 | return revs[key] |
| 1560 | except KeyError: |
| 1561 | revs[key] = rev = self._latest_revision(ud, d, name) |
| 1562 | return rev |
| 1563 | |
| 1564 | def sortable_revision(self, ud, d, name): |
| 1565 | latest_rev = self._build_revision(ud, d, name) |
| 1566 | return True, str(latest_rev) |
| 1567 | |
| 1568 | def generate_revision_key(self, ud, d, name): |
| 1569 | key = self._revision_key(ud, d, name) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1570 | return "%s-%s" % (key, d.getVar("PN") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1571 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1572 | def latest_versionstring(self, ud, d): |
| 1573 | """ |
| 1574 | Compute the latest release name like "x.y.x" in "x.y.x+gitHASH" |
| 1575 | by searching through the tags output of ls-remote, comparing |
| 1576 | versions and returning the highest match as a (version, revision) pair. |
| 1577 | """ |
| 1578 | return ('', '') |
| 1579 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1580 | class Fetch(object): |
| 1581 | def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None): |
| 1582 | if localonly and cache: |
| 1583 | raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time") |
| 1584 | |
| 1585 | if len(urls) == 0: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1586 | urls = d.getVar("SRC_URI").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1587 | self.urls = urls |
| 1588 | self.d = d |
| 1589 | self.ud = {} |
| 1590 | self.connection_cache = connection_cache |
| 1591 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1592 | fn = d.getVar('FILE') |
| 1593 | mc = d.getVar('__BBMULTICONFIG') or "" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1594 | if cache and fn and mc + fn in urldata_cache: |
| 1595 | self.ud = urldata_cache[mc + fn] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1596 | |
| 1597 | for url in urls: |
| 1598 | if url not in self.ud: |
| 1599 | try: |
| 1600 | self.ud[url] = FetchData(url, d, localonly) |
| 1601 | except NonLocalMethod: |
| 1602 | if localonly: |
| 1603 | self.ud[url] = None |
| 1604 | pass |
| 1605 | |
| 1606 | if fn and cache: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1607 | urldata_cache[mc + fn] = self.ud |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1608 | |
| 1609 | def localpath(self, url): |
| 1610 | if url not in self.urls: |
| 1611 | self.ud[url] = FetchData(url, self.d) |
| 1612 | |
| 1613 | self.ud[url].setup_localpath(self.d) |
| 1614 | return self.d.expand(self.ud[url].localpath) |
| 1615 | |
| 1616 | def localpaths(self): |
| 1617 | """ |
| 1618 | Return a list of the local filenames, assuming successful fetch |
| 1619 | """ |
| 1620 | local = [] |
| 1621 | |
| 1622 | for u in self.urls: |
| 1623 | ud = self.ud[u] |
| 1624 | ud.setup_localpath(self.d) |
| 1625 | local.append(ud.localpath) |
| 1626 | |
| 1627 | return local |
| 1628 | |
| 1629 | def download(self, urls=None): |
| 1630 | """ |
| 1631 | Fetch all urls |
| 1632 | """ |
| 1633 | if not urls: |
| 1634 | urls = self.urls |
| 1635 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1636 | network = self.d.getVar("BB_NO_NETWORK") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1637 | premirroronly = bb.utils.to_boolean(self.d.getVar("BB_FETCH_PREMIRRORONLY")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1638 | |
| 1639 | for u in urls: |
| 1640 | ud = self.ud[u] |
| 1641 | ud.setup_localpath(self.d) |
| 1642 | m = ud.method |
| 1643 | localpath = "" |
| 1644 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1645 | if ud.lockfile: |
| 1646 | lf = bb.utils.lockfile(ud.lockfile) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1647 | |
| 1648 | try: |
| 1649 | self.d.setVar("BB_NO_NETWORK", network) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1650 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1651 | if verify_donestamp(ud, self.d) and not m.need_update(ud, self.d): |
| 1652 | localpath = ud.localpath |
| 1653 | elif m.try_premirror(ud, self.d): |
| 1654 | logger.debug(1, "Trying PREMIRRORS") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1655 | mirrors = mirror_from_string(self.d.getVar('PREMIRRORS')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1656 | localpath = try_mirrors(self, self.d, ud, mirrors, False) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1657 | if localpath: |
| 1658 | try: |
| 1659 | # early checksum verification so that if the checksum of the premirror |
| 1660 | # contents mismatch the fetcher can still try upstream and mirrors |
| 1661 | update_stamp(ud, self.d) |
| 1662 | except ChecksumError as e: |
| 1663 | logger.warning("Checksum failure encountered with premirror download of %s - will attempt other sources." % u) |
| 1664 | logger.debug(1, str(e)) |
| 1665 | localpath = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1666 | |
| 1667 | if premirroronly: |
| 1668 | self.d.setVar("BB_NO_NETWORK", "1") |
| 1669 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1670 | firsterr = None |
| 1671 | verified_stamp = verify_donestamp(ud, self.d) |
| 1672 | if not localpath and (not verified_stamp or m.need_update(ud, self.d)): |
| 1673 | try: |
| 1674 | if not trusted_network(self.d, ud.url): |
| 1675 | raise UntrustedUrl(ud.url) |
| 1676 | logger.debug(1, "Trying Upstream") |
| 1677 | m.download(ud, self.d) |
| 1678 | if hasattr(m, "build_mirror_data"): |
| 1679 | m.build_mirror_data(ud, self.d) |
| 1680 | localpath = ud.localpath |
| 1681 | # early checksum verify, so that if checksum mismatched, |
| 1682 | # fetcher still have chance to fetch from mirror |
| 1683 | update_stamp(ud, self.d) |
| 1684 | |
| 1685 | except bb.fetch2.NetworkAccess: |
| 1686 | raise |
| 1687 | |
| 1688 | except BBFetchException as e: |
| 1689 | if isinstance(e, ChecksumError): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1690 | logger.warning("Checksum failure encountered with download of %s - will attempt other sources if available" % u) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1691 | logger.debug(1, str(e)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1692 | if os.path.exists(ud.localpath): |
| 1693 | rename_bad_checksum(ud, e.checksum) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1694 | elif isinstance(e, NoChecksumError): |
| 1695 | raise |
| 1696 | else: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1697 | logger.warning('Failed to fetch URL %s, attempting MIRRORS if available' % u) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1698 | logger.debug(1, str(e)) |
| 1699 | firsterr = e |
| 1700 | # Remove any incomplete fetch |
| 1701 | if not verified_stamp: |
| 1702 | m.clean(ud, self.d) |
| 1703 | logger.debug(1, "Trying MIRRORS") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1704 | mirrors = mirror_from_string(self.d.getVar('MIRRORS')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1705 | localpath = try_mirrors(self, self.d, ud, mirrors) |
| 1706 | |
| 1707 | if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1): |
| 1708 | if firsterr: |
| 1709 | logger.error(str(firsterr)) |
| 1710 | raise FetchError("Unable to fetch URL from any source.", u) |
| 1711 | |
| 1712 | update_stamp(ud, self.d) |
| 1713 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1714 | except IOError as e: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1715 | if e.errno in [errno.ESTALE]: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1716 | logger.error("Stale Error Observed %s." % u) |
| 1717 | raise ChecksumError("Stale Error Detected") |
| 1718 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1719 | except BBFetchException as e: |
| 1720 | if isinstance(e, ChecksumError): |
| 1721 | logger.error("Checksum failure fetching %s" % u) |
| 1722 | raise |
| 1723 | |
| 1724 | finally: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1725 | if ud.lockfile: |
| 1726 | bb.utils.unlockfile(lf) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1727 | |
| 1728 | def checkstatus(self, urls=None): |
| 1729 | """ |
| 1730 | Check all urls exist upstream |
| 1731 | """ |
| 1732 | |
| 1733 | if not urls: |
| 1734 | urls = self.urls |
| 1735 | |
| 1736 | for u in urls: |
| 1737 | ud = self.ud[u] |
| 1738 | ud.setup_localpath(self.d) |
| 1739 | m = ud.method |
| 1740 | logger.debug(1, "Testing URL %s", u) |
| 1741 | # First try checking uri, u, from PREMIRRORS |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1742 | mirrors = mirror_from_string(self.d.getVar('PREMIRRORS')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1743 | ret = try_mirrors(self, self.d, ud, mirrors, True) |
| 1744 | if not ret: |
| 1745 | # Next try checking from the original uri, u |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1746 | ret = m.checkstatus(self, ud, self.d) |
| 1747 | if not ret: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1748 | # Finally, try checking uri, u, from MIRRORS |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1749 | mirrors = mirror_from_string(self.d.getVar('MIRRORS')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1750 | ret = try_mirrors(self, self.d, ud, mirrors, True) |
| 1751 | |
| 1752 | if not ret: |
| 1753 | raise FetchError("URL %s doesn't work" % u, u) |
| 1754 | |
| 1755 | def unpack(self, root, urls=None): |
| 1756 | """ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1757 | Unpack urls to root |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1758 | """ |
| 1759 | |
| 1760 | if not urls: |
| 1761 | urls = self.urls |
| 1762 | |
| 1763 | for u in urls: |
| 1764 | ud = self.ud[u] |
| 1765 | ud.setup_localpath(self.d) |
| 1766 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1767 | if ud.lockfile: |
| 1768 | lf = bb.utils.lockfile(ud.lockfile) |
| 1769 | |
| 1770 | ud.method.unpack(ud, root, self.d) |
| 1771 | |
| 1772 | if ud.lockfile: |
| 1773 | bb.utils.unlockfile(lf) |
| 1774 | |
| 1775 | def clean(self, urls=None): |
| 1776 | """ |
| 1777 | Clean files that the fetcher gets or places |
| 1778 | """ |
| 1779 | |
| 1780 | if not urls: |
| 1781 | urls = self.urls |
| 1782 | |
| 1783 | for url in urls: |
| 1784 | if url not in self.ud: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1785 | self.ud[url] = FetchData(url, self.d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1786 | ud = self.ud[url] |
| 1787 | ud.setup_localpath(self.d) |
| 1788 | |
| 1789 | if not ud.localfile and ud.localpath is None: |
| 1790 | continue |
| 1791 | |
| 1792 | if ud.lockfile: |
| 1793 | lf = bb.utils.lockfile(ud.lockfile) |
| 1794 | |
| 1795 | ud.method.clean(ud, self.d) |
| 1796 | if ud.donestamp: |
| 1797 | bb.utils.remove(ud.donestamp) |
| 1798 | |
| 1799 | if ud.lockfile: |
| 1800 | bb.utils.unlockfile(lf) |
| 1801 | |
| 1802 | class FetchConnectionCache(object): |
| 1803 | """ |
| 1804 | A class which represents an container for socket connections. |
| 1805 | """ |
| 1806 | def __init__(self): |
| 1807 | self.cache = {} |
| 1808 | |
| 1809 | def get_connection_name(self, host, port): |
| 1810 | return host + ':' + str(port) |
| 1811 | |
| 1812 | def add_connection(self, host, port, connection): |
| 1813 | cn = self.get_connection_name(host, port) |
| 1814 | |
| 1815 | if cn not in self.cache: |
| 1816 | self.cache[cn] = connection |
| 1817 | |
| 1818 | def get_connection(self, host, port): |
| 1819 | connection = None |
| 1820 | |
| 1821 | cn = self.get_connection_name(host, port) |
| 1822 | if cn in self.cache: |
| 1823 | connection = self.cache[cn] |
| 1824 | |
| 1825 | return connection |
| 1826 | |
| 1827 | def remove_connection(self, host, port): |
| 1828 | cn = self.get_connection_name(host, port) |
| 1829 | if cn in self.cache: |
| 1830 | self.cache[cn].close() |
| 1831 | del self.cache[cn] |
| 1832 | |
| 1833 | def close_connections(self): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1834 | for cn in list(self.cache.keys()): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1835 | self.cache[cn].close() |
| 1836 | del self.cache[cn] |
| 1837 | |
| 1838 | from . import cvs |
| 1839 | from . import git |
| 1840 | from . import gitsm |
| 1841 | from . import gitannex |
| 1842 | from . import local |
| 1843 | from . import svn |
| 1844 | from . import wget |
| 1845 | from . import ssh |
| 1846 | from . import sftp |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1847 | from . import s3 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1848 | from . import perforce |
| 1849 | from . import bzr |
| 1850 | from . import hg |
| 1851 | from . import osc |
| 1852 | from . import repo |
| 1853 | from . import clearcase |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1854 | from . import npm |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1855 | |
| 1856 | methods.append(local.Local()) |
| 1857 | methods.append(wget.Wget()) |
| 1858 | methods.append(svn.Svn()) |
| 1859 | methods.append(git.Git()) |
| 1860 | methods.append(gitsm.GitSM()) |
| 1861 | methods.append(gitannex.GitANNEX()) |
| 1862 | methods.append(cvs.Cvs()) |
| 1863 | methods.append(ssh.SSH()) |
| 1864 | methods.append(sftp.SFTP()) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1865 | methods.append(s3.S3()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1866 | methods.append(perforce.Perforce()) |
| 1867 | methods.append(bzr.Bzr()) |
| 1868 | methods.append(hg.Hg()) |
| 1869 | methods.append(osc.Osc()) |
| 1870 | methods.append(repo.Repo()) |
| 1871 | methods.append(clearcase.ClearCase()) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1872 | methods.append(npm.Npm()) |