diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-19 13:59:14 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-22 12:03:02 +0000 |
commit | 4acc7322a2ada941b803e1aee23d84351888eef0 (patch) | |
tree | 3282b9b8541722fbe803890de00f697e9b9057ab /bitbake | |
parent | fda7b7bef1c3b0d77c370c80281ae4ce09a18cdf (diff) | |
download | poky-4acc7322a2ada941b803e1aee23d84351888eef0.tar.gz |
bitbake: fetch2: Clean up some url parameters to functions
urldata contains the url so we might as well stop passing around
pointless function parameters. This was done for legacy reasons but
its time to clean this mess up.
This is a first step in cleanup and is a standalone patch but there is
more to be done in a second patch.
(Bitbake rev: 06590cfebbcf6565a17b80cc298e3ecdfaba4656)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index b9f673c214..ae99b722aa 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -507,7 +507,7 @@ def fetcher_compare_revisions(d): | |||
507 | def mirror_from_string(data): | 507 | def mirror_from_string(data): |
508 | return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ] | 508 | return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ] |
509 | 509 | ||
510 | def verify_checksum(u, ud, d): | 510 | def verify_checksum(ud, d): |
511 | """ | 511 | """ |
512 | verify the MD5 and SHA256 checksum for downloaded src | 512 | verify the MD5 and SHA256 checksum for downloaded src |
513 | 513 | ||
@@ -530,7 +530,7 @@ def verify_checksum(u, ud, d): | |||
530 | raise NoChecksumError('No checksum specified for %s, please add at least one to the recipe:\n' | 530 | raise NoChecksumError('No checksum specified for %s, please add at least one to the recipe:\n' |
531 | 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' % | 531 | 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' % |
532 | (ud.localpath, ud.md5_name, md5data, | 532 | (ud.localpath, ud.md5_name, md5data, |
533 | ud.sha256_name, sha256data), u) | 533 | ud.sha256_name, sha256data), ud.url) |
534 | 534 | ||
535 | # Log missing sums so user can more easily add them | 535 | # Log missing sums so user can more easily add them |
536 | if ud.md5_expected == None: | 536 | if ud.md5_expected == None: |
@@ -568,10 +568,10 @@ def verify_checksum(u, ud, d): | |||
568 | 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) | 568 | 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) |
569 | 569 | ||
570 | if len(msg): | 570 | if len(msg): |
571 | raise ChecksumError('Checksum mismatch!%s' % msg, u, md5data) | 571 | raise ChecksumError('Checksum mismatch!%s' % msg, ud.url, md5data) |
572 | 572 | ||
573 | 573 | ||
574 | def update_stamp(u, ud, d): | 574 | def update_stamp(ud, d): |
575 | """ | 575 | """ |
576 | donestamp is file stamp indicating the whole fetching is done | 576 | donestamp is file stamp indicating the whole fetching is done |
577 | this function update the stamp after verifying the checksum | 577 | this function update the stamp after verifying the checksum |
@@ -584,7 +584,7 @@ def update_stamp(u, ud, d): | |||
584 | # Errors aren't fatal here | 584 | # Errors aren't fatal here |
585 | pass | 585 | pass |
586 | else: | 586 | else: |
587 | verify_checksum(u, ud, d) | 587 | verify_checksum(ud, d) |
588 | open(ud.donestamp, 'w').close() | 588 | open(ud.donestamp, 'w').close() |
589 | 589 | ||
590 | def subprocess_setup(): | 590 | def subprocess_setup(): |
@@ -730,7 +730,7 @@ def build_mirroruris(origud, mirrors, ld): | |||
730 | replacements["BASENAME"] = origud.path.split("/")[-1] | 730 | replacements["BASENAME"] = origud.path.split("/")[-1] |
731 | replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.').replace('*', '.') | 731 | replacements["MIRRORNAME"] = origud.host.replace(':','.') + origud.path.replace('/', '.').replace('*', '.') |
732 | 732 | ||
733 | def adduri(uri, ud, uris, uds): | 733 | def adduri(ud, uris, uds): |
734 | for line in mirrors: | 734 | for line in mirrors: |
735 | try: | 735 | try: |
736 | (find, replace) = line | 736 | (find, replace) = line |
@@ -753,9 +753,9 @@ def build_mirroruris(origud, mirrors, ld): | |||
753 | uris.append(newuri) | 753 | uris.append(newuri) |
754 | uds.append(newud) | 754 | uds.append(newud) |
755 | 755 | ||
756 | adduri(newuri, newud, uris, uds) | 756 | adduri(newud, uris, uds) |
757 | 757 | ||
758 | adduri(None, origud, uris, uds) | 758 | adduri(origud, uris, uds) |
759 | 759 | ||
760 | return uris, uds | 760 | return uris, uds |
761 | 761 | ||
@@ -772,22 +772,22 @@ def rename_bad_checksum(ud, suffix): | |||
772 | bb.utils.movefile(ud.localpath, new_localpath) | 772 | bb.utils.movefile(ud.localpath, new_localpath) |
773 | 773 | ||
774 | 774 | ||
775 | def try_mirror_url(newuri, origud, ud, ld, check = False): | 775 | def try_mirror_url(origud, ud, ld, check = False): |
776 | # Return of None or a value means we're finished | 776 | # Return of None or a value means we're finished |
777 | # False means try another url | 777 | # False means try another url |
778 | try: | 778 | try: |
779 | if check: | 779 | if check: |
780 | found = ud.method.checkstatus(newuri, ud, ld) | 780 | found = ud.method.checkstatus(ud.url, ud, ld) |
781 | if found: | 781 | if found: |
782 | return found | 782 | return found |
783 | return False | 783 | return False |
784 | 784 | ||
785 | os.chdir(ld.getVar("DL_DIR", True)) | 785 | os.chdir(ld.getVar("DL_DIR", True)) |
786 | 786 | ||
787 | if not os.path.exists(ud.donestamp) or ud.method.need_update(newuri, ud, ld): | 787 | if not os.path.exists(ud.donestamp) or ud.method.need_update(ud.url, ud, ld): |
788 | ud.method.download(newuri, ud, ld) | 788 | ud.method.download(ud.url, ud, ld) |
789 | if hasattr(ud.method,"build_mirror_data"): | 789 | if hasattr(ud.method,"build_mirror_data"): |
790 | ud.method.build_mirror_data(newuri, ud, ld) | 790 | ud.method.build_mirror_data(ud.url, ud, ld) |
791 | 791 | ||
792 | if not ud.localpath or not os.path.exists(ud.localpath): | 792 | if not ud.localpath or not os.path.exists(ud.localpath): |
793 | return False | 793 | return False |
@@ -817,7 +817,7 @@ def try_mirror_url(newuri, origud, ud, ld, check = False): | |||
817 | os.unlink(origud.localpath) | 817 | os.unlink(origud.localpath) |
818 | 818 | ||
819 | os.symlink(ud.localpath, origud.localpath) | 819 | os.symlink(ud.localpath, origud.localpath) |
820 | update_stamp(newuri, origud, ld) | 820 | update_stamp(origud, ld) |
821 | return ud.localpath | 821 | return ud.localpath |
822 | 822 | ||
823 | except bb.fetch2.NetworkAccess: | 823 | except bb.fetch2.NetworkAccess: |
@@ -825,13 +825,13 @@ def try_mirror_url(newuri, origud, ud, ld, check = False): | |||
825 | 825 | ||
826 | except bb.fetch2.BBFetchException as e: | 826 | except bb.fetch2.BBFetchException as e: |
827 | if isinstance(e, ChecksumError): | 827 | if isinstance(e, ChecksumError): |
828 | logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url)) | 828 | logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (ud.url, origud.url)) |
829 | logger.warn(str(e)) | 829 | logger.warn(str(e)) |
830 | rename_bad_checksum(ud, e.checksum) | 830 | rename_bad_checksum(ud, e.checksum) |
831 | elif isinstance(e, NoChecksumError): | 831 | elif isinstance(e, NoChecksumError): |
832 | raise | 832 | raise |
833 | else: | 833 | else: |
834 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | 834 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (ud.url, origud.url)) |
835 | logger.debug(1, str(e)) | 835 | logger.debug(1, str(e)) |
836 | try: | 836 | try: |
837 | ud.method.clean(ud, ld) | 837 | ud.method.clean(ud, ld) |
@@ -853,7 +853,7 @@ def try_mirrors(d, origud, mirrors, check = False): | |||
853 | uris, uds = build_mirroruris(origud, mirrors, ld) | 853 | uris, uds = build_mirroruris(origud, mirrors, ld) |
854 | 854 | ||
855 | for index, uri in enumerate(uris): | 855 | for index, uri in enumerate(uris): |
856 | ret = try_mirror_url(uri, origud, uds[index], ld, check) | 856 | ret = try_mirror_url(origud, uds[index], ld, check) |
857 | if ret != False: | 857 | if ret != False: |
858 | return ret | 858 | return ret |
859 | return None | 859 | return None |
@@ -1394,7 +1394,7 @@ class Fetch(object): | |||
1394 | localpath = ud.localpath | 1394 | localpath = ud.localpath |
1395 | # early checksum verify, so that if checksum mismatched, | 1395 | # early checksum verify, so that if checksum mismatched, |
1396 | # fetcher still have chance to fetch from mirror | 1396 | # fetcher still have chance to fetch from mirror |
1397 | update_stamp(u, ud, self.d) | 1397 | update_stamp(ud, self.d) |
1398 | 1398 | ||
1399 | except bb.fetch2.NetworkAccess: | 1399 | except bb.fetch2.NetworkAccess: |
1400 | raise | 1400 | raise |
@@ -1421,7 +1421,7 @@ class Fetch(object): | |||
1421 | logger.error(str(firsterr)) | 1421 | logger.error(str(firsterr)) |
1422 | raise FetchError("Unable to fetch URL from any source.", u) | 1422 | raise FetchError("Unable to fetch URL from any source.", u) |
1423 | 1423 | ||
1424 | update_stamp(u, ud, self.d) | 1424 | update_stamp(ud, self.d) |
1425 | 1425 | ||
1426 | except BBFetchException as e: | 1426 | except BBFetchException as e: |
1427 | if isinstance(e, NoChecksumError): | 1427 | if isinstance(e, NoChecksumError): |