Skip to contentSkip to conversation

Fixes for verify_checksum()

PATCH New Peter Kjellerstedt 1 participant 2 messages Jan 26, 2016

lore
Share & tools
lore
#0 lore raw

cover Fixes for verify_checksum()

This simplifies the logic in verify_checksum() in fetch2.

//Peter

The following changes since commit 72f98ba5775f6faa2bcad80b913948c1b953111b:

bitbake: toaster: Update UI test runner (2016-01-25 16:29:10 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib pkj/verify_checksum
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/verify_checksum

Peter Kjellerstedt (1):
fetch2: Simplify logic in verify_checksum()

 bitbake/lib/bb/fetch2/__init__.py | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 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/lib/bb/fetch2/__init__.py | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +10 -20
index 5b416ab..dd1a197 100644
@@ -574,10 +574,10 @@ def verify_checksum(ud, d, precomputed={}):
     else:
         sha256data = bb.utils.sha256_file(ud.localpath)
 
-    if ud.method.recommends_checksum(ud):
+    if ud.method.recommends_checksum(ud) and not ud.md5_expected and not ud.sha256_expected:
         # If strict checking enabled and neither sum defined, raise error
         strict = d.getVar("BB_STRICT_CHECKSUM", True) or "0"
-        if (strict == "1") and not (ud.md5_expected or ud.sha256_expected):
+        if strict == "1":
             logger.error('No checksum specified for %s, please add at least one to the recipe:\n'
                              'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' %
                              (ud.localpath, ud.md5_name, md5data,
@@ -585,32 +585,22 @@ def verify_checksum(ud, d, precomputed={}):
             raise NoChecksumError('Missing SRC_URI checksum', ud.url)
 
         # Log missing sums so user can more easily add them
-        if not ud.md5_expected and not ud.sha256_expected:
-            logger.warn('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n'
-                        'SRC_URI[%s] = "%s"',
-                        ud.localpath, ud.md5_name, md5data)
-            logger.warn('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n'
-                        'SRC_URI[%s] = "%s"',
-                        ud.localpath, ud.sha256_name, sha256data)
-
-    md5mismatch = False
-    sha256mismatch = False
-
-    if ud.md5_expected != md5data:
-        md5mismatch = True
-
-    if ud.sha256_expected != sha256data:
-        sha256mismatch = True
+        logger.warn('Missing md5 SRC_URI checksum for %s, consider adding to the recipe:\n'
+                    'SRC_URI[%s] = "%s"',
+                    ud.localpath, ud.md5_name, md5data)
+        logger.warn('Missing sha256 SRC_URI checksum for %s, consider adding to the recipe:\n'
+                    'SRC_URI[%s] = "%s"',
+                    ud.localpath, ud.sha256_name, sha256data)
 
     # We want to alert the user if a checksum is defined in the recipe but
     # it does not match.
     msg = ""
     mismatch = False
-    if md5mismatch and ud.md5_expected:
+    if ud.md5_expected and ud.md5_expected != md5data:
         msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'md5', md5data, ud.md5_expected)
         mismatch = True;
 
-    if sha256mismatch and ud.sha256_expected:
+    if ud.sha256_expected and ud.sha256_expected != sha256data:
         msg = msg + "\nFile: '%s' has %s checksum %s when %s was expected" % (ud.localpath, 'sha256', sha256data, ud.sha256_expected)
         mismatch = True;
 
Signature · 1 line
2.1.0