summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2013-04-12 16:08:10 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-04-15 15:57:31 +0100
commit07e83d04ace1b78df656c8c32fc336302adae097 (patch)
tree63417ef382b8dc83dc92a9aeaffba0591186438c /bitbake/lib/bb
parent3cc69d34131351fc9eb8672a838002241af4d329 (diff)
downloadpoky-07e83d04ace1b78df656c8c32fc336302adae097.tar.gz
bitbake: fetch2: rename file with bad checksum instead of removing it completely
* this can be useful when someone wan't to compare old file with bad checksum and new one (Bitbake rev: 33c6b93597dd43ab03ce7b62ba3eeb1893a68c38) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 1bf67ddbdc..dd1cc932d4 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -74,6 +74,9 @@ class FetchError(BBFetchException):
74 74
75class ChecksumError(FetchError): 75class ChecksumError(FetchError):
76 """Exception when mismatched checksum encountered""" 76 """Exception when mismatched checksum encountered"""
77 def __init__(self, message, url = None, checksum = None):
78 self.checksum = checksum
79 FetchError.__init__(self, message, url)
77 80
78class NoChecksumError(FetchError): 81class NoChecksumError(FetchError):
79 """Exception when no checksum is specified, but BB_STRICT_CHECKSUM is set""" 82 """Exception when no checksum is specified, but BB_STRICT_CHECKSUM is set"""
@@ -561,7 +564,7 @@ def verify_checksum(u, ud, d):
561 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) 564 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)
562 565
563 if len(msg): 566 if len(msg):
564 raise ChecksumError('Checksum mismatch!%s' % msg, u) 567 raise ChecksumError('Checksum mismatch!%s' % msg, u, md5data)
565 568
566 569
567def update_stamp(u, ud, d): 570def update_stamp(u, ud, d):
@@ -804,6 +807,7 @@ def try_mirror_url(newuri, origud, ud, ld, check = False):
804 if isinstance(e, ChecksumError): 807 if isinstance(e, ChecksumError):
805 logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url)) 808 logger.warn("Mirror checksum failure for url %s (original url: %s)\nCleaning and trying again." % (newuri, origud.url))
806 logger.warn(str(e)) 809 logger.warn(str(e))
810 self.rename_bad_checksum(ud, e.checksum)
807 elif isinstance(e, NoChecksumError): 811 elif isinstance(e, NoChecksumError):
808 raise 812 raise
809 else: 813 else:
@@ -1388,6 +1392,7 @@ class Fetch(object):
1388 if isinstance(e, ChecksumError): 1392 if isinstance(e, ChecksumError):
1389 logger.warn("Checksum failure encountered with download of %s - will attempt other sources if available" % u) 1393 logger.warn("Checksum failure encountered with download of %s - will attempt other sources if available" % u)
1390 logger.debug(1, str(e)) 1394 logger.debug(1, str(e))
1395 self.rename_bad_checksum(ud, e.checksum)
1391 elif isinstance(e, NoChecksumError): 1396 elif isinstance(e, NoChecksumError):
1392 raise 1397 raise
1393 else: 1398 else:
@@ -1495,6 +1500,18 @@ class Fetch(object):
1495 if ud.lockfile: 1500 if ud.lockfile:
1496 bb.utils.unlockfile(lf) 1501 bb.utils.unlockfile(lf)
1497 1502
1503 def rename_bad_checksum(self, ud, suffix):
1504 """
1505 Renames files to have suffix from parameter
1506 """
1507
1508 if ud.localpath is None:
1509 return
1510
1511 new_localpath = "%s_bad-checksum_%s" % (ud.localpath, suffix)
1512 bb.warn("Renaming %s to %s" % (ud.localpath, new_localpath))
1513 bb.utils.movefile(ud.localpath, new_localpath)
1514
1498from . import cvs 1515from . import cvs
1499from . import git 1516from . import git
1500from . import gitsm 1517from . import gitsm