[Reproducible-builds] Bug#792687: gettext: please support timestamps from environment

Dhole dhole at openmailbox.org
Wed Aug 5 18:15:49 UTC 2015


On 07/17/2015 04:08 PM, Dhole wrote:
> Source: gettext
> Version: 0.19.4-1
> Severity: wishlist
> Tags: patch
> User: reproducible-builds at lists.alioth.debian.org
> Usertags: toolchain timestamps
> X-Debbugs-Cc: reproducible-builds at lists.alioth.debian.org
> 
> Hi,
> 
> While working on the "reproducible builds" effort [1], we have noticed
> that the xgettext tool from gettext embeds timestamps on the creation of
> PO files.
> 
> For the Reproducible Builds effort we are proposing an environment
> variable (SOURCE_DATE_EPOCH) [2] that will contain a deterministic epoch
> timestamp (based on the latest debian/changelog entry) that could be
> used, which should be automatically exported by debhelper in the future [3].
> 
> The attached patch proposes a way to use this variable to get
> reproducible timestamps in the PO files generated by xgettext, if the
> variable has been set (if not, it falls back to the old behavior).
> With the attached patch packages using xgettext would then automatically
> generate reproducible translation files.
> 
> 
> [1]: https://wiki.debian.org/ReproducibleBuilds
> [2]: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
> [3]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=791815
> 
> Regards,
> 
> 
> 
> _______________________________________________
> Reproducible-builds mailing list
> Reproducible-builds at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds
> 

Hi

I'm attaching an update of the submitted patch targeting the latest
gettext version from Debian: 0.19.5.1-1

Regards,
-- 
Dhole
-------------- next part --------------
diff -Nru gettext-0.19.5.1/debian/changelog gettext-0.19.5.1/debian/changelog
--- gettext-0.19.5.1/debian/changelog	2015-08-02 21:41:33.000000000 +0200
+++ gettext-0.19.5.1/debian/changelog	2015-08-04 18:44:31.000000000 +0200
@@ -1,3 +1,11 @@
+gettext (0.19.5.1-1.0~reproducible1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add support for reproducible builds by using $SOURCE_DATE_EPOCH as the
+    date on creation of PO files with xgettext.
+
+ -- Eduard Sanou <dhole at openmailbox.org>  Tue, 04 Aug 2015 18:43:52 +0200
+
 gettext (0.19.5.1-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru gettext-0.19.5.1/debian/patches/04-Replace-timestamp-with-SOURCE_DATE_EPOCH gettext-0.19.5.1/debian/patches/04-Replace-timestamp-with-SOURCE_DATE_EPOCH
--- gettext-0.19.5.1/debian/patches/04-Replace-timestamp-with-SOURCE_DATE_EPOCH	1970-01-01 01:00:00.000000000 +0100
+++ gettext-0.19.5.1/debian/patches/04-Replace-timestamp-with-SOURCE_DATE_EPOCH	2015-08-04 18:46:17.000000000 +0200
@@ -0,0 +1,45 @@
+Description: Replace date timestamp by SOURCE_DATE_EPOCH env var in xgettext
+ .
+ gettext (0.19.5.1-1.0~reproducible1) UNRELEASED; urgency=medium
+ .
+   * Non-maintainer upload.
+   * Add support for reproducible builds by using $SOURCE_DATE_EPOCH as the
+     date on creation of PO files with xgettext.
+Author: Eduard Sanou <dhole at openmailbox.org>
+
+--- gettext-0.19.5.1.orig/gettext-tools/src/xgettext.c
++++ gettext-0.19.5.1/gettext-tools/src/xgettext.c
+@@ -3516,6 +3516,7 @@ construct_header ()
+   message_ty *mp;
+   char *msgstr;
+   char *comment;
++  char *source_date_epoch;
+   static lex_pos_ty pos = { __FILE__, __LINE__ };
+ 
+   if (package_name != NULL)
+@@ -3537,7 +3538,24 @@ the MSGID_BUGS_ADDRESS variable there; o
+ specify an --msgid-bugs-address command line option.\n\
+ ")));
+ 
+-  time (&now);
++  /* Allow the date and time to be set externally by an exported
++     environment variable to enable reproducible builds. */
++  source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
++  if (source_date_epoch)
++    {
++      errno = 0;
++      now = (time_t) strtol (source_date_epoch, NULL, 10);
++      if (errno != 0)
++        error (EXIT_FAILURE, errno, _("\
++SOURCE_DATE_EPOCH=\"%s\" is not a valid number"), source_date_epoch);
++
++      /* The function po_strftime uses localtime() to parse the timestamp, so 
++         we need to fix the environment timezone to get reproducible results */
++      setenv("TZ", "UTC", 1);
++    }
++  else
++    time (&now);
++
+   timestring = po_strftime (&now);
+ 
+   msgstr = xasprintf ("\
diff -Nru gettext-0.19.5.1/debian/patches/series gettext-0.19.5.1/debian/patches/series
--- gettext-0.19.5.1/debian/patches/series	2015-08-02 20:37:20.000000000 +0200
+++ gettext-0.19.5.1/debian/patches/series	2015-08-04 18:45:51.000000000 +0200
@@ -1,3 +1,4 @@
 01-do-not-use-java-in-urlget
 02-msgfmt-default-little-endian
 03-fix-gettextize-version
+04-Replace-timestamp-with-SOURCE_DATE_EPOCH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/reproducible-builds/attachments/20150805/78ed5482/attachment.sig>


More information about the Reproducible-builds mailing list