]> code.ossystems Code Review - openembedded-core.git/commitdiff
When checksuming tarballs use bb.utils.*_sum instead of calling commands directly
authorRoss Burton <ross@openedhand.com>
Thu, 1 May 2008 11:00:27 +0000 (11:00 +0000)
committerRoss Burton <ross@openedhand.com>
Thu, 1 May 2008 11:00:27 +0000 (11:00 +0000)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4387 311d38ba-8fff-0310-9ca6-ca027cbcb966

meta/classes/base.bbclass

index 2e8f3f08fbf460a37b2722313836d54f8c282cde..0c048b997b5a717c65714258932a58dee07a68e6 100644 (file)
@@ -45,21 +45,21 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data):
         raise Exception("The path does not exist '%s'" % localpath)
 
 
-    # call md5(sum) and shasum
-    try:
-        md5pipe = os.popen('md5sum ' + localpath)
-        md5data = (md5pipe.readline().split() or [ "" ])[0]
-        md5pipe.close()
-    except OSError:
-        raise Exception("Executing md5sum failed")
-
-    try:
-        shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
-        shadata = (shapipe.readline().split() or [ "" ])[0]
-        shapipe.close()
-    except OSError:
-        raise Exception("Executing shasum failed")
-
+    # Calculate the MD5 and 256-bit SHA checksums
+    md5data = bb.utils.md5_file(localpath)
+    shadata = bb.utils.sha256_file(localpath)
+
+    # sha256_file() can return None if we are running on Python 2.4 (hashlib is
+    # 2.5 onwards, sha in 2.4 is 160-bit only), so check for this and call the
+    # standalone shasum binary if required.
+    if shadata is None:
+        try:
+            shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
+            shadata = (shapipe.readline().split() or [ "" ])[0]
+            shapipe.close()
+        except OSError:
+            raise Exception("Executing shasum failed, please build shasum-native")
+    
     if no_checksum == True:    # we do not have conf/checksums.ini entry
         try:
             file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")