summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2016-01-26 11:19:56 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-30 11:43:56 +0000
commit28c041c1e7a4ccf9d1c804cb45398dbb1cf527d1 (patch)
tree073c4f80be7f944e960a3b559c8fc92a5b873b4e /bitbake/lib
parent5375e6431c0475b1a266d481af2af5187dbf99f2 (diff)
downloadpoky-28c041c1e7a4ccf9d1c804cb45398dbb1cf527d1.tar.gz
bitbake: fetch2: Simplify logic in verify_checksum()
The recent change to verify_checksum() to only show checksum warnings if no checksums are supplied made it possible to simplify the logic a bit more. (Bitbake rev: 1dc00b874acae44bbba9d8028d94f7bc97ddcd76) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 5b416ab55a..dd1a1978d1 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -574,10 +574,10 @@ def verify_checksum(ud, d, precomputed={}):
574 else: 574 else:
575 sha256data = bb.utils.sha256_file(ud.localpath) 575 sha256data = bb.utils.sha256_file(ud.localpath)
576 576
577 if ud.method.recommends_checksum(ud): 577 if ud.method.recommends_checksum(ud) and not ud.md5_expected and not ud.sha256_expected:
578 # If strict checking enabled and neither sum defined, raise error 578 # If strict checking enabled and neither sum defined, raise error
579 strict = d.getVar("BB_STRICT_CHECKSUM", True) or "0" 579 strict = d.getVar("BB_STRICT_CHECKSUM", True) or "0"
580 if (strict == "1") and not (ud.md5_expected or ud.sha256_expected): 580 if strict == "1":
581 logger.error('No checksum specified for %s, please add at least one to the recipe:\n' 581 logger.error('No checksum specified for %s, please add at least one to the recipe:\n'
582 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' % 582 'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' %
583 (ud.localpath, ud.md5_name, md5data, 583 (ud.localpath, ud.md5_name, md5data,
@@ -585,32 +585,22 @@ def verify_checksum(ud, d, precomputed={}):
585 raise NoChecksumError('Missing SRC_URI checksum', ud.url) 585 raise NoChecksumError('Missing SRC_URI checksum', ud.url)
586 586
587 # Log missing sums so user can more easily add them 587 # Log missing sums so user can more easily add them
588 if not ud.md5_expected and not ud.sha256_expected: 588 logger.warn('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n'
589 logger.warn('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n' 589 'SRC_URI[%s] = "%s"',
590 'SRC_URI[%s] = "%s"', 590 ud.localpath, ud.md5_name, md5data)
591 ud.localpath, ud.md5_name, md5data) 591 logger.warn('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n'
592 logger.warn('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n' 592 'SRC_URI[%s] = "%s"',
593 'SRC_URI[%s] = "%s"', 593 ud.localpath, ud.sha256_name, sha256data)
594 ud.localpath, ud.sha256_name, sha256data)
595
596 md5mismatch = False
597 sha256mismatch = False
598
599 if ud.md5_expected != md5data:
600 md5mismatch = True
601
602 if ud.sha256_expected != sha256data:
603 sha256mismatch = True
604 594
605 # We want to alert the user if a checksum is defined in the recipe but 595 # We want to alert the user if a checksum is defined in the recipe but
606 # it does not match. 596 # it does not match.
607 msg = "" 597 msg = ""
608 mismatch = False 598 mismatch = False
609 if md5mismatch and ud.md5_expected: 599 if ud.md5_expected and ud.md5_expected != md5data:
610 msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'md5', md5data, ud.md5_expected) 600 msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'md5', md5data, ud.md5_expected)
611 mismatch = True; 601 mismatch = True;
612 602
613 if sha256mismatch and ud.sha256_expected: 603 if ud.sha256_expected and ud.sha256_expected != sha256data:
614 msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'sha256', sha256data, ud.sha256_expected) 604 msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'sha256', sha256data, ud.sha256_expected)
615 mismatch = True; 605 mismatch = True;
616 606