Source: libtommath
Severity: normal
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

When the build time and timezone vary, the resulting .pdf file includes
an embedded timestamp. It looks like doc/makefile attempts to make the
timestamp reproducible in the generated .pdf, but doesn't catch some
corner cases.

The patch to debian/rules sets FORCE_SOURCE_DATE, which is needed to get
texlive to respect SOURCE_DATE_EPOCH.

The other patch modifies doc/makefile to use SOURCE_DATE_EPOCH directly
rather than a reference timestamp file.

Thanks for maintaining libtommath!

live well,
  vagrant

From 031c52564c767985e741a6b10aeedc624544a634 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagr...@reproducible-builds.org>
Date: Fri, 5 Jun 2020 21:26:02 +0000
Subject: [PATCH 1/2] debian/rules: export FORCE_SOURCE_DATE to allow .pdf
 files to be generated reproducibly.

Without FORCE_SOURCE_DATE texlive does not respect SOURCE_DATE_EPOCH:

  https://reproducible-builds.org/docs/source-date-epoch/
---
 debian/rules | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/rules b/debian/rules
index 97dbb93..b00c0b5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,6 +19,7 @@ export PREFIX=/usr
 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 export LIBPATH = $(PREFIX)/lib/$(DEB_HOST_MULTIARCH)
 
+export FORCE_SOURCE_DATE=1
 
 %:
 	dh $@
-- 
2.20.1

From ef8c77d9c5fd62773b467fa6e7b1a5167c4f770b Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagr...@reproducible-builds.org>
Date: Fri, 5 Jun 2020 21:55:05 +0000
Subject: [PATCH 2/2] Add patch to use UTC timezone for PDF generation.

---
 debian/patches/series           |  1 +
 debian/patches/use-utc-timezone | 37 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 debian/patches/use-utc-timezone

diff --git a/debian/patches/series b/debian/patches/series
index 1652816..198b971 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 increase-test-timeout
 remove-undefined-macro
 fix-shift-count-overflow-on-x32
+use-utc-timezone
diff --git a/debian/patches/use-utc-timezone b/debian/patches/use-utc-timezone
new file mode 100644
index 0000000..003b86f
--- /dev/null
+++ b/debian/patches/use-utc-timezone
@@ -0,0 +1,37 @@
+Author: Vagrant Cascadian <vagr...@reproducible-builds.org>
+Subject: Ensure the date is represented in UTC when generating PDF
+ files.
+Description: Use SOURCE_DATE_EPOCH directly rather than a timestamp
+ reference file which can vary between builds.
+ .
+ https://reproducible-builds.org/docs/source-date-epoch/
+
+Index: libtommath/doc/makefile
+===================================================================
+--- libtommath.orig/doc/makefile
++++ libtommath/doc/makefile
+@@ -16,15 +16,12 @@ docs: manual
+ 
+ #LTM user manual
+ mandvi: bn.tex
+-	cp bn.tex bn.bak
+-	touch --reference=bn.tex bn.bak
+-	(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y bn.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > bn-deterministic.tex
++	(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -u -d @$(SOURCE_DATE_EPOCH) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > bn-deterministic.tex
+ 	printf "%s\n" "\pdfinfo{" >> bn-deterministic.tex
+ 	printf "%s\n" "  /CreationDate (\fixedpdfdate)" >> bn-deterministic.tex
+ 	printf "%s\n}\n" "  /ModDate (\fixedpdfdate)" >> bn-deterministic.tex
+ 	cat bn.tex >> bn-deterministic.tex
+ 	mv bn-deterministic.tex bn.tex
+-	touch --reference=bn.bak bn.tex
+ 	echo "hello" > bn.ind
+ 	latex bn ${silent_stdout}
+ 	latex bn ${silent_stdout}
+@@ -35,7 +32,6 @@ mandvi: bn.tex
+ manual:	mandvi
+ 	pdflatex bn >/dev/null
+ 	sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' bn.pdf
+-	mv bn.bak bn.tex
+ 	rm -f bn.aux bn.dvi bn.log bn.idx bn.lof bn.out bn.toc
+ 
+ clean:
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

Reply via email to