summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-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: