From 813bd1f806d27d46d6df8fbc8b878e78ac0053a1 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 25 Feb 2016 15:07:06 +0000 Subject: bitbake: 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 (Bitbake rev: fd5d9011f6dd7029895b64d8a02d33185b9aa8ae) Signed-off-by: Brendan Le Foll Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bitbake/lib/bb/utils.py') diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 82579b8a15..7ab8927608 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/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""" -- cgit v1.2.3-54-g00ecf