[bitbake-devel] [PATCH 1/3] utils.py: Add sha1_file call
brendan.le.foll at intel.com
brendan.le.foll at intel.com
Thu Feb 25 15:07:06 UTC 2016
From: Brendan Le Foll <brendan.le.foll at intel.com>
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>
---
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"""
--
2.7.1
More information about the bitbake-devel
mailing list