Source: gnupg
Version: 1.4.19-6
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi,

Whilst working on the "reproducible builds" effort [0], we noticed that
gnupg could not be built reproducibly.

The attached patch removes timestamps from the "yat2m" manpage
generator. Once applied, gnupg can be built reproducibly using our
reproducible toolchain.

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


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/0010-yat2m-source-date-epoch.patch 1970-01-01 
02:00:00.000000000 +0200
--- b/debian/patches/0010-yat2m-source-date-epoch.patch 2015-11-27 
23:40:28.619516450 +0200
@@ -0,0 +1,45 @@
+--- gnupg-1.4.19.orig/doc/yat2m.c
++++ gnupg-1.4.19/doc/yat2m.c
+@@ -102,6 +102,7 @@
+ #include <assert.h>
+ #include <ctype.h>
+ #include <time.h>
++#include <limits.h>
+ 
+ 
+ #define PGM "yat2m"
+--- gnupg-1.4.19.orig/doc/yat2m.c
++++ gnupg-1.4.19/doc/yat2m.c
+@@ -324,6 +324,32 @@ isodatestring (void)
+   static char buffer[11+5];
+   struct tm *tp;
+   time_t atime = time (NULL);
++  char *endptr;
++  char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++  unsigned long long epoch;
++
++  if (source_date_epoch) {
++    errno = 0;
++    epoch = strtoull(source_date_epoch, &endptr, 10);
++    if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
++        || (errno != 0 && epoch == 0)) {
++      fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: strtoull: 
%s\n", strerror(errno));
++      exit(EXIT_FAILURE);
++    }
++    if (endptr == source_date_epoch) {
++      fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits 
were found: %s\n", endptr);
++      exit(EXIT_FAILURE);
++    }
++    if (*endptr != '\0') {
++      fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing 
garbage: %s\n", endptr);
++      exit(EXIT_FAILURE);
++    }
++    if (epoch > ULONG_MAX) {
++      fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be 
smaller than or equal to: %lu but was found to be: %llu \n", ULONG_MAX  ,epoch);
++      exit(EXIT_FAILURE);
++    }
++    atime = epoch;
++  }
+ 
+   if (atime < 0)
+     strcpy (buffer, "????" "-??" "-??");
--- a/debian/patches/series     2015-11-27 23:13:53.501216055 +0200
--- b/debian/patches/series     2015-11-27 23:42:12.260174185 +0200
@@ -7,3 +7,4 @@
 0007-Pass-DBUS_SESSION_BUS_ADDRESS-for-gnome3.patch
 0008-gpg-Silence-a-compiler-warning.patch
 0009-po-Fix-Spanish-translation.patch
+0010-yat2m-source-date-epoch.patch
_______________________________________________
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