1 From 501ae4e93fd6fa2f7d20d00d1b011f9006802eae Mon Sep 17 00:00:00 2001
2 From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
3 Date: Fri, 3 May 2019 16:32:24 +0200
4 Subject: [PATCH] Override mtime with zip -X
7 to allow for reproducible builds of .zip files
9 See https://reproducible-builds.org/ for why this is good
10 and https://reproducible-builds.org/specs/source-date-epoch/
11 for the definition of this variable.
13 Uses clamping to keep older mtimes than SOURCE_DATE_EPOCH intact.
16 1 file changed, 8 insertions(+)
20 @@ -414,6 +414,7 @@ struct zlist far *z; /* zip entry to
22 char *tempextra = NULL;
23 char *tempcextra = NULL;
24 + const char *source_date_epoch;
28 @@ -674,6 +675,13 @@ struct zlist far *z; /* zip entry to
30 } /* strcmp(z->name, "-") == 0 */
32 + if (extra_fields == 0 && (source_date_epoch = getenv("SOURCE_DATE_EPOCH")) != NULL) {
33 + time_t epoch = strtoull(source_date_epoch, NULL, 10);
35 + ulg epochtim = unix2dostime(&epoch);
36 + if (z->tim > epochtim) z->tim = epochtim;
39 if (extra_fields == 2) {