summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_json.py
diff options
context:
space:
mode:
authorChris Lamb <lamby@debian.org>2017-04-01 19:17:24 +0100
committerHolger Levsen <holger@layer-acht.org>2017-04-03 14:58:35 +0200
commitc0ebfbc8df77d5a982f1b1897c2114c735a9b8db (patch)
tree0da53928e71b0289c12b5f25832995d84a976cab /bin/reproducible_json.py
parentdd347bb5e0587fed7e6881c8cb0ed3ca60b6595b (diff)
downloadjenkins.debian.net-c0ebfbc8df77d5a982f1b1897c2114c735a9b8db.tar.xz
reproducible_json.py: Write .bz2 versions as well. (Closes: #859254)
Signed-off-by: Chris Lamb <lamby@debian.org> Signed-off-by: Holger Levsen <holger@layer-acht.org>
Diffstat (limited to 'bin/reproducible_json.py')
-rwxr-xr-xbin/reproducible_json.py32
1 files changed, 16 insertions, 16 deletions
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)