summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-16 09:05:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-17 11:57:27 +0100
commit1028d0158a2fb603479893dc4f7386d15bf68fd2 (patch)
tree8761cb3ccff386db235d6aa839170427b1d219b5
parentb8be48c718a40bf0abafa9aa15a33dfc6ce9937c (diff)
downloadpoky-1028d0158a2fb603479893dc4f7386d15bf68fd2.zip
poky-1028d0158a2fb603479893dc4f7386d15bf68fd2.tar.gz
poky-1028d0158a2fb603479893dc4f7386d15bf68fd2.tar.bz2
bitbake: siggen: Fix type conversion issues
The switch to using json has messed up the type handling as the code does assume that set()s are present. Add a decoder to reconstruct the set() objects. Also fix the change of tuples to lists for the file checksums and fix an existing type bug where dicts insteads of lists was used. Drop some old siginfo format handling code which is now long since obsolete. (Bitbake rev: 2d704842c0928f8dbe78fd081042aa7280af96be) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/siggen.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index f526792..578ba5d 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -24,9 +24,14 @@ hashequiv_logger = logging.getLogger('BitBake.SigGen.HashEquiv')
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
- return list(sorted(obj))
+ return dict(_set_object=list(sorted(obj)))
return json.JSONEncoder.default(self, obj)
+def SetDecoder(dct):
+ if '_set_object' in dct:
+ return set(dct['_set_object'])
+ return dct
+
def init(d):
siggens = [obj for obj in globals().values()
if type(obj) is type and issubclass(obj, SignatureGenerator)]
@@ -803,9 +808,9 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
return formatstr.format(**formatparams)
with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f:
- a_data = json.load(f)
+ a_data = json.load(f, object_hook=SetDecoder)
with bb.compress.zstd.open(b, "rt", encoding="utf-8", num_threads=1) as f:
- b_data = json.load(f)
+ b_data = json.load(f, object_hook=SetDecoder)
def dict_diff(a, b, whitelist=set()):
sa = set(a.keys())
@@ -821,11 +826,11 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
def file_checksums_diff(a, b):
from collections import Counter
- # Handle old siginfo format
- if isinstance(a, dict):
- a = [(os.path.basename(f), cs) for f, cs in a.items()]
- if isinstance(b, dict):
- b = [(os.path.basename(f), cs) for f, cs in b.items()]
+
+ # Convert lists back to tuples
+ a = [(f[0], f[1]) for f in a]
+ b = [(f[0], f[1]) for f in b]
+
# Compare lists, ensuring we can handle duplicate filenames if they exist
removedcount = Counter(a)
removedcount.subtract(b)
@@ -908,9 +913,9 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False):
output.append(color_format("{color_title}Variable {var} value changed from '{color_default}{oldval}{color_title}' to '{color_default}{newval}{color_title}'{color_default}", var=dep, oldval=oldval, newval=newval))
if not 'file_checksum_values' in a_data:
- a_data['file_checksum_values'] = {}
+ a_data['file_checksum_values'] = []
if not 'file_checksum_values' in b_data:
- b_data['file_checksum_values'] = {}
+ b_data['file_checksum_values'] = []
changed, added, removed = file_checksums_diff(a_data['file_checksum_values'], b_data['file_checksum_values'])
if changed:
@@ -1038,7 +1043,7 @@ def dump_sigfile(a):
output = []
with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f:
- a_data = json.load(f)
+ a_data = json.load(f, object_hook=SetDecoder)
output.append("basewhitelist: %s" % (a_data['basewhitelist']))