__init__.py 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873
  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. # Ensure that a _PYTHON_SYSCONFIGDATA_NAME value set by a recipe
  715. # (for example via python3native.bbclass since warrior) is not set for
  716. # host Python (otherwise tools like git-make-shallow will fail)
  717. cmd = 'unset _PYTHON_SYSCONFIGDATA_NAME; ' + cmd
  718. # Disable pseudo as it may affect ssh, potentially causing it to hang.
  719. cmd = 'export PSEUDO_DISABLED=1; ' + cmd
  720. if workdir:
  721. logger.debug(1, "Running '%s' in %s" % (cmd, workdir))
  722. else:
  723. logger.debug(1, "Running %s", cmd)
  724. success = False
  725. error_message = ""
  726. try:
  727. (output, errors) = bb.process.run(cmd, log=log, shell=True, stderr=subprocess.PIPE, cwd=workdir)
  728. success = True
  729. except bb.process.NotFoundError as e:
  730. error_message = "Fetch command %s" % (e.command)
  731. except bb.process.ExecutionError as e:
  732. if e.stdout:
  733. output = "output:\n%s\n%s" % (e.stdout, e.stderr)
  734. elif e.stderr:
  735. output = "output:\n%s" % e.stderr
  736. else:
  737. output = "no output"
  738. error_message = "Fetch command %s failed with exit code %s, %s" % (e.command, e.exitcode, output)
  739. except bb.process.CmdError as e:
  740. error_message = "Fetch command %s could not be run:\n%s" % (e.command, e.msg)
  741. if not success:
  742. for f in cleanup:
  743. try:
  744. bb.utils.remove(f, True)
  745. except OSError:
  746. pass
  747. raise FetchError(error_message)
  748. return output
  749. def check_network_access(d, info, url):
  750. """
  751. log remote network access, and error if BB_NO_NETWORK is set or the given
  752. URI is untrusted
  753. """
  754. if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")):
  755. raise NetworkAccess(url, info)
  756. elif not trusted_network(d, url):
  757. raise UntrustedUrl(url, info)
  758. else:
  759. logger.debug(1, "Fetcher accessed the network with the command %s" % info)
  760. def build_mirroruris(origud, mirrors, ld):
  761. uris = []
  762. uds = []
  763. replacements = {}
  764. replacements["TYPE"] = origud.type
  765. replacements["HOST"] = origud.host
  766. replacements["PATH"] = origud.path
  767. replacements["BASENAME"] = origud.path.split("/")[-1]
  768. replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.').replace('*', '.')
  769. def adduri(ud, uris, uds, mirrors, tarballs):
  770. for line in mirrors:
  771. try:
  772. (find, replace) = line
  773. except ValueError:
  774. continue
  775. for tarball in tarballs:
  776. newuri = uri_replace(ud, find, replace, replacements, ld, tarball)
  777. if not newuri or newuri in uris or newuri == origud.url:
  778. continue
  779. if not trusted_network(ld, newuri):
  780. logger.debug(1, "Mirror %s not in the list of trusted networks, skipping" % (newuri))
  781. continue
  782. # Create a local copy of the mirrors minus the current line
  783. # this will prevent us from recursively processing the same line
  784. # as well as indirect recursion A -> B -> C -> A
  785. localmirrors = list(mirrors)
  786. localmirrors.remove(line)
  787. try:
  788. newud = FetchData(newuri, ld)
  789. newud.setup_localpath(ld)
  790. except bb.fetch2.BBFetchException as e:
  791. logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
  792. logger.debug(1, str(e))
  793. try:
  794. # setup_localpath of file:// urls may fail, we should still see
  795. # if mirrors of the url exist
  796. adduri(newud, uris, uds, localmirrors, tarballs)
  797. except UnboundLocalError:
  798. pass
  799. continue
  800. uris.append(newuri)
  801. uds.append(newud)
  802. adduri(newud, uris, uds, localmirrors, tarballs)
  803. adduri(origud, uris, uds, mirrors, origud.mirrortarballs or [None])
  804. return uris, uds
  805. def rename_bad_checksum(ud, suffix):
  806. """
  807. Renames files to have suffix from parameter
  808. """
  809. if ud.localpath is None:
  810. return
  811. new_localpath = "%s_bad-checksum_%s" % (ud.localpath, suffix)
  812. bb.warn("Renaming %s to %s" % (ud.localpath, new_localpath))
  813. if not bb.utils.movefile(ud.localpath, new_localpath):
  814. bb.warn("Renaming %s to %s failed, grep movefile in log.do_fetch to see why" % (ud.localpath, new_localpath))
  815. def try_mirror_url(fetch, origud, ud, ld, check = False):
  816. # Return of None or a value means we're finished
  817. # False means try another url
  818. if ud.lockfile and ud.lockfile != origud.lockfile:
  819. lf = bb.utils.lockfile(ud.lockfile)
  820. try:
  821. if check:
  822. found = ud.method.checkstatus(fetch, ud, ld)
  823. if found:
  824. return found
  825. return False
  826. if not verify_donestamp(ud, ld, origud) or ud.method.need_update(ud, ld):
  827. ud.method.download(ud, ld)
  828. if hasattr(ud.method,"build_mirror_data"):
  829. ud.method.build_mirror_data(ud, ld)
  830. if not ud.localpath or not os.path.exists(ud.localpath):
  831. return False
  832. if ud.localpath == origud.localpath:
  833. return ud.localpath
  834. # We may be obtaining a mirror tarball which needs further processing by the real fetcher
  835. # If that tarball is a local file:// we need to provide a symlink to it
  836. dldir = ld.getVar("DL_DIR")
  837. if origud.mirrortarballs and os.path.basename(ud.localpath) in origud.mirrortarballs and os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
  838. # Create donestamp in old format to avoid triggering a re-download
  839. if ud.donestamp:
  840. bb.utils.mkdirhier(os.path.dirname(ud.donestamp))
  841. open(ud.donestamp, 'w').close()
  842. dest = os.path.join(dldir, os.path.basename(ud.localpath))
  843. if not os.path.exists(dest):
  844. # In case this is executing without any file locks held (as is
  845. # the case for file:// URLs), two tasks may end up here at the
  846. # same time, in which case we do not want the second task to
  847. # fail when the link has already been created by the first task.
  848. try:
  849. os.symlink(ud.localpath, dest)
  850. except FileExistsError:
  851. pass
  852. if not verify_donestamp(origud, ld) or origud.method.need_update(origud, ld):
  853. origud.method.download(origud, ld)
  854. if hasattr(origud.method, "build_mirror_data"):
  855. origud.method.build_mirror_data(origud, ld)
  856. return origud.localpath
  857. # Otherwise the result is a local file:// and we symlink to it
  858. ensure_symlink(ud.localpath, origud.localpath)
  859. update_stamp(origud, ld)
  860. return ud.localpath
  861. except bb.fetch2.NetworkAccess:
  862. raise
  863. except IOError as e:
  864. if e.errno in [errno.ESTALE]:
  865. logger.warning("Stale Error Observed %s." % ud.url)
  866. return False
  867. raise
  868. except bb.fetch2.BBFetchException as e:
  869. if isinstance(e, ChecksumError):
  870. logger.warning("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (ud.url, origud.url))
  871. logger.warning(str(e))
  872. if os.path.exists(ud.localpath):
  873. rename_bad_checksum(ud, e.checksum)
  874. elif isinstance(e, NoChecksumError):
  875. raise
  876. else:
  877. logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (ud.url, origud.url))
  878. logger.debug(1, str(e))
  879. try:
  880. ud.method.clean(ud, ld)
  881. except UnboundLocalError:
  882. pass
  883. return False
  884. finally:
  885. if ud.lockfile and ud.lockfile != origud.lockfile:
  886. bb.utils.unlockfile(lf)
  887. def ensure_symlink(target, link_name):
  888. if not os.path.exists(link_name):
  889. if os.path.islink(link_name):
  890. # Broken symbolic link
  891. os.unlink(link_name)
  892. # In case this is executing without any file locks held (as is
  893. # the case for file:// URLs), two tasks may end up here at the
  894. # same time, in which case we do not want the second task to
  895. # fail when the link has already been created by the first task.
  896. try:
  897. os.symlink(target, link_name)
  898. except FileExistsError:
  899. pass
  900. def try_mirrors(fetch, d, origud, mirrors, check = False):
  901. """
  902. Try to use a mirrored version of the sources.
  903. This method will be automatically called before the fetchers go.
  904. d Is a bb.data instance
  905. uri is the original uri we're trying to download
  906. mirrors is the list of mirrors we're going to try
  907. """
  908. ld = d.createCopy()
  909. uris, uds = build_mirroruris(origud, mirrors, ld)
  910. for index, uri in enumerate(uris):
  911. ret = try_mirror_url(fetch, origud, uds[index], ld, check)
  912. if ret:
  913. return ret
  914. return None
  915. def trusted_network(d, url):
  916. """
  917. Use a trusted url during download if networking is enabled and
  918. BB_ALLOWED_NETWORKS is set globally or for a specific recipe.
  919. Note: modifies SRC_URI & mirrors.
  920. """
  921. if bb.utils.to_boolean(d.getVar("BB_NO_NETWORK")):
  922. return True
  923. pkgname = d.expand(d.getVar('PN', False))
  924. trusted_hosts = None
  925. if pkgname:
  926. trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname, False)
  927. if not trusted_hosts:
  928. trusted_hosts = d.getVar('BB_ALLOWED_NETWORKS')
  929. # Not enabled.
  930. if not trusted_hosts:
  931. return True
  932. scheme, network, path, user, passwd, param = decodeurl(url)
  933. if not network:
  934. return True
  935. network = network.split(':')[0]
  936. network = network.lower()
  937. for host in trusted_hosts.split(" "):
  938. host = host.lower()
  939. if host.startswith("*.") and ("." + network).endswith(host[1:]):
  940. return True
  941. if host == network:
  942. return True
  943. return False
  944. def srcrev_internal_helper(ud, d, name):
  945. """
  946. Return:
  947. a) a source revision if specified
  948. b) latest revision if SRCREV="AUTOINC"
  949. c) None if not specified
  950. """
  951. srcrev = None
  952. pn = d.getVar("PN")
  953. attempts = []
  954. if name != '' and pn:
  955. attempts.append("SRCREV_%s_pn-%s" % (name, pn))
  956. if name != '':
  957. attempts.append("SRCREV_%s" % name)
  958. if pn:
  959. attempts.append("SRCREV_pn-%s" % pn)
  960. attempts.append("SRCREV")
  961. for a in attempts:
  962. srcrev = d.getVar(a)
  963. if srcrev and srcrev != "INVALID":
  964. break
  965. if 'rev' in ud.parm and 'tag' in ud.parm:
  966. raise FetchError("Please specify a ;rev= parameter or a ;tag= parameter in the url %s but not both." % (ud.url))
  967. if 'rev' in ud.parm or 'tag' in ud.parm:
  968. if 'rev' in ud.parm:
  969. parmrev = ud.parm['rev']
  970. else:
  971. parmrev = ud.parm['tag']
  972. if srcrev == "INVALID" or not srcrev:
  973. return parmrev
  974. if srcrev != parmrev:
  975. raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please specify one valid value" % (srcrev, parmrev))
  976. return parmrev
  977. if srcrev == "INVALID" or not srcrev:
  978. 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)
  979. if srcrev == "AUTOINC":
  980. srcrev = ud.method.latest_revision(ud, d, name)
  981. return srcrev
  982. def get_checksum_file_list(d):
  983. """ Get a list of files checksum in SRC_URI
  984. Returns the resolved local paths of all local file entries in
  985. SRC_URI as a space-separated string
  986. """
  987. fetch = Fetch([], d, cache = False, localonly = True)
  988. dl_dir = d.getVar('DL_DIR')
  989. filelist = []
  990. for u in fetch.urls:
  991. ud = fetch.ud[u]
  992. if ud and isinstance(ud.method, local.Local):
  993. paths = ud.method.localpaths(ud, d)
  994. for f in paths:
  995. pth = ud.decodedurl
  996. if '*' in pth:
  997. f = os.path.join(os.path.abspath(f), pth)
  998. if f.startswith(dl_dir):
  999. # The local fetcher's behaviour is to return a path under DL_DIR if it couldn't find the file anywhere else
  1000. if os.path.exists(f):
  1001. bb.warn("Getting checksum for %s SRC_URI entry %s: file not found except in DL_DIR" % (d.getVar('PN'), os.path.basename(f)))
  1002. else:
  1003. bb.warn("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), os.path.basename(f)))
  1004. filelist.append(f + ":" + str(os.path.exists(f)))
  1005. return " ".join(filelist)
  1006. def get_file_checksums(filelist, pn, localdirsexclude):
  1007. """Get a list of the checksums for a list of local files
  1008. Returns the checksums for a list of local files, caching the results as
  1009. it proceeds
  1010. """
  1011. return _checksum_cache.get_checksums(filelist, pn, localdirsexclude)
  1012. class FetchData(object):
  1013. """
  1014. A class which represents the fetcher state for a given URI.
  1015. """
  1016. def __init__(self, url, d, localonly = False):
  1017. # localpath is the location of a downloaded result. If not set, the file is local.
  1018. self.donestamp = None
  1019. self.needdonestamp = True
  1020. self.localfile = ""
  1021. self.localpath = None
  1022. self.lockfile = None
  1023. self.mirrortarballs = []
  1024. self.basename = None
  1025. self.basepath = None
  1026. (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(d.expand(url))
  1027. self.date = self.getSRCDate(d)
  1028. self.url = url
  1029. if not self.user and "user" in self.parm:
  1030. self.user = self.parm["user"]
  1031. if not self.pswd and "pswd" in self.parm:
  1032. self.pswd = self.parm["pswd"]
  1033. self.setup = False
  1034. if "name" in self.parm:
  1035. self.md5_name = "%s.md5sum" % self.parm["name"]
  1036. self.sha256_name = "%s.sha256sum" % self.parm["name"]
  1037. else:
  1038. self.md5_name = "md5sum"
  1039. self.sha256_name = "sha256sum"
  1040. if self.md5_name in self.parm:
  1041. self.md5_expected = self.parm[self.md5_name]
  1042. elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3"]:
  1043. self.md5_expected = None
  1044. else:
  1045. self.md5_expected = d.getVarFlag("SRC_URI", self.md5_name)
  1046. if self.sha256_name in self.parm:
  1047. self.sha256_expected = self.parm[self.sha256_name]
  1048. elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3"]:
  1049. self.sha256_expected = None
  1050. else:
  1051. self.sha256_expected = d.getVarFlag("SRC_URI", self.sha256_name)
  1052. self.ignore_checksums = False
  1053. self.names = self.parm.get("name",'default').split(',')
  1054. self.method = None
  1055. for m in methods:
  1056. if m.supports(self, d):
  1057. self.method = m
  1058. break
  1059. if not self.method:
  1060. raise NoMethodError(url)
  1061. if localonly and not isinstance(self.method, local.Local):
  1062. raise NonLocalMethod()
  1063. if self.parm.get("proto", None) and "protocol" not in self.parm:
  1064. logger.warning('Consider updating %s recipe to use "protocol" not "proto" in SRC_URI.', d.getVar('PN'))
  1065. self.parm["protocol"] = self.parm.get("proto", None)
  1066. if hasattr(self.method, "urldata_init"):
  1067. self.method.urldata_init(self, d)
  1068. if "localpath" in self.parm:
  1069. # if user sets localpath for file, use it instead.
  1070. self.localpath = self.parm["localpath"]
  1071. self.basename = os.path.basename(self.localpath)
  1072. elif self.localfile:
  1073. self.localpath = self.method.localpath(self, d)
  1074. dldir = d.getVar("DL_DIR")
  1075. if not self.needdonestamp:
  1076. return
  1077. # Note: .done and .lock files should always be in DL_DIR whereas localpath may not be.
  1078. if self.localpath and self.localpath.startswith(dldir):
  1079. basepath = self.localpath
  1080. elif self.localpath:
  1081. basepath = dldir + os.sep + os.path.basename(self.localpath)
  1082. elif self.basepath or self.basename:
  1083. basepath = dldir + os.sep + (self.basepath or self.basename)
  1084. else:
  1085. bb.fatal("Can't determine lock path for url %s" % url)
  1086. self.donestamp = basepath + '.done'
  1087. self.lockfile = basepath + '.lock'
  1088. def setup_revisions(self, d):
  1089. self.revisions = {}
  1090. for name in self.names:
  1091. self.revisions[name] = srcrev_internal_helper(self, d, name)
  1092. # add compatibility code for non name specified case
  1093. if len(self.names) == 1:
  1094. self.revision = self.revisions[self.names[0]]
  1095. def setup_localpath(self, d):
  1096. if not self.localpath:
  1097. self.localpath = self.method.localpath(self, d)
  1098. def getSRCDate(self, d):
  1099. """
  1100. Return the SRC Date for the component
  1101. d the bb.data module
  1102. """
  1103. if "srcdate" in self.parm:
  1104. return self.parm['srcdate']
  1105. pn = d.getVar("PN")
  1106. if pn:
  1107. return d.getVar("SRCDATE_%s" % pn) or d.getVar("SRCDATE") or d.getVar("DATE")
  1108. return d.getVar("SRCDATE") or d.getVar("DATE")
  1109. class FetchMethod(object):
  1110. """Base class for 'fetch'ing data"""
  1111. def __init__(self, urls=None):
  1112. self.urls = []
  1113. def supports(self, urldata, d):
  1114. """
  1115. Check to see if this fetch class supports a given url.
  1116. """
  1117. return 0
  1118. def localpath(self, urldata, d):
  1119. """
  1120. Return the local filename of a given url assuming a successful fetch.
  1121. Can also setup variables in urldata for use in go (saving code duplication
  1122. and duplicate code execution)
  1123. """
  1124. return os.path.join(d.getVar("DL_DIR"), urldata.localfile)
  1125. def supports_checksum(self, urldata):
  1126. """
  1127. Is localpath something that can be represented by a checksum?
  1128. """
  1129. # We cannot compute checksums for directories
  1130. if os.path.isdir(urldata.localpath):
  1131. return False
  1132. if urldata.localpath.find("*") != -1:
  1133. return False
  1134. return True
  1135. def recommends_checksum(self, urldata):
  1136. """
  1137. Is the backend on where checksumming is recommended (should warnings
  1138. be displayed if there is no checksum)?
  1139. """
  1140. return False
  1141. def _strip_leading_slashes(self, relpath):
  1142. """
  1143. Remove leading slash as os.path.join can't cope
  1144. """
  1145. while os.path.isabs(relpath):
  1146. relpath = relpath[1:]
  1147. return relpath
  1148. def setUrls(self, urls):
  1149. self.__urls = urls
  1150. def getUrls(self):
  1151. return self.__urls
  1152. urls = property(getUrls, setUrls, None, "Urls property")
  1153. def need_update(self, ud, d):
  1154. """
  1155. Force a fetch, even if localpath exists?
  1156. """
  1157. if os.path.exists(ud.localpath):
  1158. return False
  1159. return True
  1160. def supports_srcrev(self):
  1161. """
  1162. The fetcher supports auto source revisions (SRCREV)
  1163. """
  1164. return False
  1165. def download(self, urldata, d):
  1166. """
  1167. Fetch urls
  1168. Assumes localpath was called first
  1169. """
  1170. raise NoMethodError(urldata.url)
  1171. def unpack(self, urldata, rootdir, data):
  1172. iterate = False
  1173. file = urldata.localpath
  1174. # Localpath can't deal with 'dir/*' entries, so it converts them to '.',
  1175. # but it must be corrected back for local files copying
  1176. if urldata.basename == '*' and file.endswith('/.'):
  1177. file = '%s/%s' % (file.rstrip('/.'), urldata.path)
  1178. try:
  1179. unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True)
  1180. except ValueError as exc:
  1181. bb.fatal("Invalid value for 'unpack' parameter for %s: %s" %
  1182. (file, urldata.parm.get('unpack')))
  1183. base, ext = os.path.splitext(file)
  1184. if ext in ['.gz', '.bz2', '.Z', '.xz', '.lz']:
  1185. efile = os.path.join(rootdir, os.path.basename(base))
  1186. else:
  1187. efile = file
  1188. cmd = None
  1189. if unpack:
  1190. if file.endswith('.tar'):
  1191. cmd = 'tar x --no-same-owner -f %s' % file
  1192. elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
  1193. cmd = 'tar xz --no-same-owner -f %s' % file
  1194. elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
  1195. cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
  1196. elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
  1197. cmd = 'gzip -dc %s > %s' % (file, efile)
  1198. elif file.endswith('.bz2'):
  1199. cmd = 'bzip2 -dc %s > %s' % (file, efile)
  1200. elif file.endswith('.txz') or file.endswith('.tar.xz'):
  1201. cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
  1202. elif file.endswith('.xz'):
  1203. cmd = 'xz -dc %s > %s' % (file, efile)
  1204. elif file.endswith('.tar.lz'):
  1205. cmd = 'lzip -dc %s | tar x --no-same-owner -f -' % file
  1206. elif file.endswith('.lz'):
  1207. cmd = 'lzip -dc %s > %s' % (file, efile)
  1208. elif file.endswith('.tar.7z'):
  1209. cmd = '7z x -so %s | tar x --no-same-owner -f -' % file
  1210. elif file.endswith('.7z'):
  1211. cmd = '7za x -y %s 1>/dev/null' % file
  1212. elif file.endswith('.zip') or file.endswith('.jar'):
  1213. try:
  1214. dos = bb.utils.to_boolean(urldata.parm.get('dos'), False)
  1215. except ValueError as exc:
  1216. bb.fatal("Invalid value for 'dos' parameter for %s: %s" %
  1217. (file, urldata.parm.get('dos')))
  1218. cmd = 'unzip -q -o'
  1219. if dos:
  1220. cmd = '%s -a' % cmd
  1221. cmd = "%s '%s'" % (cmd, file)
  1222. elif file.endswith('.rpm') or file.endswith('.srpm'):
  1223. if 'extract' in urldata.parm:
  1224. unpack_file = urldata.parm.get('extract')
  1225. cmd = 'rpm2cpio.sh %s | cpio -id %s' % (file, unpack_file)
  1226. iterate = True
  1227. iterate_file = unpack_file
  1228. else:
  1229. cmd = 'rpm2cpio.sh %s | cpio -id' % (file)
  1230. elif file.endswith('.deb') or file.endswith('.ipk'):
  1231. output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup)
  1232. datafile = None
  1233. if output:
  1234. for line in output.decode().splitlines():
  1235. if line.startswith('data.tar.'):
  1236. datafile = line
  1237. break
  1238. else:
  1239. raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url)
  1240. else:
  1241. raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url)
  1242. cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile)
  1243. # If 'subdir' param exists, create a dir and use it as destination for unpack cmd
  1244. if 'subdir' in urldata.parm:
  1245. subdir = urldata.parm.get('subdir')
  1246. if os.path.isabs(subdir):
  1247. if not os.path.realpath(subdir).startswith(os.path.realpath(rootdir)):
  1248. raise UnpackError("subdir argument isn't a subdirectory of unpack root %s" % rootdir, urldata.url)
  1249. unpackdir = subdir
  1250. else:
  1251. unpackdir = os.path.join(rootdir, subdir)
  1252. bb.utils.mkdirhier(unpackdir)
  1253. else:
  1254. unpackdir = rootdir
  1255. if not unpack or not cmd:
  1256. # If file == dest, then avoid any copies, as we already put the file into dest!
  1257. dest = os.path.join(unpackdir, os.path.basename(file))
  1258. if file != dest and not (os.path.exists(dest) and os.path.samefile(file, dest)):
  1259. destdir = '.'
  1260. # For file:// entries all intermediate dirs in path must be created at destination
  1261. if urldata.type == "file":
  1262. # Trailing '/' does a copying to wrong place
  1263. urlpath = urldata.path.rstrip('/')
  1264. # Want files places relative to cwd so no leading '/'
  1265. urlpath = urlpath.lstrip('/')
  1266. if urlpath.find("/") != -1:
  1267. destdir = urlpath.rsplit("/", 1)[0] + '/'
  1268. bb.utils.mkdirhier("%s/%s" % (unpackdir, destdir))
  1269. cmd = 'cp -fpPRH %s %s' % (file, destdir)
  1270. if not cmd:
  1271. return
  1272. path = data.getVar('PATH')
  1273. if path:
  1274. cmd = "PATH=\"%s\" %s" % (path, cmd)
  1275. bb.note("Unpacking %s to %s/" % (file, unpackdir))
  1276. ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=unpackdir)
  1277. if ret != 0:
  1278. raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url)
  1279. if iterate is True:
  1280. iterate_urldata = urldata
  1281. iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file)
  1282. self.unpack(urldata, rootdir, data)
  1283. return
  1284. def clean(self, urldata, d):
  1285. """
  1286. Clean any existing full or partial download
  1287. """
  1288. bb.utils.remove(urldata.localpath)
  1289. def try_premirror(self, urldata, d):
  1290. """
  1291. Should premirrors be used?
  1292. """
  1293. return True
  1294. def checkstatus(self, fetch, urldata, d):
  1295. """
  1296. Check the status of a URL
  1297. Assumes localpath was called first
  1298. """
  1299. logger.info("URL %s could not be checked for status since no method exists.", urldata.url)
  1300. return True
  1301. def latest_revision(self, ud, d, name):
  1302. """
  1303. Look in the cache for the latest revision, if not present ask the SCM.
  1304. """
  1305. if not hasattr(self, "_latest_revision"):
  1306. raise ParameterError("The fetcher for this URL does not support _latest_revision", ud.url)
  1307. revs = bb.persist_data.persist('BB_URI_HEADREVS', d)
  1308. key = self.generate_revision_key(ud, d, name)
  1309. try:
  1310. return revs[key]
  1311. except KeyError:
  1312. revs[key] = rev = self._latest_revision(ud, d, name)
  1313. return rev
  1314. def sortable_revision(self, ud, d, name):
  1315. latest_rev = self._build_revision(ud, d, name)
  1316. return True, str(latest_rev)
  1317. def generate_revision_key(self, ud, d, name):
  1318. key = self._revision_key(ud, d, name)
  1319. return "%s-%s" % (key, d.getVar("PN") or "")
  1320. def latest_versionstring(self, ud, d):
  1321. """
  1322. Compute the latest release name like "x.y.x" in "x.y.x+gitHASH"
  1323. by searching through the tags output of ls-remote, comparing
  1324. versions and returning the highest match as a (version, revision) pair.
  1325. """
  1326. return ('', '')
  1327. class Fetch(object):
  1328. def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None):
  1329. if localonly and cache:
  1330. raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time")
  1331. if len(urls) == 0:
  1332. urls = d.getVar("SRC_URI").split()
  1333. self.urls = urls
  1334. self.d = d
  1335. self.ud = {}
  1336. self.connection_cache = connection_cache
  1337. fn = d.getVar('FILE')
  1338. mc = d.getVar('__BBMULTICONFIG') or ""
  1339. if cache and fn and mc + fn in urldata_cache:
  1340. self.ud = urldata_cache[mc + fn + str(id(d))]
  1341. for url in urls:
  1342. if url not in self.ud:
  1343. try:
  1344. self.ud[url] = FetchData(url, d, localonly)
  1345. except NonLocalMethod:
  1346. if localonly:
  1347. self.ud[url] = None
  1348. pass
  1349. if fn and cache:
  1350. urldata_cache[mc + fn + str(id(d))] = self.ud
  1351. def localpath(self, url):
  1352. if url not in self.urls:
  1353. self.ud[url] = FetchData(url, self.d)
  1354. self.ud[url].setup_localpath(self.d)
  1355. return self.d.expand(self.ud[url].localpath)
  1356. def localpaths(self):
  1357. """
  1358. Return a list of the local filenames, assuming successful fetch
  1359. """
  1360. local = []
  1361. for u in self.urls:
  1362. ud = self.ud[u]
  1363. ud.setup_localpath(self.d)
  1364. local.append(ud.localpath)
  1365. return local
  1366. def download(self, urls=None):
  1367. """
  1368. Fetch all urls
  1369. """
  1370. if not urls:
  1371. urls = self.urls
  1372. network = self.d.getVar("BB_NO_NETWORK")
  1373. premirroronly = bb.utils.to_boolean(self.d.getVar("BB_FETCH_PREMIRRORONLY"))
  1374. for u in urls:
  1375. ud = self.ud[u]
  1376. ud.setup_localpath(self.d)
  1377. m = ud.method
  1378. localpath = ""
  1379. if ud.lockfile:
  1380. lf = bb.utils.lockfile(ud.lockfile)
  1381. try:
  1382. self.d.setVar("BB_NO_NETWORK", network)
  1383. if verify_donestamp(ud, self.d) and not m.need_update(ud, self.d):
  1384. localpath = ud.localpath
  1385. elif m.try_premirror(ud, self.d):
  1386. logger.debug(1, "Trying PREMIRRORS")
  1387. mirrors = mirror_from_string(self.d.getVar('PREMIRRORS'))
  1388. localpath = try_mirrors(self, self.d, ud, mirrors, False)
  1389. if localpath:
  1390. try:
  1391. # early checksum verification so that if the checksum of the premirror
  1392. # contents mismatch the fetcher can still try upstream and mirrors
  1393. update_stamp(ud, self.d)
  1394. except ChecksumError as e:
  1395. logger.warning("Checksum failure encountered with premirror download of %s - will attempt other sources." % u)
  1396. logger.debug(1, str(e))
  1397. localpath = ""
  1398. if premirroronly:
  1399. self.d.setVar("BB_NO_NETWORK", "1")
  1400. firsterr = None
  1401. verified_stamp = verify_donestamp(ud, self.d)
  1402. if not localpath and (not verified_stamp or m.need_update(ud, self.d)):
  1403. try:
  1404. if not trusted_network(self.d, ud.url):
  1405. raise UntrustedUrl(ud.url)
  1406. logger.debug(1, "Trying Upstream")
  1407. m.download(ud, self.d)
  1408. if hasattr(m, "build_mirror_data"):
  1409. m.build_mirror_data(ud, self.d)
  1410. localpath = ud.localpath
  1411. # early checksum verify, so that if checksum mismatched,
  1412. # fetcher still have chance to fetch from mirror
  1413. update_stamp(ud, self.d)
  1414. except bb.fetch2.NetworkAccess:
  1415. raise
  1416. except BBFetchException as e:
  1417. if isinstance(e, ChecksumError):
  1418. logger.warning("Checksum failure encountered with download of %s - will attempt other sources if available" % u)
  1419. logger.debug(1, str(e))
  1420. if os.path.exists(ud.localpath):
  1421. rename_bad_checksum(ud, e.checksum)
  1422. elif isinstance(e, NoChecksumError):
  1423. raise
  1424. else:
  1425. logger.warning('Failed to fetch URL %s, attempting MIRRORS if available' % u)
  1426. logger.debug(1, str(e))
  1427. firsterr = e
  1428. # Remove any incomplete fetch
  1429. if not verified_stamp:
  1430. m.clean(ud, self.d)
  1431. logger.debug(1, "Trying MIRRORS")
  1432. mirrors = mirror_from_string(self.d.getVar('MIRRORS'))
  1433. localpath = try_mirrors(self, self.d, ud, mirrors)
  1434. if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
  1435. if firsterr:
  1436. logger.error(str(firsterr))
  1437. raise FetchError("Unable to fetch URL from any source.", u)
  1438. update_stamp(ud, self.d)
  1439. except IOError as e:
  1440. if e.errno in [errno.ESTALE]:
  1441. logger.error("Stale Error Observed %s." % u)
  1442. raise ChecksumError("Stale Error Detected")
  1443. except BBFetchException as e:
  1444. if isinstance(e, ChecksumError):
  1445. logger.error("Checksum failure fetching %s" % u)
  1446. raise
  1447. finally:
  1448. if ud.lockfile:
  1449. bb.utils.unlockfile(lf)
  1450. def checkstatus(self, urls=None):
  1451. """
  1452. Check all urls exist upstream
  1453. """
  1454. if not urls:
  1455. urls = self.urls
  1456. for u in urls:
  1457. ud = self.ud[u]
  1458. ud.setup_localpath(self.d)
  1459. m = ud.method
  1460. logger.debug(1, "Testing URL %s", u)
  1461. # First try checking uri, u, from PREMIRRORS
  1462. mirrors = mirror_from_string(self.d.getVar('PREMIRRORS'))
  1463. ret = try_mirrors(self, self.d, ud, mirrors, True)
  1464. if not ret:
  1465. # Next try checking from the original uri, u
  1466. ret = m.checkstatus(self, ud, self.d)
  1467. if not ret:
  1468. # Finally, try checking uri, u, from MIRRORS
  1469. mirrors = mirror_from_string(self.d.getVar('MIRRORS'))
  1470. ret = try_mirrors(self, self.d, ud, mirrors, True)
  1471. if not ret:
  1472. raise FetchError("URL %s doesn't work" % u, u)
  1473. def unpack(self, root, urls=None):
  1474. """
  1475. Unpack urls to root
  1476. """
  1477. if not urls:
  1478. urls = self.urls
  1479. for u in urls:
  1480. ud = self.ud[u]
  1481. ud.setup_localpath(self.d)
  1482. if ud.lockfile:
  1483. lf = bb.utils.lockfile(ud.lockfile)
  1484. ud.method.unpack(ud, root, self.d)
  1485. if ud.lockfile:
  1486. bb.utils.unlockfile(lf)
  1487. def clean(self, urls=None):
  1488. """
  1489. Clean files that the fetcher gets or places
  1490. """
  1491. if not urls:
  1492. urls = self.urls
  1493. for url in urls:
  1494. if url not in self.ud:
  1495. self.ud[url] = FetchData(url, self.d)
  1496. ud = self.ud[url]
  1497. ud.setup_localpath(self.d)
  1498. if not ud.localfile and ud.localpath is None:
  1499. continue
  1500. if ud.lockfile:
  1501. lf = bb.utils.lockfile(ud.lockfile)
  1502. ud.method.clean(ud, self.d)
  1503. if ud.donestamp:
  1504. bb.utils.remove(ud.donestamp)
  1505. if ud.lockfile:
  1506. bb.utils.unlockfile(lf)
  1507. class FetchConnectionCache(object):
  1508. """
  1509. A class which represents an container for socket connections.
  1510. """
  1511. def __init__(self):
  1512. self.cache = {}
  1513. def get_connection_name(self, host, port):
  1514. return host + ':' + str(port)
  1515. def add_connection(self, host, port, connection):
  1516. cn = self.get_connection_name(host, port)
  1517. if cn not in self.cache:
  1518. self.cache[cn] = connection
  1519. def get_connection(self, host, port):
  1520. connection = None
  1521. cn = self.get_connection_name(host, port)
  1522. if cn in self.cache:
  1523. connection = self.cache[cn]
  1524. return connection
  1525. def remove_connection(self, host, port):
  1526. cn = self.get_connection_name(host, port)
  1527. if cn in self.cache:
  1528. self.cache[cn].close()
  1529. del self.cache[cn]
  1530. def close_connections(self):
  1531. for cn in list(self.cache.keys()):
  1532. self.cache[cn].close()
  1533. del self.cache[cn]
  1534. from . import cvs
  1535. from . import git
  1536. from . import gitsm
  1537. from . import gitannex
  1538. from . import local
  1539. from . import svn
  1540. from . import wget
  1541. from . import ssh
  1542. from . import sftp
  1543. from . import s3
  1544. from . import perforce
  1545. from . import bzr
  1546. from . import hg
  1547. from . import osc
  1548. from . import repo
  1549. from . import clearcase
  1550. from . import npm
  1551. methods.append(local.Local())
  1552. methods.append(wget.Wget())
  1553. methods.append(svn.Svn())
  1554. methods.append(git.Git())
  1555. methods.append(gitsm.GitSM())
  1556. methods.append(gitannex.GitANNEX())
  1557. methods.append(cvs.Cvs())
  1558. methods.append(ssh.SSH())
  1559. methods.append(sftp.SFTP())
  1560. methods.append(s3.S3())
  1561. methods.append(perforce.Perforce())
  1562. methods.append(bzr.Bzr())
  1563. methods.append(hg.Hg())
  1564. methods.append(osc.Osc())
  1565. methods.append(repo.Repo())
  1566. methods.append(clearcase.ClearCase())
  1567. methods.append(npm.Npm())