__init__.py 66 KB

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