[xml/sgml-pkgs] Bug#791815: libxslt: please support timestamps from environment

Dhole dhole at openmailbox.org
Wed Jul 8 16:44:00 UTC 2015


Source: libxslt
Version: 1.1.28-2
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: toolchain timestamps

Hi!

While working on the “reproducible builds” effort [1], we have noticed
that libxslt embeds timestamps when generating documentation.

We have a proposal for using a deterministic timestamp [2] (based on
the latest debian/changelog entry) which is contained in the environment
variable SOURCE_DATE_EPOCH (currently exported by debhelper in our
experimental framework).

The attached patch proposes a way to use this variable to get
reproducible timestamps when generating docs, if the variable has been
set (if not, it falls back to the old behavior).


 [1]: https://wiki.debian.org/ReproducibleBuilds
 [2]: https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal

Regards,
-- 
Dhole
-------------- next part --------------
diff -Nru libxslt-1.1.28/debian/changelog libxslt-1.1.28/debian/changelog
--- libxslt-1.1.28/debian/changelog	2015-07-01 12:00:21.000000000 +0200
+++ libxslt-1.1.28/debian/changelog	2015-07-08 15:19:03.000000000 +0200
@@ -1,9 +1,14 @@
-libxslt (1.1.28-2.0~reproducible3) UNRELEASED; urgency=low
+libxslt (1.1.28-2.0~reproducible4) UNRELEASED; urgency=low
 
+  [ Jérémy Bobbio ]
   * Add a patch from Daniel Veillard to make generate-id() provide stable IDs
     to make its output reproducible.
 
- -- Jérémy Bobbio <lunar at debian.org>  Wed, 01 Jul 2015 11:49:58 +0200
+  [ Eduard Sanou ]
+  * Add support for reproducible builds by using $SOURCE_DATE_EPOCH as the
+    date when processing docs (when using the var $date).
+
+ -- Dhole <dhole at openmailbox.org>  Wed, 08 Jul 2015 15:05:07 +0200
 
 libxslt (1.1.28-2) unstable; urgency=low
 
diff -Nru libxslt-1.1.28/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH libxslt-1.1.28/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH
--- libxslt-1.1.28/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH	1970-01-01 01:00:00.000000000 +0100
+++ libxslt-1.1.28/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH	2015-07-08 15:18:26.000000000 +0200
@@ -0,0 +1,65 @@
+Description: Replace date timestamp by SOURCE_DATE_EPOCH env var
+Author: Dhole <dhole at openmailbox.org>
+
+---
+
+--- libxslt-1.1.28.orig/libexslt/date.c
++++ libxslt-1.1.28/libexslt/date.c
+@@ -46,6 +46,7 @@
+ #include "exslt.h"
+ 
+ #include <string.h>
++#include <errno.h>
+ 
+ #ifdef HAVE_MATH_H
+ #include <math.h>
+@@ -747,21 +748,46 @@ static exsltDateValPtr
+ exsltDateCurrent (void)
+ {
+     struct tm localTm, gmTm;
++    struct tm *tb = NULL;
+     time_t secs;
+     int local_s, gm_s;
+     exsltDateValPtr ret;
++    char *source_date_epoch;
+ 
+     ret = exsltDateCreateDate(XS_DATETIME);
+     if (ret == NULL)
+         return NULL;
+ 
+-    /* get current time */
+     secs    = time(NULL);
++    /* 
++     * 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;
++	secs = (time_t) strtol (source_date_epoch, NULL, 10);
++	if (errno == 0) {
++	    tb = gmtime(&secs);
++	    if (tb == NULL) {
++	    /* SOURCE_DATE_EPOCH is not a valid date */
++		return NULL;
++	    } else {
++		localTm = *tb;
++	    }
++	} else {
++	    /* SOURCE_DATE_EPOCH is not a valid number */
++	    return NULL;
++	} 
++    } else {
++	/* get current time */
+ #if HAVE_LOCALTIME_R
+-    localtime_r(&secs, &localTm);
++	localtime_r(&secs, &localTm);
+ #else
+-    localTm = *localtime(&secs);
++	localTm = *localtime(&secs);
+ #endif
++    }
++
+ 
+     /* get real year, not years since 1900 */
+     ret->value.date.year = localTm.tm_year + 1900;
diff -Nru libxslt-1.1.28/debian/patches/series libxslt-1.1.28/debian/patches/series
--- libxslt-1.1.28/debian/patches/series	2015-07-01 12:00:21.000000000 +0200
+++ libxslt-1.1.28/debian/patches/series	2015-07-08 15:13:19.000000000 +0200
@@ -7,3 +7,4 @@
 0007-EXSLT-function-str-replace-is-broken-as-is.patch
 0008-Fix-quoting-of-xlocale-test-program-in-configure.in.patch
 0009-Make-generate-id-deterministic.patch
+0010-Replace-timestamp-with-SOURCE_DATE_EPOCH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/debian-xml-sgml-pkgs/attachments/20150708/70b0d6d0/attachment.sig>


More information about the debian-xml-sgml-pkgs mailing list