tags 859254 + patch
retitle 859254 Please make reproducible.json available via some more efficient 
method
thanks

Chris Lamb wrote:

> my quick tests show that `bzip -9` produces the smallest file.

Patch attached:

  commit 62c3949a8d8be485ba53b1da347ed68a3b8f0c37
  Author: Chris Lamb <[email protected]>
  Date:   Sat Apr 1 19:17:24 2017 +0100
  
      reproducible_json.py: Write .bz2 version as well. (Closes: #859254)
      
      Signed-off-by: Chris Lamb <[email protected]>
  
   bin/reproducible_json.py | 16 ++++++++++------
   1 file changed, 10 insertions(+), 6 deletions(-)


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [email protected] / chris-lamb.co.uk
       `-
>From 62c3949a8d8be485ba53b1da347ed68a3b8f0c37 Mon Sep 17 00:00:00 2001
From: Chris Lamb <[email protected]>
Date: Sat, 1 Apr 2017 19:17:24 +0100
Subject: [PATCH] reproducible_json.py: Write .bz2 version as well. (Closes:
 #859254)

Signed-off-by: Chris Lamb <[email protected]>
---
 bin/reproducible_json.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py
index 33e0fb3e..3707b1f3 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,12 +106,15 @@ 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)
+for fn, target in (
+    (open, REPRODUCIBLE_JSON),
+    (bz2.BZ2File, REPRODUCIBLE_JSON + '.bz2'),
+):
+    tmpfile = tempfile.mkstemp(dir=os.path.dirname(REPRODUCIBLE_JSON))[1]
+    with fn(tmpfile, 'w') as fd:
+        json.dump(output, fd, indent=4, sort_keys=True)
+    os.rename(tmpfile, target)
+    os.chmod(target, 0o644)
 
 # json for tracker.d.o, thanks to #785531
 tmpfile = tempfile.mkstemp(dir=os.path.dirname(REPRODUCIBLE_TRACKER_JSON))[1]
-- 
2.11.0

Reply via email to