[xmds2] 04/05: Ensure reproducible build

Rafael Laboissiere rafael at debian.org
Thu Jun 29 21:20:22 UTC 2017


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

rafael pushed a commit to branch master
in repository xmds2.

commit 146db2df15ec475092c44f58f943386dbe35c3af
Author: Rafael Laboissiere <rafael at debian.org>
Date:   Thu Jun 29 17:44:05 2017 -0300

    Ensure reproducible build
    
    + d/fix-cheetah-build-str.py: New script for replacing
      timestamp and build paths generated by Cheetah
    + d/control: Build-depends on python-debian and python-dateutil
    + d/rules: Call fix-cheetah-build-str.py in the
      override_dh_auto_install rule
    
    Gbp-Dch: Full
---
 debian/control                  |  2 ++
 debian/fix-cheetah-build-str.py | 33 +++++++++++++++++++++++++++++++++
 debian/rules                    |  1 +
 3 files changed, 36 insertions(+)

diff --git a/debian/control b/debian/control
index d9ddc00..43dc814 100644
--- a/debian/control
+++ b/debian/control
@@ -15,6 +15,8 @@ Build-Depends: debhelper (>= 10),
                mpi-default-dev,
                octave,
                python,
+               python-dateutil,
+               python-debian,
                python-h5py,
                python-setuptools,
                python-pyparsing,
diff --git a/debian/fix-cheetah-build-str.py b/debian/fix-cheetah-build-str.py
new file mode 100644
index 0000000..2a46df7
--- /dev/null
+++ b/debian/fix-cheetah-build-str.py
@@ -0,0 +1,33 @@
+### This script walks through all *.py that are included in the binary
+### package and replaces the build-specify timestamp and build path
+### generated by Cheetah.  This makes the building of the package
+### reproducible.  This script is intended to be called in the
+### override_dh_auto_install rule.
+
+import os
+import re
+import sys
+import time
+import fnmatch
+import fileinput
+import debian.changelog as dch
+from dateutil import parser
+
+ch = dch.Changelog (open ('debian/changelog', 'r'))
+dt = ch [0].date
+ts = time.mktime (parser.parse (dt).timetuple ())
+
+for dName, sdName, fList in os.walk ('debian/xmds2'):
+    for fileName in fList:
+        if fnmatch.fnmatch (fileName, '*.py'):
+            fname = os.path.join (dName, fileName)
+            for line in fileinput.input (fname, inplace = True):
+                outline = line
+                if re.match ("^__CHEETAH_genTime__ = .*$", line):
+                    outline = "__CHEETAH_genTime__ = %f\n" % ts
+                if re.match ("^__CHEETAH_genTimestamp__ = '.*'$", line):
+                    outline = "__CHEETAH_genTimestamp__ = '%s'\n" % dt
+                m = re.match ("^__CHEETAH_src__ = '.*/(.*)'$", line)
+                if m:
+                    outline = "__CHEETAH_src__ = '%s'\n" % m.group (1)
+                sys.stdout.write (outline)
diff --git a/debian/rules b/debian/rules
index b9416a9..b97d315 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,7 @@ XMDS_USER_DATA = $(CURDIR)/debian/xmds-user-data
 
 override_dh_auto_install:
 	python setup.py install --root=debian/xmds2 --install-layout=deb 
+	python debian/fix-cheetah-build-str.py
 
 override_dh_auto_test:
 	( export PYTHONPATH=$$(pwd) ;			\

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/xmds2.git



More information about the debian-science-commits mailing list