summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-30 20:49:59 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-31 09:13:04 +0100
commit672c07de4a96eb67eaafba0873eced44ec9ae1a6 (patch)
tree94163d2c92a6e5f78a89ab30e36b032e484dc5ae
parent2554be49f2993c8cc3c10d9d1896c9bef530b0f1 (diff)
downloadpoky-672c07de4a96eb67eaafba0873eced44ec9ae1a6.tar.gz
bitbake: fetch2: Ensure that incorrect checksumed files are always renamed
There are some codepaths where the file checksum is verified and can be found to mismatch but the 'rename' logic doesn't kick in. If code relies on the presence of a file for the checksum having been checked (e.g. uninative.bbclass) then it can be used when the checksum hasn't matched. Therefore rename the file whenever an invalid checksum is encountered. (Bitbake rev: 69ef6c8a9db02bfa0e3fac72481ec26586a29a01) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index e8cea7feb4..dc074d5340 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -677,7 +677,8 @@ def verify_donestamp(ud, d, origud=None):
677 # incorrect stamp file. 677 # incorrect stamp file.
678 logger.warn("Checksum mismatch for local file %s\n" 678 logger.warn("Checksum mismatch for local file %s\n"
679 "Cleaning and trying again." % ud.localpath) 679 "Cleaning and trying again." % ud.localpath)
680 rename_bad_checksum(ud, e.checksum) 680 if os.path.exists(ud.localpath):
681 rename_bad_checksum(ud, e.checksum)
681 bb.utils.remove(ud.donestamp) 682 bb.utils.remove(ud.donestamp)
682 return False 683 return False
683 684
@@ -698,11 +699,21 @@ def update_stamp(ud, d):
698 # Errors aren't fatal here 699 # Errors aren't fatal here
699 pass 700 pass
700 else: 701 else:
701 checksums = verify_checksum(ud, d) 702 try:
702 # Store the checksums for later re-verification against the recipe 703 checksums = verify_checksum(ud, d)
703 with open(ud.donestamp, "wb") as cachefile: 704 # Store the checksums for later re-verification against the recipe
704 p = pickle.Pickler(cachefile, pickle.HIGHEST_PROTOCOL) 705 with open(ud.donestamp, "wb") as cachefile:
705 p.dump(checksums) 706 p = pickle.Pickler(cachefile, pickle.HIGHEST_PROTOCOL)
707 p.dump(checksums)
708 except ChecksumError as e:
709 # Checksums failed to verify, trigger re-download and remove the
710 # incorrect stamp file.
711 logger.warn("Checksum mismatch for local file %s\n"
712 "Cleaning and trying again." % ud.localpath)
713 if os.path.exists(ud.localpath):
714 rename_bad_checksum(ud, e.checksum)
715 bb.utils.remove(ud.donestamp)
716 raise
706 717
707def subprocess_setup(): 718def subprocess_setup():
708 # Python installs a SIGPIPE handler by default. This is usually not what 719 # Python installs a SIGPIPE handler by default. This is usually not what
@@ -973,7 +984,8 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
973 if isinstance(e, ChecksumError): 984 if isinstance(e, ChecksumError):
974 logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (ud.url, origud.url)) 985 logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (ud.url, origud.url))
975 logger.warn(str(e)) 986 logger.warn(str(e))
976 rename_bad_checksum(ud, e.checksum) 987 if os.path.exists(ud.localpath):
988 rename_bad_checksum(ud, e.checksum)
977 elif isinstance(e, NoChecksumError): 989 elif isinstance(e, NoChecksumError):
978 raise 990 raise
979 else: 991 else:
@@ -1583,7 +1595,8 @@ class Fetch(object):
1583 if isinstance(e, ChecksumError): 1595 if isinstance(e, ChecksumError):
1584 logger.warn("Checksum failure encountered with download of %s - will attempt other sources if available" % u) 1596 logger.warn("Checksum failure encountered with download of %s - will attempt other sources if available" % u)
1585 logger.debug(1, str(e)) 1597 logger.debug(1, str(e))
1586 rename_bad_checksum(ud, e.checksum) 1598 if os.path.exists(ud.localpath):
1599 rename_bad_checksum(ud, e.checksum)
1587 elif isinstance(e, NoChecksumError): 1600 elif isinstance(e, NoChecksumError):
1588 raise 1601 raise
1589 else: 1602 else: