Bug#788752: analog: please make the build reproducible
Source: analog Version: 2:6.0-20 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: timestamps Hi! While working on the “reproducible builds” effort [1], we have noticed that analog could not be built reproducibly. The attached patch removes extra timestamps from the build system. Specifically, the patch avoids the the usage of the __DATE__ and __TIME__ C macro which embed timestamps during the compilation and make the package build unreproducible. Once applied, analog can be built reproducibly in our current experimental framework. [1]: https://wiki.debian.org/ReproducibleBuilds -- Dhole diff -u analog-6.0/debian/changelog analog-6.0/debian/changelog --- analog-6.0/debian/changelog +++ analog-6.0/debian/changelog @@ -1,3 +1,10 @@ +analog (2:6.0-22) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Remove timestamp from outxml.c to make package build reproducibly + + -- Dhole Sat, 13 Jun 2015 21:05:32 +0200 + analog (2:6.0-20) unstable; urgency=low * QA upload. only in patch2: unchanged: --- analog-6.0.orig/src/outxml.c +++ analog-6.0/src/outxml.c @@ -54,7 +54,6 @@ extern timecode_t starttimec; unsigned int year, month, day, i; - struct tm temptime; char *xmlversion = "1.0"; char *encoding = "UTF-8"; @@ -85,15 +84,10 @@ xml_defaults( opts ); // extract a build timestamp from __DATE__ and __TIME__ -- locale dependent?! need to force "C" locale ? - strptime( __DATE__" "__TIME__, "%b%n%d%n%Y%n%T", &temptime ); - - sprintf( buffer, "%04d%02d%02d%02d%02d", - temptime.tm_year+1900, temptime.tm_mon+1, temptime.tm_mday, temptime.tm_hour, temptime.tm_min ); code2date( starttimec/1440, &day, &month, &year); - + XML_OUT( XMLDBG "", VERSION ); - XML_OUT( XMLDBG "", buffer ); XML_OUT( XMLDBG " ", year, month+1, day, (int)((starttimec%1440)/60), (int)(starttimec%60) ); signature.asc Description: OpenPGP digital signature
Bug#788752: [Reproducible-builds] Bug#788752: analog: please make the build reproducible
I forgot to add: In order to make the build reproducible, the timestamp used in outxml.c has been removed. The new generated xml will not have the `` field. -- Dhole signature.asc Description: OpenPGP digital signature
Bug#788752: [Reproducible-builds] Bug#788752: analog: please make the build reproducible
Hi! The patch I submitted earlier removed the timestamp from the build system. Probably removing the `` field in the generated xml by outxml.c was not desirable, so I've improved the patch. In this case no timestamp is removed: the build date can now be set externally, and specifically it is set to the last debian/changelog entry. -- Dhole diff -u analog-6.0/debian/changelog analog-6.0/debian/changelog --- analog-6.0/debian/changelog +++ analog-6.0/debian/changelog @@ -1,3 +1,11 @@ +analog (2:6.0-21) 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. + + + -- Dhole Mon, 15 Jun 2015 13:08:11 +0200 + analog (2:6.0-20) unstable; urgency=low * QA upload. diff -u analog-6.0/debian/rules analog-6.0/debian/rules --- analog-6.0/debian/rules +++ analog-6.0/debian/rules @@ -2,6 +2,8 @@ include /usr/share/quilt/quilt.make +export BUILD_DATE = $(shell LC_ALL=C date -u --date="`dpkg-parsechangelog -SDate`" +'%b %e %Y %H:%M:%S') + clean: unpatch dh clean only in patch2: unchanged: --- analog-6.0.orig/src/Makefile +++ analog-6.0/src/Makefile @@ -47,6 +47,7 @@ # MPE/iX needs LIBS = -lsocket -lm # SVR4 needs LIBS = -lsocket -lnsl -lm # DYNIX/ptx needs LIBS = -L/usr/lib/bsd-socket -lsocket -lnsl -lm +BUILD_DATE ?= $(shell date '+%b %e %Y') # define in case it is not exported PROGRAM = analog TARGET = ../analog @@ -69,7 +70,7 @@ HEADERS = anlghead.h anlghea2.h anlghea3.h anlghea4.h macdir.h \ pcre/pcre.h libgd/gd.h libgd/gdfontf.h libgd/gdfonts.h unzip/unzip.h \ zlib/zlib.h bzip2/bzlib.h -ALLCFLAGS = $(CFLAGS) $(DEFS) -D$(OS) +ALLCFLAGS = $(CFLAGS) $(DEFS) -D$(OS) -DBUILD_DATE="\"$(BUILD_DATE)\"" ALLOBJS = $(OBJS) $(SUBDIROBJS) $(PROGRAM): $(OBJS) $(SUBDIRS) $(HEADERS) Makefile only in patch2: unchanged: --- analog-6.0.orig/src/outxml.c +++ analog-6.0/src/outxml.c @@ -16,6 +16,10 @@ #define NDEBUG +#ifndef BUILD_DATE +#define BUILD_DATE __DATE__ " " __TIME__ +#endif + #include #include #include @@ -85,7 +89,7 @@ xml_defaults( opts ); // extract a build timestamp from __DATE__ and __TIME__ -- locale dependent?! need to force "C" locale ? - strptime( __DATE__" "__TIME__, "%b%n%d%n%Y%n%T", &temptime ); + strptime( BUILD_DATE, "%b%n%d%n%Y%n%T", &temptime ); sprintf( buffer, "%04d%02d%02d%02d%02d", temptime.tm_year+1900, temptime.tm_mon+1, temptime.tm_mday, temptime.tm_hour, temptime.tm_min ); signature.asc Description: OpenPGP digital signature