diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-20 12:46:32 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-21 13:10:32 +0100 |
commit | f3fb4dc40f153cf4e80b4915e8d58e6fde74a29e (patch) | |
tree | 0c63bebb12cbd5e8a9d67c069149cc68c783f4e7 /bitbake | |
parent | 927565c3b1b94b4080ab0678a1c24c39183c4de0 (diff) | |
download | poky-f3fb4dc40f153cf4e80b4915e8d58e6fde74a29e.tar.gz |
bitbake: fetch2: Split try_mirrors into two parts
There are no functionality changes in this change
(From Poky rev: d222ebb7c75d74fde4fd04ea6feb27e10a862bae)
(Bitbake rev: db62e109cc36380ff8b8918628c9dea14ac9afbc)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 111 |
1 files changed, 59 insertions, 52 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index b09753f574..e4af9519ba 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -464,6 +464,60 @@ def check_network_access(d, info = "", url = None): | |||
464 | else: | 464 | else: |
465 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) | 465 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) |
466 | 466 | ||
467 | def try_mirror_url(newuri, origud, ud, ld, check = False): | ||
468 | # Return of None or a value means we're finished | ||
469 | # False means try another url | ||
470 | try: | ||
471 | if check: | ||
472 | found = ud.method.checkstatus(newuri, ud, ld) | ||
473 | if found: | ||
474 | return found | ||
475 | return False | ||
476 | |||
477 | os.chdir(ld.getVar("DL_DIR", True)) | ||
478 | |||
479 | if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): | ||
480 | ud.method.download(newuri, ud, ld) | ||
481 | if hasattr(ud.method,"build_mirror_data"): | ||
482 | ud.method.build_mirror_data(newuri, ud, ld) | ||
483 | |||
484 | if not ud.localpath or not os.path.exists(ud.localpath): | ||
485 | return False | ||
486 | |||
487 | if ud.localpath == origud.localpath: | ||
488 | return ud.localpath | ||
489 | |||
490 | # We may be obtaining a mirror tarball which needs further processing by the real fetcher | ||
491 | # If that tarball is a local file:// we need to provide a symlink to it | ||
492 | dldir = ld.getVar("DL_DIR", True) | ||
493 | if os.path.basename(ud.localpath) != os.path.basename(origud.localpath): | ||
494 | open(ud.donestamp, 'w').close() | ||
495 | dest = os.path.join(dldir, os.path.basename(ud.localpath)) | ||
496 | if not os.path.exists(dest): | ||
497 | os.symlink(ud.localpath, dest) | ||
498 | return None | ||
499 | # Otherwise the result is a local file:// and we symlink to it | ||
500 | if not os.path.exists(origud.localpath): | ||
501 | os.symlink(ud.localpath, origud.localpath) | ||
502 | update_stamp(newuri, origud, ld) | ||
503 | return ud.localpath | ||
504 | |||
505 | except bb.fetch2.NetworkAccess: | ||
506 | raise | ||
507 | |||
508 | except bb.fetch2.BBFetchException as e: | ||
509 | if isinstance(e, ChecksumError): | ||
510 | logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url)) | ||
511 | logger.warn(str(e)) | ||
512 | else: | ||
513 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | ||
514 | logger.debug(1, str(e)) | ||
515 | try: | ||
516 | ud.method.clean(ud, ld) | ||
517 | except UnboundLocalError: | ||
518 | pass | ||
519 | return False | ||
520 | |||
467 | def try_mirrors(d, origud, mirrors, check = False): | 521 | def try_mirrors(d, origud, mirrors, check = False): |
468 | """ | 522 | """ |
469 | Try to use a mirrored version of the sources. | 523 | Try to use a mirrored version of the sources. |
@@ -482,59 +536,12 @@ def try_mirrors(d, origud, mirrors, check = False): | |||
482 | newuri = uri_replace(origud, find, replace, ld) | 536 | newuri = uri_replace(origud, find, replace, ld) |
483 | if not newuri: | 537 | if not newuri: |
484 | continue | 538 | continue |
485 | try: | 539 | ud = FetchData(newuri, ld) |
486 | ud = FetchData(newuri, ld) | 540 | ud.setup_localpath(ld) |
487 | ud.setup_localpath(ld) | ||
488 | |||
489 | os.chdir(ld.getVar("DL_DIR", True)) | ||
490 | |||
491 | if check: | ||
492 | found = ud.method.checkstatus(newuri, ud, ld) | ||
493 | if found: | ||
494 | return found | ||
495 | continue | ||
496 | 541 | ||
497 | if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): | 542 | ret = try_mirror_url(newuri, origud, ud, ld, check) |
498 | ud.method.download(newuri, ud, ld) | 543 | if ret != False: |
499 | if hasattr(ud.method,"build_mirror_data"): | 544 | return ret |
500 | ud.method.build_mirror_data(newuri, ud, ld) | ||
501 | |||
502 | if not ud.localpath or not os.path.exists(ud.localpath): | ||
503 | continue | ||
504 | |||
505 | if ud.localpath == origud.localpath: | ||
506 | return ud.localpath | ||
507 | |||
508 | # We may be obtaining a mirror tarball which needs further processing by the real fetcher | ||
509 | # If that tarball is a local file:// we need to provide a symlink to it | ||
510 | dldir = ld.getVar("DL_DIR", True) | ||
511 | if os.path.basename(ud.localpath) != os.path.basename(origud.localpath): | ||
512 | open(ud.donestamp, 'w').close() | ||
513 | dest = os.path.join(dldir, os.path.basename(ud.localpath)) | ||
514 | if not os.path.exists(dest): | ||
515 | os.symlink(ud.localpath, dest) | ||
516 | return None | ||
517 | # Otherwise the result is a local file:// and we symlink to it | ||
518 | if not os.path.exists(origud.localpath): | ||
519 | os.symlink(ud.localpath, origud.localpath) | ||
520 | update_stamp(newuri, origud, ld) | ||
521 | return ud.localpath | ||
522 | |||
523 | except bb.fetch2.NetworkAccess: | ||
524 | raise | ||
525 | |||
526 | except bb.fetch2.BBFetchException as e: | ||
527 | if isinstance(e, ChecksumError): | ||
528 | logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url)) | ||
529 | logger.warn(str(e)) | ||
530 | else: | ||
531 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | ||
532 | logger.debug(1, str(e)) | ||
533 | try: | ||
534 | ud.method.clean(ud, ld) | ||
535 | except UnboundLocalError: | ||
536 | pass | ||
537 | continue | ||
538 | return None | 545 | return None |
539 | 546 | ||
540 | def srcrev_internal_helper(ud, d, name): | 547 | def srcrev_internal_helper(ud, d, name): |