summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorkpcyrd <git@rxv.cc>2021-07-24 18:13:49 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-07-25 09:04:17 +0300
commit9e54fcf4be0d62e13e5a6fed481a1c08cd59c871 (patch)
treeae1b79d89f6d48f3b898a2baba768c6d44fe2cfb /src/common.c
parentc13969849d6d072c22ae4a2eddb40c0974b70a31 (diff)
downloadapk-tools-9e54fcf4be0d62e13e5a6fed481a1c08cd59c871.tar.gz
apk-tools-9e54fcf4be0d62e13e5a6fed481a1c08cd59c871.tar.bz2
apk-tools-9e54fcf4be0d62e13e5a6fed481a1c08cd59c871.tar.xz
apk-tools-9e54fcf4be0d62e13e5a6fed481a1c08cd59c871.zip
io_archive: Use SOURCE_DATE_EPOCH for meta files instead of current time
[TT: minor stylistic changes]
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 14a56a3..580e6d5 100644
--- a/src/common.c
+++ b/src/common.c
@@ -40,3 +40,18 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
return tmp;
}
+
+time_t apk_get_build_time(void)
+{
+ static int initialized = 0;
+ static time_t timestamp = 0;
+ char *source_date_epoch;
+
+ if (initialized) return timestamp;
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch && *source_date_epoch)
+ timestamp = strtoull(source_date_epoch, NULL, 10);
+ else timestamp = time(NULL);
+ initialized = 1;
+ return timestamp;
+}