diff options
author | Brendan Le Foll <brendan.le.foll@intel.com> | 2016-02-25 15:07:06 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-26 17:17:20 +0000 |
commit | fd5d9011f6dd7029895b64d8a02d33185b9aa8ae (patch) | |
tree | 35c91e62c62e3a19560543ca919fbe502b9560a6 /lib/bb/utils.py | |
parent | 932a92b8130d4815656dc885f0c6e4afa4502022 (diff) | |
download | bitbake-fd5d9011f6dd7029895b64d8a02d33185b9aa8ae.tar.gz |
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@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r-- | lib/bb/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 82579b8a1..7ab892760 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""" |