[Debian-med-packaging] Bug#989693: brian: Fails to build reproducibly

Nilesh Patra nilesh at debian.org
Thu Jun 10 17:47:40 BST 2021


Source: brian
Version: 2.4.2-6
Severity: normal
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: timestamps, randomness
X-Debbugs-Cc: nilesh at debian.org, reproducible-bugs at lists.alioth.debian.org

Dear Maintainer,

Brian does not build reproducibly because:

a) It injects timestamps into docs
b) It injects files and text in random order into files

Super thanks to Felix C. Stegerman <flx at obfusk.net> for helping with
patch for the latter reason! :-)

I've committed a patch to salsa here[1] and will upload post bullseye
release.

Also attaching the corresponding patch with this email

[1]: https://salsa.debian.org/med-team/brian/-/commit/f16a61b846edb138e0d81cba1cc5e58f0e625ccc

Nilesh

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.7.0-2-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-------------- next part --------------
From f16a61b846edb138e0d81cba1cc5e58f0e625ccc Mon Sep 17 00:00:00 2001
From: Nilesh Patra <nilesh at debian.org>
Date: Thu, 10 Jun 2021 22:03:05 +0530
Subject: [PATCH] Make build reproducible

---
 debian/patches/reproducible.patch | 65 +++++++++++++++++++++++++++++++
 debian/patches/series             |  1 +
 debian/rules                      |  1 +
 3 files changed, 67 insertions(+)
 create mode 100644 debian/patches/reproducible.patch

diff --git a/debian/patches/reproducible.patch b/debian/patches/reproducible.patch
new file mode 100644
index 00000000..05db27f0
--- /dev/null
+++ b/debian/patches/reproducible.patch
@@ -0,0 +1,65 @@
+Description: Fix timestamps, insert files in deterministic order
+Author: Nilesh Patra <nilesh at debian.org>
+Last-Update: 2021-06-10
+--- a/dev/tools/release/setversion.py
++++ b/dev/tools/release/setversion.py
+@@ -8,7 +8,7 @@
+ * README.txt version
+ '''
+ 
+-import os, sys, re, datetime
++import os, sys, re, datetime, time
+ 
+ 
+ def setversion(version):
+@@ -47,7 +47,9 @@
+ 
+ 
+ def setreleasedate():
+-    releasedate = str(datetime.date.today())
++    releasedate = str(datetime.datetime.utcfromtimestamp(
++    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
++    ).date())
+     pathname = os.path.abspath(os.path.dirname(__file__))
+     os.chdir(pathname)
+     os.chdir('../../../')
+--- a/docs_sphinx/conf.py
++++ b/docs_sphinx/conf.py
+@@ -99,8 +99,10 @@
+ 
+ # General information about the project.
+ project = 'Brian 2'
+-import datetime
+-copyright = '2012?{}, Brian authors'.format(datetime.datetime.today().year)
++import datetime, time
++copyright = '2012?{}, Brian authors'.format(datetime.datetime.utcfromtimestamp(
++    int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
++    ).year)
+ 
+ # The version info for the project you're documenting, acts as replacement for
+ # |version| and |release|, also used in various other places throughout the
+--- a/brian2/sphinxext/examplefinder.py
++++ b/brian2/sphinxext/examplefinder.py
+@@ -54,9 +54,9 @@
+     '''
+     name = obj.__name__
+     examples_map = get_examples_map()
+-    examples = the_examples_map[name]
++    examples = sorted(the_examples_map[name])
+     tutorials_map = get_tutorials_map()
+-    tutorials = the_tutorials_map[name]
++    tutorials = sorted(the_tutorials_map[name])
+     if len(examples+tutorials)==0:
+         return ''
+     txt = 'Tutorials and examples using this'
+--- a/brian2/sphinxext/generate_examples.py
++++ b/brian2/sphinxext/generate_examples.py
+@@ -160,7 +160,7 @@
+         category_additional_files[relpath].append((file, full_name))
+         with codecs.open(fname, 'rU', encoding='utf-8') as f:
+             content = f.read()
+-        output = file + '\n' + '=' * len(title) + '\n\n'
++        output = file + '\n' + '=' * len(file) + '\n\n'
+         output += '.. code:: none\n\n'
+         content_lines = ['\t' + l for l in content.split('\n')]
+         output += '\n'.join(content_lines)
diff --git a/debian/patches/series b/debian/patches/series
index 742a3d6c..257f3619 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 ignore_failing_test.patch
 privacy.patch
 gsl-compiler-arg.patch
+reproducible.patch
diff --git a/debian/rules b/debian/rules
index a0cd4b0c..d1719605 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,7 @@
 #!/usr/bin/make -f
 # -*- makefile -*-
 
+export LANG=C.UTF-8 LC_ALL=C.UTF-8
 ifeq (,$(findstring get-orig-source, $(MAKECMDGOALS)))
 export  http_proxy=http://127.0.0.1:9/
 endif
-- 
GitLab



More information about the Debian-med-packaging mailing list