[Qa-jenkins-scm] [jenkins.debian.net] 01/01: bin/reproducible_json: Workaround str/bytes issue by using /bin/bzip2.

Holger Levsen holger at layer-acht.org
Mon Apr 3 15:11:49 UTC 2017


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit eeb1c58849c507f3bb437e54d2c44eb22eafe159
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Apr 3 16:58:52 2017 +0200

    bin/reproducible_json: Workaround str/bytes issue by using /bin/bzip2.
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_json.py | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py
index 6fb6549..4c759c1 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))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list