Source: socat
Version: 1.7.2.4-1
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps

Hi!

As part of the “reproducible builds” effort, we have discovered that
socat is using the __DATE__ and __TIME__ C pre-processor macro to record
the time of the build. This prevent socat build to be reproducible.

The attached patch will instead set the value of the `timestamp`
variable to the date of the latest debian/changelog entry. In order to
do so, it will patch the build system to allow the build timestamp to be
externally set through the BUILD_DATE variable.

Once applied, socat can be built reproducibly.

-- 
Lunar                                .''`. 
lu...@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
diff -Nru socat-1.7.2.4/debian/changelog socat-1.7.2.4/debian/changelog
--- socat-1.7.2.4/debian/changelog	2014-06-24 21:20:21.000000000 +0200
+++ socat-1.7.2.4/debian/changelog	2014-10-06 17:56:32.000000000 +0200
@@ -1,3 +1,10 @@
+socat (1.7.2.4-1.0~reproducible1) UNRELEASED; urgency=medium
+
+  * Patch build system to allow the build date to be set externally,
+    and set it to the latest debian/changelog entry for reproducibility.
+
+ -- Jérémy Bobbio <lu...@debian.org>  Mon, 06 Oct 2014 17:55:47 +0200
+
 socat (1.7.2.4-1) unstable; urgency=low
 
   * New upstream release, update patches.
diff -Nru socat-1.7.2.4/debian/control socat-1.7.2.4/debian/control
--- socat-1.7.2.4/debian/control	2014-06-24 19:15:04.000000000 +0200
+++ socat-1.7.2.4/debian/control	2014-10-06 17:51:02.000000000 +0200
@@ -3,7 +3,7 @@
 Priority: extra
 Maintainer: Laszlo Boszormenyi (GCS) <g...@debian.org>
 Homepage: http://www.dest-unreach.org/socat/
-Build-Depends: debhelper (>= 9), libssl-dev, libwrap0-dev
+Build-Depends: debhelper (>= 9), dh-autoreconf, libssl-dev, libwrap0-dev
 Standards-Version: 3.9.5
 
 Package: socat
diff -Nru socat-1.7.2.4/debian/patches/04-Set-build-date socat-1.7.2.4/debian/patches/04-Set-build-date
--- socat-1.7.2.4/debian/patches/04-Set-build-date	1970-01-01 01:00:00.000000000 +0100
+++ socat-1.7.2.4/debian/patches/04-Set-build-date	2014-10-06 18:55:35.000000000 +0200
@@ -0,0 +1,41 @@
+Description: allow time of the build to be set externally
+ When running the configure script, the time of the build
+ will be set to the environment variable BUILD_DATE if the
+ latr is set. This is needed to make builds reproducible.
+Author: Jérémy Bobbio <lu...@debian.org>
+Last-Update: 2014-10-06
+
+--- socat-1.7.2.4.orig/configure.in
++++ socat-1.7.2.4/configure.in
+@@ -1844,4 +1844,11 @@ if test -n "$WITH_FIPS"; then
+ fi
+ AC_SUBST(FIPSLD_CC)
+ 
++# allow BUILD_DATE to be externally set for build reproducibility
++if test "$BUILD_DATE"; then
++  AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
++else
++  AC_DEFINE(BUILD_DATE, [__DATE__" "__TIME__])
++fi
++
+ AC_OUTPUT(Makefile)
+--- socat-1.7.2.4.orig/socat.c
++++ socat-1.7.2.4/socat.c
+@@ -70,7 +70,7 @@ static int socat_newchild(void);
+ static const char socatversion[] =
+ #include "./VERSION"
+       ;
+-static const char timestamp[] = __DATE__" "__TIME__;
++static const char timestamp[] = BUILD_DATE;
+ 
+ const char copyright_socat[] = "socat by Gerhard Rieger - see www.dest-unreach.org";
+ #if WITH_OPENSSL
+--- socat-1.7.2.4.orig/config.h.in
++++ socat-1.7.2.4/config.h.in
+@@ -550,4 +550,6 @@
+ 
+ #undef WITH_MSGLEVEL
+ 
++#define BUILD_DATE __DATE__ " " __TIME__
++
+ #endif /* !defined(__config_h_included) */
diff -Nru socat-1.7.2.4/debian/patches/series socat-1.7.2.4/debian/patches/series
--- socat-1.7.2.4/debian/patches/series	2014-06-24 21:11:46.000000000 +0200
+++ socat-1.7.2.4/debian/patches/series	2014-10-06 18:55:59.000000000 +0200
@@ -2,3 +2,4 @@
 01-Index
 02-Manpage-slashes
 03-Truncate
+04-Set-build-date
diff -Nru socat-1.7.2.4/debian/rules socat-1.7.2.4/debian/rules
--- socat-1.7.2.4/debian/rules	2013-07-03 20:12:23.000000000 +0200
+++ socat-1.7.2.4/debian/rules	2014-10-06 18:47:18.000000000 +0200
@@ -1,7 +1,12 @@
 #!/usr/bin/make -f
 
+export BUILD_DATE = $(shell LC_ALL=C date -u --date="`dpkg-parsechangelog -SDate`" +'%b %e %Y %H:%M:%S')
+
+# upsteram maintains config.h.in manually
+export AUTOHEADER = true
+
 %:
-	dh $@
+	dh $@ --with=autoreconf
 
 override_dh_auto_configure:
 	dh_auto_configure -- --disable-readline

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