summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorBrendan Le Foll <brendan.le.foll@intel.com>2016-02-25 15:07:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-26 17:20:05 +0000
commit813bd1f806d27d46d6df8fbc8b878e78ac0053a1 (patch)
tree7024f64792ae014e56d0bcea6f029a7f0475e224 /bitbake/lib/bb/utils.py
parent7bb9e8ddbfabfbaebe1b3cb635b6d9979854cc47 (diff)
downloadpoky-813bd1f806d27d46d6df8fbc8b878e78ac0053a1.tar.gz
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 <brendan.le.foll@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py15
1 files changed, 15 insertions, 0 deletions
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):
534 s.update(line) 534 s.update(line)
535 return s.hexdigest() 535 return s.hexdigest()
536 536
537def sha1_file(filename):
538 """
539 Return the hex string representation of the SHA1 checksum of the filename
540 """
541 try:
542 import hashlib
543 except ImportError:
544 return None
545
546 s = hashlib.sha1()
547 with open(filename, "rb") as f:
548 for line in f:
549 s.update(line)
550 return s.hexdigest()
551
537def preserved_envvars_exported(): 552def preserved_envvars_exported():
538 """Variables which are taken from the environment and placed in and exported 553 """Variables which are taken from the environment and placed in and exported
539 from the metadata""" 554 from the metadata"""