diff options
author | Sungbo Eo <mans0n@gorani.run> | 2022-02-12 17:01:31 +0900 |
---|---|---|
committer | Sungbo Eo <mans0n@gorani.run> | 2022-03-09 15:38:23 +0900 |
commit | 39d06472eb93d72940b2728d33e2dafa2676e47b (patch) | |
tree | ec8e96487b6e9f2e7a830533c90b310ba6cf8f2e /tools/zip/patches/011-reproducible-mtime.patch | |
parent | e42764cc5fa364e9fa553903c56191484738965e (diff) | |
download | upstream-39d06472eb93d72940b2728d33e2dafa2676e47b.tar.gz upstream-39d06472eb93d72940b2728d33e2dafa2676e47b.tar.bz2 upstream-39d06472eb93d72940b2728d33e2dafa2676e47b.zip |
tools: zip: fetch SOURCE_DATE_EPOCH directly
Remove "--mtime" option introduced in commit 18c9faa03211 ("tools: zip:
add option for reproducible archives") and instead fetch SOURCE_DATE_EPOCH
environment variable directly in the code.
Ref: https://sourceforge.net/p/infozip/patches/25/
Signed-off-by: Sungbo Eo <mans0n@gorani.run>
Diffstat (limited to 'tools/zip/patches/011-reproducible-mtime.patch')
-rw-r--r-- | tools/zip/patches/011-reproducible-mtime.patch | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/zip/patches/011-reproducible-mtime.patch b/tools/zip/patches/011-reproducible-mtime.patch new file mode 100644 index 0000000000..6ce8445e83 --- /dev/null +++ b/tools/zip/patches/011-reproducible-mtime.patch @@ -0,0 +1,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; |