From c0ebfbc8df77d5a982f1b1897c2114c735a9b8db Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sat, 1 Apr 2017 19:17:24 +0100 Subject: reproducible_json.py: Write .bz2 versions as well. (Closes: #859254) Signed-off-by: Chris Lamb Signed-off-by: Holger Levsen --- bin/reproducible_json.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py index 33e0fb3e..cfb6e95b 100755 --- a/bin/reproducible_json.py +++ b/bin/reproducible_json.py @@ -14,6 +14,7 @@ from reproducible_common import * from apt_pkg import version_compare import aptsources.sourceslist +import bz2 import json import os import tempfile @@ -105,19 +106,18 @@ for row in result: output4tracker = list(crossarch.values()) -# normal json -tmpfile = tempfile.mkstemp(dir=os.path.dirname(REPRODUCIBLE_JSON))[1] -with open(tmpfile, 'w') as fd: - json.dump(output, fd, indent=4, sort_keys=True) -os.rename(tmpfile, REPRODUCIBLE_JSON) -os.chmod(REPRODUCIBLE_JSON, 0o644) - -# json for tracker.d.o, thanks to #785531 -tmpfile = tempfile.mkstemp(dir=os.path.dirname(REPRODUCIBLE_TRACKER_JSON))[1] -with open(tmpfile, 'w') as fd: - json.dump(output4tracker, fd, indent=4, sort_keys=True) -os.rename(tmpfile, REPRODUCIBLE_TRACKER_JSON) -os.chmod(REPRODUCIBLE_TRACKER_JSON, 0o644) - -log.info(DEBIAN_URL + '/reproducible.json and /reproducible-tracker.json have been updated.') - +for data, fn, target in ( + (output, open, REPRODUCIBLE_JSON), + (output, bz2.BZ2File, REPRODUCIBLE_JSON + '.bz2'), + + # json for tracker.d.o, thanks to #785531 + (output4tracker, open, REPRODUCIBLE_TRACKER_JSON), + (output4tracker, bz2.BZ2File, REPRODUCIBLE_TRACKER_JSON + '.bz2'), +): + tmpfile = tempfile.mkstemp()[1] + with fn(tmpfile, 'w') as fd: + json.dump(data, fd, indent=4, sort_keys=True) + os.rename(tmpfile, target) + os.chmod(target, 0o644) + + log.info("%s/%s has been updated.", DEBIAN_URL, target) -- cgit v1.2.3-70-g09d2