[Python-modules-team] Bug#881089: stardicter: please make the build reproducible

Chris Lamb lamby at debian.org
Tue Nov 7 16:04:09 UTC 2017


Source: stardicter
Version: 1.1-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed
that stardicter generates non-deterministic output in .ifo files.

In particular, it adds the current date and time.

Patch attached that uses SOURCE_DATE_EPOCH[1] if available.

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
diff --git a/stardicter/base.py b/stardicter/base.py
index 64dd17f..3d2a8a0 100644
--- a/stardicter/base.py
+++ b/stardicter/base.py
@@ -30,6 +30,7 @@ from operator import attrgetter
 import os
 import re
 import struct
+import time
 
 from six.moves.urllib.request import urlopen
 from six import BytesIO
@@ -386,7 +387,9 @@ class StardictWriter(object):
             handle.write(self.convert('website={0}\n'.format(URL), False))
             # we're using pango markup for all entries
             handle.write('sametypesequence=g\n')
-            handle.write(datetime.date.today().strftime('date=%Y.%m.%d\n'))
+            now = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
+            today = datetime.datetime.utcfromtimestamp(now)
+            handle.write(today.strftime('date=%Y.%m.%d\n'))
 
     def write_dict(self, directory):
         '''


More information about the Python-modules-team mailing list