diff options
| -rw-r--r-- | bitbake/lib/bb/siggen.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py index 625a9cf3bb..f526792efd 100644 --- a/bitbake/lib/bb/siggen.py +++ b/bitbake/lib/bb/siggen.py | |||
| @@ -11,6 +11,8 @@ import pickle | |||
| 11 | import bb.data | 11 | import bb.data |
| 12 | import difflib | 12 | import difflib |
| 13 | import simplediff | 13 | import simplediff |
| 14 | import json | ||
| 15 | import bb.compress.zstd | ||
| 14 | from bb.checksum import FileChecksumCache | 16 | from bb.checksum import FileChecksumCache |
| 15 | from bb import runqueue | 17 | from bb import runqueue |
| 16 | import hashserv | 18 | import hashserv |
| @@ -19,6 +21,12 @@ import hashserv.client | |||
| 19 | logger = logging.getLogger('BitBake.SigGen') | 21 | logger = logging.getLogger('BitBake.SigGen') |
| 20 | hashequiv_logger = logging.getLogger('BitBake.SigGen.HashEquiv') | 22 | hashequiv_logger = logging.getLogger('BitBake.SigGen.HashEquiv') |
| 21 | 23 | ||
| 24 | class SetEncoder(json.JSONEncoder): | ||
| 25 | def default(self, obj): | ||
| 26 | if isinstance(obj, set): | ||
| 27 | return list(sorted(obj)) | ||
| 28 | return json.JSONEncoder.default(self, obj) | ||
| 29 | |||
| 22 | def init(d): | 30 | def init(d): |
| 23 | siggens = [obj for obj in globals().values() | 31 | siggens = [obj for obj in globals().values() |
| 24 | if type(obj) is type and issubclass(obj, SignatureGenerator)] | 32 | if type(obj) is type and issubclass(obj, SignatureGenerator)] |
| @@ -398,9 +406,9 @@ class SignatureGeneratorBasic(SignatureGenerator): | |||
| 398 | 406 | ||
| 399 | fd, tmpfile = tempfile.mkstemp(dir=os.path.dirname(sigfile), prefix="sigtask.") | 407 | fd, tmpfile = tempfile.mkstemp(dir=os.path.dirname(sigfile), prefix="sigtask.") |
| 400 | try: | 408 | try: |
| 401 | with os.fdopen(fd, "wb") as stream: | 409 | with bb.compress.zstd.open(fd, "wt", encoding="utf-8", num_threads=1) as f: |
| 402 | p = pickle.dump(data, stream, -1) | 410 | json.dump(data, f, sort_keys=True, separators=(",", ":"), cls=SetEncoder) |
| 403 | stream.flush() | 411 | f.flush() |
| 404 | os.chmod(tmpfile, 0o664) | 412 | os.chmod(tmpfile, 0o664) |
| 405 | bb.utils.rename(tmpfile, sigfile) | 413 | bb.utils.rename(tmpfile, sigfile) |
| 406 | except (OSError, IOError) as err: | 414 | except (OSError, IOError) as err: |
| @@ -794,12 +802,10 @@ def compare_sigfiles(a, b, recursecb=None, color=False, collapsed=False): | |||
| 794 | formatparams.update(values) | 802 | formatparams.update(values) |
| 795 | return formatstr.format(**formatparams) | 803 | return formatstr.format(**formatparams) |
| 796 | 804 | ||
| 797 | with open(a, 'rb') as f: | 805 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: |
| 798 | p1 = pickle.Unpickler(f) | 806 | a_data = json.load(f) |
| 799 | a_data = p1.load() | 807 | with bb.compress.zstd.open(b, "rt", encoding="utf-8", num_threads=1) as f: |
| 800 | with open(b, 'rb') as f: | 808 | b_data = json.load(f) |
| 801 | p2 = pickle.Unpickler(f) | ||
| 802 | b_data = p2.load() | ||
| 803 | 809 | ||
| 804 | def dict_diff(a, b, whitelist=set()): | 810 | def dict_diff(a, b, whitelist=set()): |
| 805 | sa = set(a.keys()) | 811 | sa = set(a.keys()) |
| @@ -1031,9 +1037,8 @@ def calc_taskhash(sigdata): | |||
| 1031 | def dump_sigfile(a): | 1037 | def dump_sigfile(a): |
| 1032 | output = [] | 1038 | output = [] |
| 1033 | 1039 | ||
| 1034 | with open(a, 'rb') as f: | 1040 | with bb.compress.zstd.open(a, "rt", encoding="utf-8", num_threads=1) as f: |
| 1035 | p1 = pickle.Unpickler(f) | 1041 | a_data = json.load(f) |
| 1036 | a_data = p1.load() | ||
| 1037 | 1042 | ||
| 1038 | output.append("basewhitelist: %s" % (a_data['basewhitelist'])) | 1043 | output.append("basewhitelist: %s" % (a_data['basewhitelist'])) |
| 1039 | 1044 | ||
