io_archive: Use SOURCE_DATE_EPOCH for meta files instead of current time
[TT: minor stylistic changes]cute-signatures
parent
c1405f9311
commit
90228c4d26
|
@ -177,6 +177,8 @@ static inline uint32_t get_unaligned32(const void *ptr)
|
||||||
|
|
||||||
typedef void (*apk_progress_cb)(void *cb_ctx, size_t);
|
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);
|
void *apk_array_resize(void *array, size_t new_size, size_t elem_size);
|
||||||
|
|
||||||
#define APK_ARRAY(array_type_name, elem_type_name) \
|
#define APK_ARRAY(array_type_name, elem_type_name) \
|
||||||
|
|
15
src/common.c
15
src/common.c
|
@ -40,3 +40,18 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
|
||||||
|
|
||||||
return tmp;
|
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.uid, ae->uid);
|
||||||
PUT_OCTAL(buf.gid, ae->gid);
|
PUT_OCTAL(buf.gid, ae->gid);
|
||||||
PUT_OCTAL(buf.mode, ae->mode & 07777);
|
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 */
|
/* Checksum */
|
||||||
strcpy(buf.magic, "ustar ");
|
strcpy(buf.magic, "ustar ");
|
||||||
|
|
Loading…
Reference in New Issue