Source: transfig Version: 1:3.2.5.e-5 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: toolchain X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org
Dear Maintainer, While working on the “reproducible builds” effort [1], we have noticed that some packages (like kannel) use fig2dev in their building process, resulting in timestamps in postscript files that break reproducibility. To solve this kind of issues, it would be nice to have transfig support the SOURCE_DATE_EPOCH environment variable [2]. See the attached patch for a solution to this issue. Regards, Alexis Bienvenüe. [1] https://wiki.debian.org/ReproducibleBuilds [2] https://reproducible-builds.org/specs/source-date-epoch/
diff -Nru transfig-3.2.5.e/debian/changelog transfig-3.2.5.e/debian/changelog --- transfig-3.2.5.e/debian/changelog 2016-01-30 11:49:30.000000000 +0100 +++ transfig-3.2.5.e/debian/changelog 2016-04-03 16:42:27.000000000 +0200 @@ -1,3 +1,9 @@ +transfig (1:3.2.5.e-5.0~reproducible1) unstable; urgency=medium + + * Honour SOURCE_DATE_EPOCH environment variable + + -- Alexis Bienvenüe <p...@passoire.fr> Sun, 03 Apr 2016 16:42:27 +0200 + transfig (1:3.2.5.e-5) unstable; urgency=medium * Upgrade to Standards-Version 3.9.6 (no changes). diff -Nru transfig-3.2.5.e/debian/patches/33_honour_SOURCE_DATE_EPOCH.patch transfig-3.2.5.e/debian/patches/33_honour_SOURCE_DATE_EPOCH.patch --- transfig-3.2.5.e/debian/patches/33_honour_SOURCE_DATE_EPOCH.patch 1970-01-01 01:00:00.000000000 +0100 +++ transfig-3.2.5.e/debian/patches/33_honour_SOURCE_DATE_EPOCH.patch 2016-04-03 19:11:44.000000000 +0200 @@ -0,0 +1,147 @@ +Description: Honour SOURCE_DATE_EPOCH variable + Honour SOURCE_DATE_EPOCH environment variable when creating + PS and pictex files. +Author: Alexis Bienvenüe <p...@passoire.fr> + +Index: transfig-3.2.5.e/fig2dev/dev/genpictex.c +=================================================================== +--- transfig-3.2.5.e.orig/fig2dev/dev/genpictex.c ++++ transfig-3.2.5.e/fig2dev/dev/genpictex.c +@@ -125,7 +125,6 @@ genpictex_start(objects) + F_compound *objects; + { + char host[256]; +- time_t when; + struct passwd *who; + + texfontsizes[0] = texfontsizes[1] = +@@ -135,12 +134,11 @@ F_compound *objects; + + /* announce filename, version etc */ + +- (void) time(&when); + fprintf(tfp, "%%Title: %s\n", + (name? name: ((from) ? from : "stdin"))); + fprintf(tfp, "%%%%Created by: %s Version %s Patchlevel %s\n", + prog, VERSION, PATCHLEVEL); +- fprintf(tfp, "%%%%CreationDate: %s", ctime(&when)); ++ fprintf(tfp, "%%%%CreationDate: %s", creation_date()); + if (gethostname(host, sizeof(host)) == -1) + (void)strcpy(host, "unknown-host!?!?"); + if ( !anonymous) { +Index: transfig-3.2.5.e/fig2dev/dev/genps.c +=================================================================== +--- transfig-3.2.5.e.orig/fig2dev/dev/genps.c ++++ transfig-3.2.5.e/fig2dev/dev/genps.c +@@ -456,7 +456,6 @@ F_compound *objects; + { + char host[256]; + struct passwd *who; +- time_t when; + int itmp, jtmp; + int i; + int cliplx, cliply, clipux, clipuy; +@@ -626,12 +625,11 @@ F_compound *objects; + + if (gethostname(host, sizeof(host)) == -1) + (void)strcpy(host, "unknown-host!?!?"); +- (void) time(&when); + fprintf(tfp, "%%%%Title: %s\n", + (name? name: ((from) ? from : "stdin"))); + fprintf(tfp, "%%%%Creator: %s Version %s Patchlevel %s\n", + prog, VERSION, PATCHLEVEL); +- fprintf(tfp, "%%%%CreationDate: %s", ctime(&when)); ++ fprintf(tfp, "%%%%CreationDate: %s", creation_date()); + if ( !anonymous) { + who = getpwuid(getuid()); + if (who) +Index: transfig-3.2.5.e/fig2dev/dev/readjpg.c +=================================================================== +--- transfig-3.2.5.e.orig/fig2dev/dev/readjpg.c ++++ transfig-3.2.5.e/fig2dev/dev/readjpg.c +@@ -92,7 +92,6 @@ void + JPEGtoPS(char *jpegfile, FILE *PSfile) { + imagedata *JPEG; + size_t n; +- time_t t; + int i, filtype; + char realname[PATH_MAX]; + +@@ -101,13 +100,11 @@ JPEGtoPS(char *jpegfile, FILE *PSfile) { + /* reopen the file */ + JPEG->fp = open_picfile(jpegfile, &filtype, True, realname); + +- time(&t); +- + /* produce EPS header comments */ + fprintf(PSfile, "%%!PS-Adobe-3.0 EPSF-3.0\n"); + fprintf(PSfile, "%%%%Creator: jpeg2ps %s by Thomas Merz\n", VERSION); + fprintf(PSfile, "%%%%Title: %s\n", JPEG->filename); +- fprintf(PSfile, "%%%%CreationDate: %s", ctime(&t)); ++ fprintf(PSfile, "%%%%CreationDate: %s", creation_date()); + fprintf(PSfile, "%%%%BoundingBox: %d %d %d %d\n", + 0, 0, JPEG->width, JPEG->height); + fprintf(PSfile, "%%%%DocumentData: %s\n", +Index: transfig-3.2.5.e/fig2dev/fig2dev.c +=================================================================== +--- transfig-3.2.5.e.orig/fig2dev/fig2dev.c ++++ transfig-3.2.5.e/fig2dev/fig2dev.c +@@ -31,6 +31,8 @@ + #include "drivers.h" + #include "bound.h" + #include "read.h" ++#include <errno.h> ++#include <limits.h> + + extern int fig_getopt(); + extern char *optarg; +@@ -889,3 +891,40 @@ gs_broken_pipe(int sig) + exit(1); + } + ++char* ++creation_date() ++{ ++ struct tm *build_time; ++ time_t now; ++ char *source_date_epoch; ++ unsigned long long epoch; ++ char *endptr; ++ ++ source_date_epoch = getenv("SOURCE_DATE_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); ++ } ++ now = epoch; ++ return(asctime(gmtime(&now))); ++ } else { ++ time(&now); ++ return(ctime(&now)); ++ } ++} +Index: transfig-3.2.5.e/fig2dev/fig2dev.h +=================================================================== +--- transfig-3.2.5.e.orig/fig2dev/fig2dev.h ++++ transfig-3.2.5.e/fig2dev/fig2dev.h +@@ -229,3 +229,4 @@ typedef struct _point + int x,y; + } Point; + ++extern char* creation_date(); diff -Nru transfig-3.2.5.e/debian/patches/series transfig-3.2.5.e/debian/patches/series --- transfig-3.2.5.e/debian/patches/series 2014-08-26 10:06:06.000000000 +0200 +++ transfig-3.2.5.e/debian/patches/series 2016-04-01 17:00:02.000000000 +0200 @@ -18,3 +18,4 @@ 30_fprintf_format.patch 31_index_not_static.patch 32_dev_Imake_typo.patch +33_honour_SOURCE_DATE_EPOCH.patch