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