[Reproducible-commits] [libxslt] 03/04: Honour SOURCE_DATE_EPOCH when embedding timestamps in docs

Mattia Rizzolo mattia at mapreri.org
Wed Nov 11 19:37:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

mapreri-guest pushed a commit to branch pu/reproducible_builds
in repository libxslt.

commit 7702038082fd8ac3c1458f9207c153c591dd8364
Author: Dhole <dhole at openmailbox.org>
Date:   Wed Jul 8 15:26:12 2015 +0200

    Honour SOURCE_DATE_EPOCH when embedding timestamps in docs
    
    Closes: #791815
---
 .../0010-Replace-timestamp-with-SOURCE_DATE_EPOCH  | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH b/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH
new file mode 100644
index 0000000..fb6c8b4
--- /dev/null
+++ b/debian/patches/0010-Replace-timestamp-with-SOURCE_DATE_EPOCH
@@ -0,0 +1,67 @@
+Description: Replace date timestamp by SOURCE_DATE_EPOCH env var
+Author: Dhole <dhole at openmailbox.org>
+Forwarded: no
+Bug-Debian: https://bugs.debian.org/791815
+
+---
+
+--- 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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/libxslt.git



More information about the Reproducible-commits mailing list