Source: gnuplot Version: 5.0.3+dfsg3-5 Severity: wishlist Tags: upstream User: reproducible-bui...@lists.alioth.debian.org Usertags: timestamps username environment X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org Control: block -1 by 827187
Dear Maintainer, While working on the "reproducible builds" effort [1], we have noticed that gnuplot has following reproducibility issues : * gnuplot embeds timestamps in its ps output. When the SOURCE_DATE_EPOCH environment variable [2] is set, it can be used to make the output reproducible. See 13_honour_SOURCE_DATE_EPOCH.patch * gnuplot embeds the username in its ps output. I think the unix username is not usefull in this output, and can be stripped. See 14_strip_username_from_output.patch - maybe it is possible to strip it only if SOURCE_DATE_EPOCH is set if this username is considered to be relevant here. * The SHELL used when building gnuplot is recorded in the Makefiles included in gnuplot-doc. I think /bin/sh can always be used instead. See changes with override_dh_auto_configure Once these patches are applied, and once https://bugs.debian.org/827187 is fixed, gnuplot can be built reproducibly in our current experimental framework. Regards, Alexis Bienvenüe. [1] https://wiki.debian.org/ReproducibleBuilds [2] https://reproducible-builds.org/specs/source-date-epoch/
diff -Nru gnuplot-5.0.3+dfsg3/debian/changelog gnuplot-5.0.3+dfsg3/debian/changelog --- gnuplot-5.0.3+dfsg3/debian/changelog 2016-06-10 20:03:10.000000000 +0200 +++ gnuplot-5.0.3+dfsg3/debian/changelog 2016-06-13 17:01:48.000000000 +0200 @@ -1,3 +1,9 @@ +gnuplot (5.0.3+dfsg3-5.0~reproducible1) UNRELEASED; urgency=medium + + * Make the build reproducible. + + -- Alexis Bienvenüe <p...@passoire.fr> Mon, 13 Jun 2016 17:01:48 +0200 + gnuplot (5.0.3+dfsg3-5) unstable; urgency=medium [ Sven Joachim ] diff -Nru gnuplot-5.0.3+dfsg3/debian/patches/13_honour_SOURCE_DATE_EPOCH.patch gnuplot-5.0.3+dfsg3/debian/patches/13_honour_SOURCE_DATE_EPOCH.patch --- gnuplot-5.0.3+dfsg3/debian/patches/13_honour_SOURCE_DATE_EPOCH.patch 1970-01-01 01:00:00.000000000 +0100 +++ gnuplot-5.0.3+dfsg3/debian/patches/13_honour_SOURCE_DATE_EPOCH.patch 2016-06-13 17:00:49.000000000 +0200 @@ -0,0 +1,57 @@ +Description: Honour SOURCE_DATE_EPOCH + Get date from the environment variable SOURCE_DATE_EPOCH (when set), + to build output timestamps. + See https://reproducible-builds.org/specs/source-date-epoch/ +Author: Alexis Bienvenüe <p...@passoire.fr> + +--- gnuplot-5.0.3+dfsg3.orig/term/post.trm ++++ gnuplot-5.0.3+dfsg3/term/post.trm +@@ -1657,15 +1657,45 @@ end\n\ + int i; + time_t now; + char *timedate; +- ++ char *source_date_epoch; ++ unsigned long long epoch; ++ char *endptr; ++ + ps_common_uses_fonts = uses_fonts; + ps_common_xoff = xoff; + ps_common_yoff = yoff; + + ps_page = 0; + +- time(&now); +- timedate=asctime(localtime(&now)); ++ /* get source date from environment variable SOURCE_DATE_EPOCH, if set. ++ See https://reproducible-builds.org/specs/source-date-epoch/ */ ++ 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; ++ timedate=asctime(gmtime(&now)); ++ } else { ++ time(&now); ++ timedate=asctime(localtime(&now)); ++ } + timedate[strlen(timedate)-1]='\0'; + + #ifdef PSLATEX_DRIVER diff -Nru gnuplot-5.0.3+dfsg3/debian/patches/14_strip_username_from_output.patch gnuplot-5.0.3+dfsg3/debian/patches/14_strip_username_from_output.patch --- gnuplot-5.0.3+dfsg3/debian/patches/14_strip_username_from_output.patch 1970-01-01 01:00:00.000000000 +0100 +++ gnuplot-5.0.3+dfsg3/debian/patches/14_strip_username_from_output.patch 2016-06-13 17:00:49.000000000 +0200 @@ -0,0 +1,36 @@ +Description: Strip username from output + Strip username from output to make it reproducible. +Author: Alexis Bienvenüe <p...@passoire.fr> + +Index: gnuplot-5.0.3+dfsg3/term/post.trm +=================================================================== +--- gnuplot-5.0.3+dfsg3.orig/term/post.trm ++++ gnuplot-5.0.3+dfsg3/term/post.trm +@@ -1644,7 +1644,6 @@ SDict begin [\n\ + /Title (%s)\n\ + /Subject (gnuplot plot)\n\ + /Creator (gnuplot %s patchlevel %s)\n\ +- /Author (%s)\n\ + %% /Producer (gnuplot)\n\ + %% /Keywords ()\n\ + /CreationDate (%s)\n\ +@@ -1821,18 +1820,11 @@ end\n\ + + /* HH: print pdf information interpreted by ghostscript/acrobat */ + { +- char *username=getusername(); +- char *username2=PS_escape_string(username,"()\\"); + char *outstr2=PS_escape_string(outstr,"()\\"); + fprintf(gppsfile, psi3, + outstr2?outstr2:"", +- gnuplot_version, gnuplot_patchlevel, +- username2?username2:"", ++ gnuplot_version, gnuplot_patchlevel, + timedate); +- if (username) +- free(username); +- if (username2) +- free(username2); + if (outstr2) + free(outstr2); + } diff -Nru gnuplot-5.0.3+dfsg3/debian/patches/series gnuplot-5.0.3+dfsg3/debian/patches/series --- gnuplot-5.0.3+dfsg3/debian/patches/series 2016-02-22 18:58:53.000000000 +0100 +++ gnuplot-5.0.3+dfsg3/debian/patches/series 2016-06-13 17:00:49.000000000 +0200 @@ -6,3 +6,5 @@ 10_removepicins.patch 11_fix_linkage_wx.patch 12_info.patch +13_honour_SOURCE_DATE_EPOCH.patch +14_strip_username_from_output.patch diff -Nru gnuplot-5.0.3+dfsg3/debian/rules gnuplot-5.0.3+dfsg3/debian/rules --- gnuplot-5.0.3+dfsg3/debian/rules 2016-06-09 22:22:41.000000000 +0200 +++ gnuplot-5.0.3+dfsg3/debian/rules 2016-06-13 17:00:49.000000000 +0200 @@ -35,11 +35,11 @@ override_dh_auto_configure: mkdir -p $(BUILDDIR_NOX) - cd $(BUILDDIR_NOX); ./../../configure $(conf_opts) --with-qt=no --without-x --disable-wxwidgets + cd $(BUILDDIR_NOX); CONFIG_SHELL=/bin/sh ./../../configure $(conf_opts) --with-qt=no --without-x --disable-wxwidgets mkdir -p $(BUILDDIR_X11) - cd $(BUILDDIR_X11); ../../configure $(conf_opts) --with-qt=no --with-tutorial + cd $(BUILDDIR_X11); CONFIG_SHELL=/bin/sh ../../configure $(conf_opts) --with-qt=no --with-tutorial mkdir -p $(BUILDDIR_QT) - cd $(BUILDDIR_QT); ../../configure $(conf_opts) --enable-qt + cd $(BUILDDIR_QT); CONFIG_SHELL=/bin/sh ../../configure $(conf_opts) --enable-qt override_dh_auto_build: dh_auto_build -a -- -C $(BUILDDIR_NOX)/src