diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index e8eaebe9dc..05fd81ad4d 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -198,7 +198,7 @@ def fetcher_compare_revisions(d): | |||
198 | # 3. localpaths | 198 | # 3. localpaths |
199 | # localpath can be called at any time | 199 | # localpath can be called at any time |
200 | 200 | ||
201 | def init(urls, d, setup = True): | 201 | def init(urls, d): |
202 | urldata = {} | 202 | urldata = {} |
203 | 203 | ||
204 | fn = bb.data.getVar('FILE', d, 1) | 204 | fn = bb.data.getVar('FILE', d, 1) |
@@ -209,11 +209,6 @@ def init(urls, d, setup = True): | |||
209 | if url not in urldata: | 209 | if url not in urldata: |
210 | urldata[url] = FetchData(url, d) | 210 | urldata[url] = FetchData(url, d) |
211 | 211 | ||
212 | if setup: | ||
213 | for url in urldata: | ||
214 | if not urldata[url].setup: | ||
215 | urldata[url].setup_localpath(d) | ||
216 | |||
217 | urldata_cache[fn] = urldata | 212 | urldata_cache[fn] = urldata |
218 | return urldata | 213 | return urldata |
219 | 214 | ||
@@ -279,7 +274,10 @@ def download(d, urls = None): | |||
279 | """ | 274 | """ |
280 | if not urls: | 275 | if not urls: |
281 | urls = d.getVar("SRC_URI", 1).split() | 276 | urls = d.getVar("SRC_URI", 1).split() |
282 | urldata = init(urls, d, True) | 277 | urldata = init(urls, d) |
278 | |||
279 | for u in urls: | ||
280 | urldata[u].setup_localpath(d) | ||
283 | 281 | ||
284 | for u in urls: | 282 | for u in urls: |
285 | ud = urldata[u] | 283 | ud = urldata[u] |
@@ -341,13 +339,14 @@ def checkstatus(d, urls = None): | |||
341 | Check all urls exist upstream | 339 | Check all urls exist upstream |
342 | init must have previously been called | 340 | init must have previously been called |
343 | """ | 341 | """ |
344 | urldata = init([], d, True) | 342 | urldata = init([], d) |
345 | 343 | ||
346 | if not urls: | 344 | if not urls: |
347 | urls = urldata | 345 | urls = urldata |
348 | 346 | ||
349 | for u in urls: | 347 | for u in urls: |
350 | ud = urldata[u] | 348 | ud = urldata[u] |
349 | ud.setup_localpath(d) | ||
351 | m = ud.method | 350 | m = ud.method |
352 | logger.debug(1, "Testing URL %s", u) | 351 | logger.debug(1, "Testing URL %s", u) |
353 | # First try checking uri, u, from PREMIRRORS | 352 | # First try checking uri, u, from PREMIRRORS |
@@ -370,10 +369,11 @@ def localpaths(d): | |||
370 | Return a list of the local filenames, assuming successful fetch | 369 | Return a list of the local filenames, assuming successful fetch |
371 | """ | 370 | """ |
372 | local = [] | 371 | local = [] |
373 | urldata = init([], d, True) | 372 | urldata = init([], d) |
374 | 373 | ||
375 | for u in urldata: | 374 | for u in urldata: |
376 | ud = urldata[u] | 375 | ud = urldata[u] |
376 | ud.setup_localpath(d) | ||
377 | local.append(ud.localpath) | 377 | local.append(ud.localpath) |
378 | 378 | ||
379 | return local | 379 | return local |
@@ -394,14 +394,9 @@ def get_srcrev(d): | |||
394 | """ | 394 | """ |
395 | 395 | ||
396 | scms = [] | 396 | scms = [] |
397 | 397 | urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d) | |
398 | # Only call setup_localpath on URIs which supports_srcrev() | ||
399 | urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False) | ||
400 | for u in urldata: | 398 | for u in urldata: |
401 | ud = urldata[u] | 399 | if urldata[u].method.supports_srcrev(): |
402 | if ud.method.supports_srcrev(): | ||
403 | if not ud.setup: | ||
404 | ud.setup_localpath(d) | ||
405 | scms.append(u) | 400 | scms.append(u) |
406 | 401 | ||
407 | if len(scms) == 0: | 402 | if len(scms) == 0: |
@@ -434,6 +429,7 @@ def localpath(url, d, cache = True): | |||
434 | """ | 429 | """ |
435 | ud = init([url], d) | 430 | ud = init([url], d) |
436 | if ud[url].method: | 431 | if ud[url].method: |
432 | ud[url].setup_localpath(d) | ||
437 | return ud[url].localpath | 433 | return ud[url].localpath |
438 | return url | 434 | return url |
439 | 435 | ||
@@ -546,6 +542,8 @@ class FetchData(object): | |||
546 | """ | 542 | """ |
547 | def __init__(self, url, d): | 543 | def __init__(self, url, d): |
548 | self.localfile = "" | 544 | self.localfile = "" |
545 | self.localpath = None | ||
546 | self.lockfile = None | ||
549 | (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(data.expand(url, d)) | 547 | (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(data.expand(url, d)) |
550 | self.date = Fetch.getSRCDate(self, d) | 548 | self.date = Fetch.getSRCDate(self, d) |
551 | self.url = url | 549 | self.url = url |
@@ -565,15 +563,34 @@ class FetchData(object): | |||
565 | self.sha256_expected = bb.data.getVarFlag("SRC_URI", self.sha256_name, d) | 563 | self.sha256_expected = bb.data.getVarFlag("SRC_URI", self.sha256_name, d) |
566 | 564 | ||
567 | self.names = self.parm.get("name",'default').split(',') | 565 | self.names = self.parm.get("name",'default').split(',') |
566 | |||
567 | self.method = None | ||
568 | for m in methods: | 568 | for m in methods: |
569 | if m.supports(url, self, d): | 569 | if m.supports(url, self, d): |
570 | self.method = m | 570 | self.method = m |
571 | if hasattr(m,"urldata_init"): | 571 | break |
572 | m.urldata_init(self, d) | 572 | |
573 | if m.supports_srcrev(): | 573 | if not self.method: |
574 | self.setup_srcrevs(d) | 574 | raise NoMethodError("Missing implementation for url %s" % url) |
575 | return | 575 | |
576 | raise NoMethodError("Missing implementation for url %s" % url) | 576 | if self.method.supports_srcrev(): |
577 | self.setup_srcrevs(d) | ||
578 | |||
579 | if hasattr(self.method, "urldata_init"): | ||
580 | self.method.urldata_init(self, d) | ||
581 | |||
582 | if "localpath" in self.parm: | ||
583 | # if user sets localpath for file, use it instead. | ||
584 | self.localpath = self.parm["localpath"] | ||
585 | self.basename = os.path.basename(self.localpath) | ||
586 | elif self.localfile: | ||
587 | self.localpath = self.method.localpath(self.url, self, d) | ||
588 | |||
589 | if self.localfile and self.localpath: | ||
590 | # Note: These files should always be in DL_DIR whereas localpath may not be. | ||
591 | basepath = bb.data.expand("${DL_DIR}/%s" % os.path.basename(self.localpath), d) | ||
592 | self.md5 = basepath + '.md5' | ||
593 | self.lockfile = basepath + '.lock' | ||
577 | 594 | ||
578 | def setup_srcrevs(self, d): | 595 | def setup_srcrevs(self, d): |
579 | if not self.method.supports_srcrev(): | 596 | if not self.method.supports_srcrev(): |
@@ -588,20 +605,9 @@ class FetchData(object): | |||
588 | self.revision = self.revisions[self.names[0]] | 605 | self.revision = self.revisions[self.names[0]] |
589 | 606 | ||
590 | def setup_localpath(self, d): | 607 | def setup_localpath(self, d): |
591 | self.setup = True | 608 | if not self.localpath: |
592 | if "localpath" in self.parm: | ||
593 | # if user sets localpath for file, use it instead. | ||
594 | self.localpath = self.parm["localpath"] | ||
595 | self.basename = os.path.basename(self.localpath) | ||
596 | else: | ||
597 | self.localpath = self.method.localpath(self.url, self, d) | 609 | self.localpath = self.method.localpath(self.url, self, d) |
598 | 610 | ||
599 | if self.localpath is not None: | ||
600 | # Note: These files should always be in DL_DIR whereas localpath may not be. | ||
601 | basepath = bb.data.expand("${DL_DIR}/%s" % os.path.basename(self.localpath), d) | ||
602 | self.md5 = basepath + '.md5' | ||
603 | self.lockfile = basepath + '.lock' | ||
604 | |||
605 | 611 | ||
606 | class Fetch(object): | 612 | class Fetch(object): |
607 | """Base class for 'fetch'ing data""" | 613 | """Base class for 'fetch'ing data""" |