diff options
author | Chris Lamb <lamby@debian.org> | 2017-04-03 16:58:52 +0200 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2017-04-03 17:11:44 +0200 |
commit | eeb1c58849c507f3bb437e54d2c44eb22eafe159 (patch) | |
tree | 51b0fe0963eb7e1bf5844ac61c6bb2b764786795 | |
parent | e7957d7508e6c1e8f4403e6827e5ee82ce730159 (diff) | |
download | jenkins.debian.net-eeb1c58849c507f3bb437e54d2c44eb22eafe159.tar.xz |
bin/reproducible_json: Workaround str/bytes issue by using /bin/bzip2.
Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-x | bin/reproducible_json.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py index 6fb6549a..4c759c17 100755 --- a/bin/reproducible_json.py +++ b/bin/reproducible_json.py @@ -14,9 +14,9 @@ from reproducible_common import * from apt_pkg import version_compare import aptsources.sourceslist -import bz2 import json import os +import subprocess import tempfile @@ -106,18 +106,23 @@ for row in result: output4tracker = list(crossarch.values()) -for data, fn, target in ( - (output, open, REPRODUCIBLE_JSON), - (output, bz2.BZ2File, REPRODUCIBLE_JSON + '.bz2'), - +for data, target in ( + (output, REPRODUCIBLE_JSON), # json for tracker.d.o, thanks to #785531 - (output4tracker, open, REPRODUCIBLE_TRACKER_JSON), - (output4tracker, bz2.BZ2File, REPRODUCIBLE_TRACKER_JSON + '.bz2'), + (output4tracker, REPRODUCIBLE_TRACKER_JSON), ): tmpfile = tempfile.mkstemp(dir=os.path.dirname(target))[1] - with fn(tmpfile, 'w') as fd: + with open(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) + log.info("%s/%s has been updated.", DEBIAN_URL, os.path.dirname(target)) + + # Write compressed version + compressed = '{}.bz2'.format(target) + tmpfile = tempfile.mkstemp(dir=os.path.dirname(compressed))[1] + with open(tmpfile, 'w') as fd: + subprocess.check_call(('bzip2', '-9c', target), stdout=fd) + os.rename(tmpfile, compressed) + os.chmod(compressed, 0o644) + log.info("%s/%s has been updated.", DEBIAN_URL, os.path.dirname(compressed)) |