Source: gdbm
Version: 1.8.3-13.1
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps

Hi!

While working on the “reproducible builds” effort [1], we have noticed
that gdbm could not be built reproducibly.

The attached patch fixes several issues: it removes the build date and
time from the version string, calls strip-nondeterminism on static
libraries, and adjust file mtimes before building the binary packages.

Once applied, gdbm can be built reproducibly with the current
experimental framework.

 [1]: https://wiki.debian.org/ReproducibleBuilds

-- 
Lunar                                .''`. 
lu...@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
diff -Nru gdbm-1.8.3/debian/changelog gdbm-1.8.3/debian/changelog
--- gdbm-1.8.3/debian/changelog	2014-11-16 18:18:50.000000000 +0100
+++ gdbm-1.8.3/debian/changelog	2015-01-01 23:56:05.000000000 +0100
@@ -1,3 +1,12 @@
+gdbm (1.8.3-13.1.0~reproducible1) UNRELEASED; urgency=low
+
+  * Enable reproducible builds:
+    - Stop recording the build date and time in the version string.
+    - Use strip-nondeterminism on static libraries.
+    - Fix mtimes before building binary packages.
+
+ -- Jérémy Bobbio <lu...@debian.org>  Thu, 01 Jan 2015 22:44:01 +0000
+
 gdbm (1.8.3-13.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -Nru gdbm-1.8.3/debian/control gdbm-1.8.3/debian/control
--- gdbm-1.8.3/debian/control	2014-11-16 18:10:03.000000000 +0100
+++ gdbm-1.8.3/debian/control	2015-01-01 23:54:19.000000000 +0100
@@ -3,7 +3,7 @@
 Priority: important
 Maintainer: Anibal Monsalve Salazar <ani...@debian.org>
 Build-Depends: texinfo, libtool, automake, autoconf, autotools-dev,
- dpkg-dev (>= 1.16.1~), debhelper (>= 7)
+ dpkg-dev (>= 1.16.1~), debhelper (>= 7), strip-nondeterminism
 Standards-Version: 3.9.5
 Homepage: http://directory.fsf.org/project/gdbm/
 
diff -Nru gdbm-1.8.3/debian/patches/09-stop-recording-build-date.patch gdbm-1.8.3/debian/patches/09-stop-recording-build-date.patch
--- gdbm-1.8.3/debian/patches/09-stop-recording-build-date.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdbm-1.8.3/debian/patches/09-stop-recording-build-date.patch	2015-01-01 23:43:59.000000000 +0100
@@ -0,0 +1,18 @@
+Description: Stop recording build date
+ Recording the build date and time prevents gdbm to be build
+ reproducibly. Given it was only added to the version string when
+ certain macros were available, we simply disable the code
+ unconditionally.
+Author: Jérémy Bobbio <lu...@debian.org>
+
+--- gdbm-1.8.3.orig/version.c
++++ gdbm-1.8.3/version.c
+@@ -30,7 +30,7 @@
+ 
+ /* Keep a string with the version number in it! */
+ const char * gdbm_version = "GDBM version 1.8.3. 10/15/2002"
+-#if defined(__STDC__) && defined(__DATE__) && defined(__TIME__)
++#if 0 && defined(__STDC__) && defined(__DATE__) && defined(__TIME__)
+ 		" (built " __DATE__ " " __TIME__ ")"
+ #endif
+ 		;
diff -Nru gdbm-1.8.3/debian/patches/series gdbm-1.8.3/debian/patches/series
--- gdbm-1.8.3/debian/patches/series	2013-06-02 00:39:56.000000000 +0200
+++ gdbm-1.8.3/debian/patches/series	2015-01-01 23:41:13.000000000 +0100
@@ -6,3 +6,4 @@
 06_manpage-cleanup.patch
 07-link-flags.patch
 08-709905-gdbm.texinfo.patch
+09-stop-recording-build-date.patch
diff -Nru gdbm-1.8.3/debian/rules gdbm-1.8.3/debian/rules
--- gdbm-1.8.3/debian/rules	2014-11-16 18:13:27.000000000 +0100
+++ gdbm-1.8.3/debian/rules	2015-01-01 23:58:40.000000000 +0100
@@ -18,6 +18,8 @@
 DPKG_EXPORT_BUILDFLAGS = 1
 include /usr/share/dpkg/buildflags.mk
 
+BUILD_DATE := $(shell dpkg-parsechangelog | sed -n -e 's/^Date: //p')
+
 CFLAGS += -O2 -g -Wall -D_REENTRANT
 
 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
@@ -102,6 +104,8 @@
 	dpkg-gensymbols -plibgdbm3
 	chown -R root.root debian/tmp/
 	chmod -R go=rX debian/tmp/
+	find debian/tmp -depth -newermt '$(BUILD_DATE)' -print0 | \
+		xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
 	dpkg --build debian/tmp/ ..
 
 binary-libgdbm-dev: checkroot build
@@ -119,6 +123,8 @@
 	done
 	#chmod 644 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.la
 	rm -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.la
+	find debian/tmp -type f -name '*.a' -print0 | \
+		xargs -0 strip-nondeterminism --type ar
 
 	# libc6 owns ndbm.h, but some apps want gdbm's
 	mv debian/tmp/usr/include/ndbm.h debian/tmp/usr/include/gdbm-ndbm.h
@@ -154,6 +160,8 @@
 	cd debian/tmp/; find . -type f ! -regex '.*/DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
 	chown -R root.root debian/tmp/
 	chmod -R go=rX debian/tmp/
+	find debian/tmp -depth -newermt '$(BUILD_DATE)' -print0 | \
+		xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
 	dpkg --build debian/tmp/ ..
 
 define checkdir

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to