GNU bug report logs - #32342
[PATCH] Do not store mtime when compressing stdin

Previous Next

Package: gzip;

Reported by: "Bernhard M. Wiedemann" <bwiedemann <at> suse.de>

Date: Wed, 1 Aug 2018 11:53:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 32342 <at> debbugs.gnu.org (full text, mbox):

From: "Bernhard M. Wiedemann" <bwiedemann <at> suse.de>
To: 32342 <at> debbugs.gnu.org
Cc: "Bernhard M. Wiedemann" <bwiedemann <at> suse.de>
Subject: [PATCH] Allow to override time_stamp with SOURCE_DATE_EPOCH
Date: Thu,  2 Aug 2018 11:03:59 +0200
in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

---
1st draft: probably has some year-2038 problems left
---
 zip.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/zip.c b/zip.c
index 337932c..b5c8867 100644
--- a/zip.c
+++ b/zip.c
@@ -19,6 +19,7 @@
 
 #include <config.h>
 #include <ctype.h>
+#include <stdlib.h>
 
 #include "tailor.h"
 #include "gzip.h"
@@ -34,6 +35,7 @@ off_t header_bytes;   /* number of bytes in gzip header */
 int zip(in, out)
     int in, out;            /* input and output file descriptors */
 {
+    char *source_date_epoch;
     uch  flags = 0;         /* general purpose bit flags */
     ush  attr = 0;          /* ascii/binary flag */
     ush  deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */
@@ -57,7 +59,10 @@ int zip(in, out)
     if (time_stamp.tv_nsec < 0)
       stamp = 0;
     else if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff)
-      stamp = time_stamp.tv_sec;
+      {
+        if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || (stamp = strtol(source_date_epoch, NULL, 10)) <= 0)
+          stamp = time_stamp.tv_sec;
+      }
     else
       {
         /* It's intended that timestamp 0 generates this warning,
-- 
2.16.4





This bug report was last modified 6 years and 344 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.