1
0

320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --- a/jffsX-utils/mkfs.jffs2.c
  2. +++ b/jffsX-utils/mkfs.jffs2.c
  3. @@ -109,7 +109,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;
  10. static uint32_t find_hardlink(struct filesystem_entry *e)
  11. @@ -250,8 +250,8 @@ static struct filesystem_entry *add_host
  12. mode &= ~(S_ISUID | S_ISGID);
  13. }
  14. }
  15. - if (fake_times) {
  16. - timestamp = 0;
  17. + if (fixed_timestamp != -1) {
  18. + timestamp = fixed_timestamp;
  19. }
  20. entry = xcalloc(1, sizeof(struct filesystem_entry));
  21. @@ -1557,6 +1557,20 @@ static void parse_image(void){
  22. close(in_fd);
  23. }
  24. +static void set_source_date_epoch() {
  25. + char *env = getenv("SOURCE_DATE_EPOCH");
  26. + char *endptr = env;
  27. + errno = 0;
  28. + if (env && *env) {
  29. + fixed_timestamp = strtoull(env, &endptr, 10);
  30. + if (errno || (endptr && *endptr != '\0')) {
  31. + fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
  32. + exit(1);
  33. + }
  34. + }
  35. +}
  36. +
  37. +
  38. int main(int argc, char **argv)
  39. {
  40. int c, opt;
  41. @@ -1575,6 +1589,7 @@ int main(int argc, char **argv)
  42. warn_page_size = 1; /* warn user if page size not 4096 */
  43. jffs2_compressors_init();
  44. + set_source_date_epoch();
  45. while ((opt = getopt_long(argc, argv,
  46. "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0)
  47. @@ -1625,7 +1640,7 @@ int main(int argc, char **argv)
  48. break;
  49. case 'f':
  50. - fake_times = 1;
  51. + fixed_timestamp = 0;
  52. break;
  53. case 'h':