aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard M. Wiedemann <bwiedemann@suse.de>2023-10-23 09:12:42 +0000
committerAlexey Kardashevskiy <aik@ozlabs.ru>2023-11-15 18:26:10 +1100
commit08bc29fba8f2e660e454c9e93ab44b558d109498 (patch)
tree84c71a7fab4b8a0d883f149791bd6c0bdb4cf64a
parent3a259df2449fc4a4e43ab5f33f0b2c66484b4bc3 (diff)
downloadSLOF-08bc29fba8f2e660e454c9e93ab44b558d109498.zip
SLOF-08bc29fba8f2e660e454c9e93ab44b558d109498.tar.gz
SLOF-08bc29fba8f2e660e454c9e93ab44b558d109498.tar.bz2
Allow to override build date with SOURCE_DATE_EPOCH
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. Without this patch, openSUSE's qemu package always varied between builds. This patch was done while working on reproducible builds for openSUSE. This is an alternative to https://lists.ozlabs.org/pipermail/slof/2023-October/002895.html Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r--romfs/tools/create_crc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/romfs/tools/create_crc.c b/romfs/tools/create_crc.c
index abc373b..4a30e48 100644
--- a/romfs/tools/create_crc.c
+++ b/romfs/tools/create_crc.c
@@ -95,7 +95,13 @@ createHeaderImage(int notime)
if (!notime) {
/* read time and write it into data stream */
- if ((caltime = time(NULL)) == -1) {
+ char *source_date_epoch;
+ /* This assumes that (if set) the SOURCE_DATE_EPOCH environment variable
+ will contain a correct, positive integer in the time_t range */
+ if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
+ (caltime = (time_t)strtoll(source_date_epoch, NULL, 10)) <= 0)
+ caltime = time(NULL);
+ if (caltime == -1) {
printf("time error\n");
}
if ((tm = localtime(&caltime)) == NULL) {