ghostscript/0001-mkromfs-make-build-reproducible-use-buildtime-from-S.patch
2017-01-30 13:16:52 +00:00

50 lines
1.7 KiB
Diff

From 495b79d8e9a44ad0ada965add3a046120646e7e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=83=C2=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Thu, 12 Jan 2017 18:04:57 +0100
Subject: [PATCH 1/2] mkromfs: make build reproducible, use buildtime from
SOURCE_DATE_EPOCH
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The environment variable SOURCE_DATE_EPOCH is the common approach for
getting reproducible timestamps and thus builds. In case the variable
is not set, keep using the current time of the mkromfs run.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
base/mkromfs.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/base/mkromfs.c b/base/mkromfs.c
index b7bc6bf..9b81c46 100644
--- a/base/mkromfs.c
+++ b/base/mkromfs.c
@@ -2280,6 +2280,8 @@ main(int argc, char *argv[])
int compaction = 0;
Xlist_element *Xlist_scan = NULL, *Xlist_head = NULL;
char pa[PATH_STR_LEN];
+ time_t buildtime = 0;
+ char* env_source_date_epoch;
memset(pa, 0x00, PATH_STR_LEN);
@@ -2336,7 +2338,13 @@ main(int argc, char *argv[])
#endif
fprintf(out,"\n#include \"stdint_.h\"\n");
fprintf(out,"\n#include \"time_.h\"\n\n");
- fprintf(out," time_t gs_romfs_buildtime = %ld;\n\n", time(NULL));
+
+ if ((env_source_date_epoch = getenv("SOURCE_DATE_EPOCH"))) {
+ buildtime = strtoul(env_source_date_epoch, NULL, 10);
+ }
+ if (!buildtime)
+ buildtime = time(NULL);
+ fprintf(out," time_t gs_romfs_buildtime = %ld;\n\n", buildtime);
/* process the remaining arguments (options interspersed with paths) */
for (; atarg < argc; atarg++) {
--
2.11.0