diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-16 09:05:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-17 11:57:27 +0100 |
commit | 1028d0158a2fb603479893dc4f7386d15bf68fd2 (patch) | |
tree | 8761cb3ccff386db235d6aa839170427b1d219b5 /bitbake | |
parent | b8be48c718a40bf0abafa9aa15a33dfc6ce9937c (diff) | |
download | poky-1028d0158a2fb603479893dc4f7386d15bf68fd2.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/siggen.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py index f526792efd..578ba5d661 100644 --- a/bitbake/lib/bb/siggen.py +++ b/bitbake/lib/bb/siggen.py | |||
@@ -24,9 +24,14 @@ hashequiv_logger = logging.getLogger('BitBake.SigGen.HashEquiv') | |||
24 | class SetEncoder(json.JSONEncoder): | 24 | class SetEncoder(json.JSONEncoder): |
25 | def default(self, obj): | 25 | def default(self, obj): |
26 | if isinstance(obj, set): | 26 | if isinstance(obj, set): |
27 | return list(sorted(obj)) | 27 | return dict(_set_object=list(sorted(obj))) |
28 | return json.JSONEncoder.default(self, obj) | 28 | return json.JSONEncoder.default(self, obj) |
29 | 29 | ||
30 | def SetDecoder(dct): | ||
31 | if '_set_object' in dct: | ||
32 | return set(dct['_set_object']) | ||
33 | return dct | ||
34 | |||
30 | def init(d): | 35 | def init(d): |
31 | siggens = [obj for obj in globals().values() | 36 | siggens = [obj for obj in globals().values() |
32 | if type(obj) is type and issubclass(obj, SignatureGenerator)] | 37 | if type(obj) is type and issubclass(obj, SignatureGenerator)] |
@@ -803,9 +808,9 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False): | |||
803 | return formatstr.format(**formatparams) | 808 | return formatstr.format(**formatparams) |
804 | 809 | ||
805 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: | 810 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: |
806 | a_data = json.load(f) | 811 | a_data = json.load(f, object_hook=SetDecoder) |
807 | with bb.compress.zstd.open(b, "rt", encoding="utf-8", num_threads=1) as f: | 812 | with bb.compress.zstd.open(b, "rt", encoding="utf-8", num_threads=1) as f: |
808 | b_data = json.load(f) | 813 | b_data = json.load(f, object_hook=SetDecoder) |
809 | 814 | ||
810 | def dict_diff(a, b, whitelist=set()): | 815 | def dict_diff(a, b, whitelist=set()): |
811 | sa = set(a.keys()) | 816 | sa = set(a.keys()) |
@@ -821,11 +826,11 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False): | |||
821 | 826 | ||
822 | def file_checksums_diff(a, b): | 827 | def file_checksums_diff(a, b): |
823 | from collections import Counter | 828 | from collections import Counter |
824 | # Handle old siginfo format | 829 | |
825 | if isinstance(a, dict): | 830 | # Convert lists back to tuples |
826 | a = [(os.path.basename(f), cs) for f, cs in a.items()] | 831 | a = [(f[0], f[1]) for f in a] |
827 | if isinstance(b, dict): | 832 | b = [(f[0], f[1]) for f in b] |
828 | b = [(os.path.basename(f), cs) for f, cs in b.items()] | 833 | |
829 | # Compare lists, ensuring we can handle duplicate filenames if they exist | 834 | # Compare lists, ensuring we can handle duplicate filenames if they exist |
830 | removedcount = Counter(a) | 835 | removedcount = Counter(a) |
831 | removedcount.subtract(b) | 836 | removedcount.subtract(b) |
@@ -908,9 +913,9 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False): | |||
908 | 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)) | 913 | 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)) |
909 | 914 | ||
910 | if not 'file_checksum_values' in a_data: | 915 | if not 'file_checksum_values' in a_data: |
911 | a_data['file_checksum_values'] = {} | 916 | a_data['file_checksum_values'] = [] |
912 | if not 'file_checksum_values' in b_data: | 917 | if not 'file_checksum_values' in b_data: |
913 | b_data['file_checksum_values'] = {} | 918 | b_data['file_checksum_values'] = [] |
914 | 919 | ||
915 | changed, added, removed = file_checksums_diff(a_data['file_checksum_values'], b_data['file_checksum_values']) | 920 | changed, added, removed = file_checksums_diff(a_data['file_checksum_values'], b_data['file_checksum_values']) |
916 | if changed: | 921 | if changed: |
@@ -1038,7 +1043,7 @@ def dump_sigfile(a): | |||
1038 | output = [] | 1043 | output = [] |
1039 | 1044 | ||
1040 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: | 1045 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: |
1041 | a_data = json.load(f) | 1046 | a_data = json.load(f, object_hook=SetDecoder) |
1042 | 1047 | ||
1043 | output.append("basewhitelist: %s" % (a_data['basewhitelist'])) | 1048 | output.append("basewhitelist: %s" % (a_data['basewhitelist'])) |
1044 | 1049 | ||