diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-20 12:46:32 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-21 11:35:07 +0100 |
| commit | 3f30bf4eab707b1c8c27b7c10aa90a5f41a69980 (patch) | |
| tree | 23dd1651af38b34d98b04a44799a7c8c37461c41 /bitbake | |
| parent | ea032bb2c3b18c50ab3fa9dd6dfd2ca9adaba8bc (diff) | |
| download | poky-3f30bf4eab707b1c8c27b7c10aa90a5f41a69980.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>
Conflicts:
bitbake/lib/bb/fetch2/__init__.py
Signed-off-by: Khem Raj <kraj@juniper.net>
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 108 |
1 files changed, 59 insertions, 49 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 5c8652fc3a..8e361ed27e 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
| @@ -449,6 +449,60 @@ def check_network_access(d, info = "", url = None): | |||
| 449 | else: | 449 | else: |
| 450 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) | 450 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) |
| 451 | 451 | ||
| 452 | def try_mirror_url(newuri, origud, ud, ld, check = False): | ||
| 453 | # Return of None or a value means we're finished | ||
| 454 | # False means try another url | ||
| 455 | try: | ||
| 456 | if check: | ||
| 457 | found = ud.method.checkstatus(newuri, ud, ld) | ||
| 458 | if found: | ||
| 459 | return found | ||
| 460 | return False | ||
| 461 | |||
| 462 | os.chdir(ld.getVar("DL_DIR", True)) | ||
| 463 | |||
| 464 | if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): | ||
| 465 | ud.method.download(newuri, ud, ld) | ||
| 466 | if hasattr(ud.method,"build_mirror_data"): | ||
| 467 | ud.method.build_mirror_data(newuri, ud, ld) | ||
| 468 | |||
| 469 | if not ud.localpath or not os.path.exists(ud.localpath): | ||
| 470 | return False | ||
| 471 | |||
| 472 | if ud.localpath == origud.localpath: | ||
| 473 | return ud.localpath | ||
| 474 | |||
| 475 | # We may be obtaining a mirror tarball which needs further processing by the real fetcher | ||
| 476 | # If that tarball is a local file:// we need to provide a symlink to it | ||
| 477 | dldir = ld.getVar("DL_DIR", True) | ||
| 478 | if os.path.basename(ud.localpath) != os.path.basename(origud.localpath): | ||
| 479 | open(ud.donestamp, 'w').close() | ||
| 480 | dest = os.path.join(dldir, os.path.basename(ud.localpath)) | ||
| 481 | if not os.path.exists(dest): | ||
| 482 | os.symlink(ud.localpath, dest) | ||
| 483 | return None | ||
| 484 | # Otherwise the result is a local file:// and we symlink to it | ||
| 485 | if not os.path.exists(origud.localpath): | ||
| 486 | os.symlink(ud.localpath, origud.localpath) | ||
| 487 | update_stamp(newuri, origud, ld) | ||
| 488 | return ud.localpath | ||
| 489 | |||
| 490 | except bb.fetch2.NetworkAccess: | ||
| 491 | raise | ||
| 492 | |||
| 493 | except bb.fetch2.BBFetchException as e: | ||
| 494 | if isinstance(e, ChecksumError): | ||
| 495 | logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url)) | ||
| 496 | logger.warn(str(e)) | ||
| 497 | else: | ||
| 498 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | ||
| 499 | logger.debug(1, str(e)) | ||
| 500 | try: | ||
| 501 | ud.method.clean(ud, ld) | ||
| 502 | except UnboundLocalError: | ||
| 503 | pass | ||
| 504 | return False | ||
| 505 | |||
| 452 | def try_mirrors(d, origud, mirrors, check = False): | 506 | def try_mirrors(d, origud, mirrors, check = False): |
| 453 | """ | 507 | """ |
| 454 | Try to use a mirrored version of the sources. | 508 | Try to use a mirrored version of the sources. |
| @@ -467,56 +521,12 @@ def try_mirrors(d, origud, mirrors, check = False): | |||
| 467 | newuri = uri_replace(origud, find, replace, ld) | 521 | newuri = uri_replace(origud, find, replace, ld) |
| 468 | if not newuri: | 522 | if not newuri: |
| 469 | continue | 523 | continue |
| 470 | try: | 524 | ud = FetchData(newuri, ld) |
| 471 | ud = FetchData(newuri, ld) | 525 | ud.setup_localpath(ld) |
| 472 | ud.setup_localpath(ld) | ||
| 473 | 526 | ||
| 474 | os.chdir(ld.getVar("DL_DIR", True)) | 527 | ret = try_mirror_url(newuri, origud, ud, ld, check) |
| 475 | 528 | if ret != False: | |
| 476 | if check: | 529 | return ret |
| 477 | found = ud.method.checkstatus(newuri, ud, ld) | ||
| 478 | if found: | ||
| 479 | return found | ||
| 480 | continue | ||
| 481 | |||
| 482 | if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): | ||
| 483 | ud.method.download(newuri, ud, ld) | ||
| 484 | if os.path.exists(ud.localpath): | ||
| 485 | open(ud.donestamp, 'w').close() | ||
| 486 | if hasattr(ud.method,"build_mirror_data"): | ||
| 487 | ud.method.build_mirror_data(newuri, ud, ld) | ||
| 488 | |||
| 489 | if not ud.localpath or not os.path.exists(ud.localpath): | ||
| 490 | continue | ||
| 491 | |||
| 492 | if ud.localpath == origud.localpath: | ||
| 493 | return ud.localpath | ||
| 494 | |||
| 495 | # We may be obtaining a mirror tarball which needs further processing by the real fetcher | ||
| 496 | # If that tarball is a local file:// we need to provide a symlink to it | ||
| 497 | dldir = ld.getVar("DL_DIR", True) | ||
| 498 | if os.path.basename(ud.localpath) != os.path.basename(origud.localpath): | ||
| 499 | dest = os.path.join(dldir, os.path.basename(ud.localpath)) | ||
| 500 | if not os.path.exists(dest): | ||
| 501 | os.symlink(ud.localpath, dest) | ||
| 502 | return None | ||
| 503 | # Otherwise the result is a local file:// and we symlink to it | ||
| 504 | if not os.path.exists(origud.localpath): | ||
| 505 | os.symlink(ud.localpath, origud.localpath) | ||
| 506 | return ud.localpath | ||
| 507 | |||
| 508 | except bb.fetch2.NetworkAccess: | ||
| 509 | raise | ||
| 510 | |||
| 511 | except bb.fetch2.BBFetchException as e: | ||
| 512 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | ||
| 513 | logger.debug(1, str(e)) | ||
| 514 | try: | ||
| 515 | if os.path.isfile(ud.localpath): | ||
| 516 | bb.utils.remove(ud.localpath) | ||
| 517 | except UnboundLocalError: | ||
| 518 | pass | ||
| 519 | continue | ||
| 520 | return None | 530 | return None |
| 521 | 531 | ||
| 522 | def srcrev_internal_helper(ud, d, name): | 532 | def srcrev_internal_helper(ud, d, name): |
