[oe-commits] [bitbake] 01/19: utils.py: Add sha1_file call

git at git.openembedded.org git at git.openembedded.org
Fri Feb 26 17:59:03 UTC 2016


rpurdie pushed a commit to branch master
in repository bitbake.

commit fd5d9011f6dd7029895b64d8a02d33185b9aa8ae
Author: Brendan Le Foll <brendan.le.foll at intel.com>
AuthorDate: Thu Feb 25 15:07:06 2016 +0000

    utils.py: Add sha1_file call
    
    This is useful as npm-lockdown uses sha1 because npm releases the sha1 of
    packages and whilst this is undocumented it seems no other algorithm is
    supported
    
    Signed-off-by: Brendan Le Foll <brendan.le.foll at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/utils.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 82579b8..7ab8927 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -534,6 +534,21 @@ def sha256_file(filename):
             s.update(line)
     return s.hexdigest()
 
+def sha1_file(filename):
+    """
+    Return the hex string representation of the SHA1 checksum of the filename
+    """
+    try:
+        import hashlib
+    except ImportError:
+        return None
+
+    s = hashlib.sha1()
+    with open(filename, "rb") as f:
+        for line in f:
+            s.update(line)
+    return s.hexdigest()
+
 def preserved_envvars_exported():
     """Variables which are taken from the environment and placed in and exported
     from the metadata"""

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list