Skip to content
Snippets Groups Projects
Commit 90228c4d authored by kpcyrd's avatar kpcyrd Committed by Timo Teräs
Browse files

io_archive: Use SOURCE_DATE_EPOCH for meta files instead of current time

[TT: minor stylistic changes]
parent c1405f93
No related branches found
No related tags found
No related merge requests found
Pipeline #88548 passed
......@@ -177,6 +177,8 @@ static inline uint32_t get_unaligned32(const void *ptr)
typedef void (*apk_progress_cb)(void *cb_ctx, size_t);
time_t apk_get_build_time(void);
void *apk_array_resize(void *array, size_t new_size, size_t elem_size);
#define APK_ARRAY(array_type_name, elem_type_name) \
......
......@@ -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;
}
......@@ -291,7 +291,7 @@ int apk_tar_write_entry(struct apk_ostream *os, const struct apk_file_info *ae,
PUT_OCTAL(buf.uid, ae->uid);
PUT_OCTAL(buf.gid, ae->gid);
PUT_OCTAL(buf.mode, ae->mode & 07777);
PUT_OCTAL(buf.mtime, ae->mtime ?: time(NULL));
PUT_OCTAL(buf.mtime, ae->mtime ?: apk_get_build_time());
/* Checksum */
strcpy(buf.magic, "ustar ");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment