[Reproducible-commits] [texlive-bin] 01/01: Enhance SOURCE_DATE_EPOCH support (luatex, \today and others), adding patches honour-source-date-epoch-full, honour-source-date-epoch-luatex, honour-source-date-epoch-today

Alexis Bienvenüe jboulix-guest at moszumanska.debian.org
Fri May 6 23:03:30 UTC 2016


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

jboulix-guest pushed a commit to branch pu/reproducible_builds
in repository texlive-bin.

commit b396cecfde397111a845458f735ee488ca088c36
Author: Alexis Bienvenüe <pado at passoire.fr>
Date:   Sat May 7 01:00:22 2016 +0200

    Enhance SOURCE_DATE_EPOCH support (luatex, \today and others), adding patches
    honour-source-date-epoch-full, honour-source-date-epoch-luatex, honour-source-date-epoch-today
---
 debian/changelog                               |   7 ++
 debian/patches/honour-source-date-epoch-full   |  80 ++++++++++++++
 debian/patches/honour-source-date-epoch-luatex |  71 ++++++++++++
 debian/patches/honour-source-date-epoch-today  | 147 +++++++++++++++++++++++++
 debian/patches/series                          |   3 +
 5 files changed, 308 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index da163a3..170b14f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+texlive-bin (2015.20160222.37495-1.0~reproducible2) UNRELEASED; urgency=medium
+
+  * Add patches honour-source-date-epoch-today,
+    honour-source-date-epoch-full.
+
+ -- Alexis Bienvenüe <pado at passoire.fr>  Wed, 04 May 2016 11:50:15 +0200
+
 texlive-bin (2015.20160222.37495-1.0~reproducible1) UNRELEASED; urgency=medium
 
   [ akira ]
diff --git a/debian/patches/honour-source-date-epoch-full b/debian/patches/honour-source-date-epoch-full
new file mode 100644
index 0000000..28de343
--- /dev/null
+++ b/debian/patches/honour-source-date-epoch-full
@@ -0,0 +1,80 @@
+Description: Extended SOURCE_DATE_EPOCH support
+ Extend SOURCE_DATE_EPOCH support.
+ This patch is the TL2015 equivalent for upstream commit
+ https://www.tug.org/svn/texlive?view=revision&revision=40881
+Author: Alexis Bienvenüe <pado at passoire.fr>
+Forwarded: https://www.tug.org/pipermail/tex-live/2016-May/038339.html
+Applied-Upstream: https://www.tug.org/svn/texlive?view=revision&revision=40881
+
+--- texlive-bin-2015.20160222.37495.orig/texk/dvipdfm-x/pdfdoc.c
++++ texlive-bin-2015.20160222.37495/texk/dvipdfm-x/pdfdoc.c
+@@ -459,6 +459,39 @@ asn_date (char *date_string)
+   time_t      current_time;
+   struct tm  *bd_time;
+ 
++  char* source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++  unsigned long long epoch;
++  char *endptr;
++  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);
++        }
++      current_time = epoch;
++      bd_time = gmtime(&current_time);
++      tz_offset = 0;
++    }
++  else {
+   time(&current_time);
+   bd_time = localtime(&current_time);
+ 
+@@ -471,7 +504,8 @@ asn_date (char *date_string)
+   tz_offset = compute_timezone_offset();
+ #  endif /* HAVE_TIMEZONE */
+ #endif /* HAVE_TM_GMTOFF */
+-
++  }
++  
+   sprintf(date_string, "D:%04d%02d%02d%02d%02d%02d%c%02ld'%02ld'",
+ 	  bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday,
+ 	  bd_time->tm_hour, bd_time->tm_min, bd_time->tm_sec,
+--- texlive-bin-2015.20160222.37495.orig/texk/dvipdfm-x/xbb.c
++++ texlive-bin-2015.20160222.37495/texk/dvipdfm-x/xbb.c
+@@ -84,8 +84,15 @@ static void do_time(FILE *file)
+   time_t current_time;
+   struct tm *bd_time;
+ 
+-  time(&current_time);
+-  bd_time = localtime(&current_time);
++  char* source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++  unsigned long long epoch;
++  if(source_date_epoch) {
++    current_time = strtoull(source_date_epoch, NULL, 10);
++    bd_time = gmtime(&current_time);
++  } else {
++    time(&current_time);
++    bd_time = localtime(&current_time);
++  }
+   fprintf(file, "%%%%CreationDate: %s\n", asctime(bd_time));
+ }
+ 
diff --git a/debian/patches/honour-source-date-epoch-luatex b/debian/patches/honour-source-date-epoch-luatex
new file mode 100644
index 0000000..019e4f3
--- /dev/null
+++ b/debian/patches/honour-source-date-epoch-luatex
@@ -0,0 +1,71 @@
+Description: SOURCE_DATE_EPOCH support for luatex
+ Extend SOURCE_DATE_EPOCH support to luatex.
+Author: Alexis Bienvenüe <pado at passoire.fr>
+Forwarded: https://mailman.ntg.nl/pipermail/dev-luatex/2016-May/005700.html
+
+--- texlive-bin-2015.20160222.37495.orig/texk/web2c/luatexdir/luatex.c
++++ texlive-bin-2015.20160222.37495/texk/web2c/luatexdir/luatex.c
+@@ -877,8 +877,16 @@ static RETSIGTYPE catch_interrupt(int ar
+ 
+ void get_date_and_time(int *minutes, int *day, int *month, int *year)
+ {
+-    time_t myclock = time((time_t *) 0);
+-    struct tm *tmptr = localtime(&myclock);
++  char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++  struct tm *tmptr;
++  time_t myclock;
++  if(source_date_epoch) {
++    myclock = strtoull(source_date_epoch, NULL, 10);
++    tmptr = gmtime (&myclock);
++  } else {
++    myclock = time((time_t *) 0);
++    tmptr = localtime(&myclock);
++  }
+ 
+     *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
+     *day = tmptr->tm_mday;
+--- texlive-bin-2015.20160222.37495.orig/texk/web2c/luatexdir/pdf/pdfgen.w
++++ texlive-bin-2015.20160222.37495/texk/web2c/luatexdir/pdf/pdfgen.w
+@@ -1606,7 +1606,7 @@ static void print_ID(PDF pdf)
+ @c
+ #define TIME_STR_SIZE 30        /* minimum size for |time_str| is 24: |"D:YYYYmmddHHMMSS+HH'MM'"| */
+ 
+-static void makepdftime(PDF pdf)
++static void makepdftime(PDF pdf, int utc)
+ {
+     struct tm lt, gmt;
+     size_t size;
+@@ -1615,7 +1615,12 @@ static void makepdftime(PDF pdf)
+     char *time_str = pdf->start_time_str;
+ 
+     /* get the time */
+-    lt = *localtime(&t);
++    if (utc) {
++        lt = *gmtime(&t);
++    }
++    else {
++        lt = *localtime(&t);
++    }
+     size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", &lt);
+     /* expected format: "YYYYmmddHHMMSS" */
+     if (size == 0) {
+@@ -1660,10 +1665,17 @@ static void makepdftime(PDF pdf)
+ void init_start_time(PDF pdf)
+ {
+     assert(pdf);
++    char *source_date_epoch;
+     if (pdf->start_time == 0) {
+-        pdf->start_time = time((time_t *) NULL);
+         pdf->start_time_str = xtalloc(TIME_STR_SIZE, char);
+-        makepdftime(pdf);
++        source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++        if(source_date_epoch) {
++            pdf->start_time = strtoull(source_date_epoch, NULL, 10);
++            makepdftime(pdf,true);
++        } else {
++            pdf->start_time = time((time_t *) NULL);
++            makepdftime(pdf,false);
++        }
+     }
+ }
+ 
diff --git a/debian/patches/honour-source-date-epoch-today b/debian/patches/honour-source-date-epoch-today
new file mode 100644
index 0000000..b858ea8
--- /dev/null
+++ b/debian/patches/honour-source-date-epoch-today
@@ -0,0 +1,147 @@
+Description: Make \today honour SOURCE_DATE_EPOCH
+ Set \today value from SOURCE_DATE_EPOCH (if set).
+ See https://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20160404/005179.html
+ This is TL2015 equivalent (without SOURCE_DATE_EPOCH_TEX_PRIMITIVES) of
+ https://www.tug.org/svn/texlive?view=revision&revision=40889
+Author: Alexis Bienvenüe <pado at passoire.fr>
+Forwarded: https://www.tug.org/pipermail/tex-k/2016-May/002691.html
+Applied-Upstream: https://www.tug.org/svn/texlive?view=revision&revision=40889
+
+Index: texlive-bin-2015.20160222.37495/texk/web2c/lib/texmfmp.c
+===================================================================
+--- texlive-bin-2015.20160222.37495.orig/texk/web2c/lib/texmfmp.c
++++ texlive-bin-2015.20160222.37495/texk/web2c/lib/texmfmp.c
+@@ -2143,6 +2143,49 @@ catch_interrupt (int arg)
+ }
+ #endif /* not WIN32 */
+ 
++static boolean start_time_set = false;
++static time_t start_time = 0;
++
++void init_start_time() {
++  char *source_date_epoch;
++  unsigned long long epoch;
++  char *endptr;
++  if (!start_time_set) {
++    start_time_set = true;
++    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));
++            uexit(EXIT_FAILURE);
++          }
++        if (endptr == source_date_epoch)
++          {
++            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr);
++            uexit(EXIT_FAILURE);
++          }
++        if (*endptr != '\0')
++          {
++            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr);
++            uexit(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);
++            uexit(EXIT_FAILURE);
++          }
++        start_time = epoch;
++      }
++    else {
++      start_time = time((time_t *) NULL);
++    }
++  }
++}
++
+ /* Besides getting the date and time here, we also set up the interrupt
+    handler, for no particularly good reason.  It's just that since the
+    `fix_date_and_time' routine is called early on (section 1337 in TeX,
+@@ -2153,8 +2196,14 @@ void
+ get_date_and_time (integer *minutes,  integer *day,
+                    integer *month,  integer *year)
+ {
+-  time_t myclock = time ((time_t *) 0);
+-  struct tm *tmptr = localtime (&myclock);
++  struct tm *tmptr;
++  if(getenv("SOURCE_DATE_EPOCH")) {
++    init_start_time();
++    tmptr = gmtime (&start_time);
++  } else {
++    time_t myclock = time ((time_t *) 0);
++    tmptr = localtime (&myclock);
++  }
+ 
+   *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
+   *day = tmptr->tm_mday;
+@@ -2869,11 +2918,10 @@ void pdftex_fail(const char *fmt, ...)
+ }
+ #endif /* not pdfTeX */
+ 
+-static boolean start_time_set = false;
+-static time_t start_time = 0;
+ #define TIME_STR_SIZE 30
+ char start_time_str[TIME_STR_SIZE];
+-static char time_str[TIME_STR_SIZE];
++
++ static char time_str[TIME_STR_SIZE];
+     /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */
+ 
+ static void makepdftime(time_t t, char *time_str, int utc)
+@@ -2931,45 +2979,14 @@ static void makepdftime(time_t t, char *
+ 
+ void initstarttime(void)
+ {
+-	char *source_date_epoch;
+-	unsigned long long epoch;
+-	char *endptr;
+-    if (!start_time_set) {
+-        start_time_set = true;
+-	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));
+-			uexit(EXIT_FAILURE);
+-		}
+-		if (endptr == source_date_epoch)
+-		{
+-			fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr);
+-			uexit(EXIT_FAILURE);
+-		}
+-		if (*endptr != '\0')
+-		{
+-			fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr);
+-			uexit(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);
+-			uexit(EXIT_FAILURE);
+-		}
+-		start_time = epoch;
+-		makepdftime(start_time, start_time_str, 1);
+-	}
+-	else {
+-		start_time = time((time_t *) NULL);
+-		makepdftime(start_time, start_time_str, 0);
+-	}
++  if (!start_time_set) {
++    init_start_time();
++    if(getenv("SOURCE_DATE_EPOCH")) {
++      makepdftime(start_time, start_time_str, 1);
++    } else {
++      makepdftime(start_time, start_time_str, 0);
+     }
++  }
+ }
+ 
+ char *makecstring(integer s)
diff --git a/debian/patches/series b/debian/patches/series
index 539674a..f99a884 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -23,3 +23,6 @@ fix-format-gcc-errors
 fix-mktexlsr-bashims
 suppress-dvips-creationdate
 remove-timestamp-tex-preamble
+honour-source-date-epoch-today
+honour-source-date-epoch-full
+honour-source-date-epoch-luatex

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



More information about the Reproducible-commits mailing list