summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@kernel.crashing.org>2022-10-06 16:53:22 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-17 15:05:08 +0000
commit96272636897d2c35ee50ff935f23f7fcead5a537 (patch)
treec8adf175b3c72806867b2708e3200d67bca49e93 /bitbake
parentb643d2bc178efab1a192d2db3e2ea99e9c3e5dde (diff)
downloadpoky-96272636897d2c35ee50ff935f23f7fcead5a537.tar.gz
bitbake: utils/ply: Update md5 to better report errors with hashlib
In the case where hashlib is not available, the try would fail and fall through resulting in a backtrace on the usage of the 'sig'. The backtrace itself was confusing and made it difficult to determine what went wrong. Update the import to be in it's own try block with an appropriate message to indicate what went wrong. Note, the current version of ply all of this code has been restructured so this is not applicable upstream. Additionally, some versions of hashlib don't appear to implement the second FIPS related argument. Detect this and support both versions. (Bitbake rev: d26ed38c233583b35ad1451e521f07d9c2329f4e) Signed-off-by: Mark Hatle <mark.hatle@amd.com> Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> (cherry picked from commit 484ab42f440070c0369b81f5c69da860fa47a798) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py7
-rw-r--r--bitbake/lib/ply/yacc.py7
2 files changed, 13 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 66a8a08c21..bca4830f22 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -545,7 +545,12 @@ def md5_file(filename):
545 Return the hex string representation of the MD5 checksum of filename. 545 Return the hex string representation of the MD5 checksum of filename.
546 """ 546 """
547 import hashlib 547 import hashlib
548 return _hasher(hashlib.new('MD5', usedforsecurity=False), filename) 548 try:
549 sig = hashlib.new('MD5', usedforsecurity=False)
550 except TypeError:
551 # Some configurations don't appear to support two arguments
552 sig = hashlib.new('MD5')
553 return _hasher(sig, filename)
549 554
550def sha256_file(filename): 555def sha256_file(filename):
551 """ 556 """
diff --git a/bitbake/lib/ply/yacc.py b/bitbake/lib/ply/yacc.py
index 767c4e4674..381b50cf0b 100644
--- a/bitbake/lib/ply/yacc.py
+++ b/bitbake/lib/ply/yacc.py
@@ -2798,7 +2798,14 @@ class ParserReflect(object):
2798 def signature(self): 2798 def signature(self):
2799 try: 2799 try:
2800 import hashlib 2800 import hashlib
2801 except ImportError:
2802 raise RuntimeError("Unable to import hashlib")
2803 try:
2801 sig = hashlib.new('MD5', usedforsecurity=False) 2804 sig = hashlib.new('MD5', usedforsecurity=False)
2805 except TypeError:
2806 # Some configurations don't appear to support two arguments
2807 sig = hashlib.new('MD5')
2808 try:
2802 if self.start: 2809 if self.start:
2803 sig.update(self.start.encode('latin-1')) 2810 sig.update(self.start.encode('latin-1'))
2804 if self.prec: 2811 if self.prec: