[Reproducible-builds] Bug#835129: dateutils: please make the build reproducible
Chris Lamb
lamby at debian.org
Mon Aug 22 19:28:20 UTC 2016
Source: dateutils
Version: 0.3.1-1.1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-builds at lists.alioth.debian.org
Hi,
Whilst working on the Reproducible Builds effort [0], I noticed
that dateutils could not be built reproducibly.
Patch attached.
[0] https://reproducible-builds.org/
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby at debian.org / chris-lamb.co.uk
`-
-------------- next part --------------
--- a/debian/patches/0002-reproducible-build.diff 1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/0002-reproducible-build.diff 2016-08-22 20:22:06.728424663 +0100
@@ -0,0 +1,54 @@
+Description: Make the build reproducible
+Author: Chris Lamb <lamby at debian.org>
+Last-Update: 2016-08-22
+
+--- dateutils-0.3.1.orig/build-aux/yuck.c
++++ dateutils-0.3.1/build-aux/yuck.c
+@@ -1349,6 +1349,38 @@ bollocks:
+ _exit(EXIT_FAILURE);
+ }
+
++static time_t
++get_current_time(void)
++{
++ time_t now;
++ char *source_date_epoch, *endptr;
++ unsigned long long epoch;
++
++ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++
++ if (!source_date_epoch) {
++ return time(NULL);
++ }
++
++ errno = 0;
++ epoch = strtoull(source_date_epoch, &endptr, 10);
++
++ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0)) || (errno != 0 && epoch == 0)) {
++ now = (time_t)-1;
++ } else if (endptr == source_date_epoch) {
++ now = (time_t)-1;
++ } else if (*endptr != '\0') {
++ now = (time_t)-1;
++ } else if (epoch > ULONG_MAX) {
++ now = (time_t)-1;
++ } else {
++ now = (time_t)epoch;
++ }
++
++ return now;
++}
++
++
+
+ static int
+ wr_pre(void)
+@@ -1432,7 +1464,7 @@ wr_man_date(void)
+ char buf[32U];
+ int rc = 0;
+
+- if ((now = time(NULL)) == (time_t)-1) {
++ if ((now = get_current_time()) == (time_t)-1) {
+ rc = -1;
+ } else if ((tp = gmtime(&now)) == NULL) {
+ rc = -1;
--- a/debian/patches/series 2016-08-22 20:01:29.991392761 +0100
--- b/debian/patches/series 2016-08-22 20:17:05.127120394 +0100
@@ -1 +1,2 @@
0001-do-not-use-march-native-compiler-flags.diff
+0002-reproducible-build.diff
More information about the Reproducible-builds
mailing list