3 @@ -108,7 +108,7 @@ static char *rootdir = default_rootdir;
4 static int verbose = 0;
5 static int squash_uids = 0;
6 static int squash_perms = 0;
7 -static int fake_times = 0;
8 +static time_t fixed_timestamp = -1;
9 int target_endian = __BYTE_ORDER;
11 uint32_t find_hardlink(struct filesystem_entry *e)
12 @@ -249,8 +249,8 @@ static struct filesystem_entry *add_host
13 mode &= ~(S_ISUID | S_ISGID);
18 + if (fixed_timestamp != -1) {
19 + timestamp = fixed_timestamp;
22 entry = xcalloc(1, sizeof(struct filesystem_entry));
23 @@ -1554,6 +1554,20 @@ void parse_image(){
27 +static void set_source_date_epoch() {
28 + char *env = getenv("SOURCE_DATE_EPOCH");
32 + fixed_timestamp = strtoull(env, &endptr, 10);
33 + if (errno || (endptr && *endptr != '\0')) {
34 + fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
41 int main(int argc, char **argv)
44 @@ -1572,6 +1586,7 @@ int main(int argc, char **argv)
45 warn_page_size = 1; /* warn user if page size not 4096 */
47 jffs2_compressors_init();
48 + set_source_date_epoch();
50 while ((opt = getopt_long(argc, argv,
51 "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0)
52 @@ -1622,7 +1637,7 @@ int main(int argc, char **argv)
57 + fixed_timestamp = 0;