Source: apt-dater
Version: 1.0.1+git20150119-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 apt-dater could not be built reproducibly.

The attached patch allows the build date embedded in apt-dater.c (coming
from the C macros __DATE__ and __TIME__) to be set externally with the
BUILD_DATE define, and specifically it is set to the last
debian/changelog entry. In case the BUILD_DATE define is not exported,
the package can be built embedding a timestamp of the compilation time.
Once applied, apt-dater can be built reproducibly in our current
experimental framework.

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

-- 
Dhole
diff -Nru apt-dater-1.0.1+git20150119/debian/changelog 
apt-dater-1.0.1+git20150119/debian/changelog
--- apt-dater-1.0.1+git20150119/debian/changelog        2015-01-19 
19:14:38.000000000 +0100
+++ apt-dater-1.0.1+git20150119/debian/changelog        2015-06-23 
03:13:51.000000000 +0200
@@ -1,3 +1,11 @@
+apt-dater (1.0.1+git20150119-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Patch build system to allow the build date to be set externally,
+    and set it to the latest debian/changelog entry for reproducibility.
+
+ -- Dhole <dh...@openmailbox.org>  Tue, 23 Jun 2015 03:13:30 +0200
+
 apt-dater (1.0.1+git20150119-1) unstable; urgency=low
 
   * New upstream git snapshot.
diff -Nru apt-dater-1.0.1+git20150119/debian/patches/fix_build_date 
apt-dater-1.0.1+git20150119/debian/patches/fix_build_date
--- apt-dater-1.0.1+git20150119/debian/patches/fix_build_date   1970-01-01 
01:00:00.000000000 +0100
+++ apt-dater-1.0.1+git20150119/debian/patches/fix_build_date   2015-06-23 
03:14:33.000000000 +0200
@@ -0,0 +1,45 @@
+Description: Set build date externally
+ .
+ apt-dater (1.0.1+git20150119-1.1) UNRELEASED; urgency=medium
+ .
+   * Non-maintainer upload.
+   * Patch build system to allow the build date to be set externally,
+     and set it to the latest debian/changelog entry for reproducibility.
+Author: Dhole <dh...@openmailbox.org>
+
+---
+
+--- apt-dater-1.0.1+git20150119.orig/src/Makefile.am
++++ apt-dater-1.0.1+git20150119/src/Makefile.am
+@@ -1,5 +1,7 @@
+ bin_PROGRAMS = apt-dater
+ 
++# define in case BUILD_DATE is not exported
++BUILD_DATE ?= $(shell date '%b %e %Y %H:%M:%S')
++
+ apt_dater_SOURCES =                   \
+       adproto.h                       \
+       apt-dater.c                     \
+@@ -38,7 +40,7 @@ apt_dater_SOURCES =                  \
+ 
+ apt_dater_LDADD = $(GLIB_LIBS) $(TCL_LIBS) $(LIBXML2_LIBS) $(LIBCONFIG_LIBS)
+ 
+-AM_CFLAGS = -Wall -DPKGLIBDIR='"'$(pkglibdir)'"'
++AM_CFLAGS = -Wall -DPKGLIBDIR='"'$(pkglibdir)'"' 
-DBUILD_DATE="\"$(BUILD_DATE)\""
+ if LINUX
+ AM_LDFLAGS = -Wl,--as-needed
+ else
+--- apt-dater-1.0.1+git20150119.orig/src/apt-dater.c
++++ apt-dater-1.0.1+git20150119/src/apt-dater.c
+@@ -45,7 +45,11 @@
+ #include "report.h"
+ #endif
+ 
+-#define VERSTEXT PACKAGE_STRING " - " __DATE__ " " __TIME__ "\n\n" \
++#ifndef BUILD_DATE
++#define BUILD_DATE __DATE__ " " __TIME__
++#endif
++
++#define VERSTEXT PACKAGE_STRING " - " BUILD_DATE "\n\n" \
+   "Copyright Holder: IBH IT-Service GmbH [https://www.ibh.net/]\n\n"; \
+   "This program is free software; you can redistribute it and/or modify\n" \
+   "it under the terms of the GNU General Public License as published by\n" \
diff -Nru apt-dater-1.0.1+git20150119/debian/patches/series 
apt-dater-1.0.1+git20150119/debian/patches/series
--- apt-dater-1.0.1+git20150119/debian/patches/series   1970-01-01 
01:00:00.000000000 +0100
+++ apt-dater-1.0.1+git20150119/debian/patches/series   2015-06-23 
03:14:15.000000000 +0200
@@ -0,0 +1 @@
+fix_build_date
diff -Nru apt-dater-1.0.1+git20150119/debian/rules 
apt-dater-1.0.1+git20150119/debian/rules
--- apt-dater-1.0.1+git20150119/debian/rules    2015-01-19 19:14:38.000000000 
+0100
+++ apt-dater-1.0.1+git20150119/debian/rules    2015-06-23 03:08:26.000000000 
+0200
@@ -8,6 +8,10 @@
        --enable-clusters \
        --enable-debug
 
+# Store a the last changelog date in the form of __DATE__ " " __DATE__ C macro
+export BUILD_DATE = $(shell LC_ALL=C date -u \
+       --date="`dpkg-parsechangelog -SDate`" +'%b %e %Y %H:%M:%S')
+
 %:
        dh $@
 

Attachment: signature.asc
Description: OpenPGP 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