blob: 6ce8445e831fb9bb9ece3578ce9f39e304cc759d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
From 501ae4e93fd6fa2f7d20d00d1b011f9006802eae Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
Date: Fri, 3 May 2019 16:32:24 +0200
Subject: [PATCH] Override mtime with zip -X
with SOURCE_DATE_EPOCH
to allow for reproducible builds of .zip files
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.
Uses clamping to keep older mtimes than SOURCE_DATE_EPOCH intact.
---
zipup.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/zipup.c
+++ b/zipup.c
@@ -414,6 +414,7 @@ struct zlist far *z; /* zip entry to
ush tempcext = 0;
char *tempextra = NULL;
char *tempcextra = NULL;
+ const char *source_date_epoch;
#ifdef WINDLL
@@ -674,6 +675,13 @@ struct zlist far *z; /* zip entry to
} /* strcmp(z->name, "-") == 0 */
+ if (extra_fields == 0 && (source_date_epoch = getenv("SOURCE_DATE_EPOCH")) != NULL) {
+ time_t epoch = strtoull(source_date_epoch, NULL, 10);
+ if (epoch > 0) {
+ ulg epochtim = unix2dostime(&epoch);
+ if (z->tim > epochtim) z->tim = epochtim;
+ }
+ }
if (extra_fields == 2) {
unsigned len;
char *p;
|