0001-mkstandalone-add-argument-fixed-time-to-override-mti.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 8dde1d7be2dd321a375570b7ff7e22bb01293044 Mon Sep 17 00:00:00 2001
  2. From: Alexander Couzens <lynxis@fe80.eu>
  3. Date: Fri, 4 Dec 2015 17:10:42 +0100
  4. Subject: [PATCH 08/10] mkstandalone: add argument --fixed-time to override
  5. mtime of files
  6. mkstandalone adds several files to an archive. Doing this it uses the
  7. mtime to give these files a timestamp.
  8. --fixed-time <TIME_EPOCH> overrides these timestamps with a given.
  9. Replacing all timestamps with a specific one is required
  10. to get reproducible builds. See source epoch specification of
  11. reproducible-builds.org
  12. ---
  13. util/grub-mkstandalone.c | 14 +++++++++++++-
  14. 1 file changed, 13 insertions(+), 1 deletion(-)
  15. diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
  16. index 4907d44..047f0cd 100644
  17. --- a/util/grub-mkstandalone.c
  18. +++ b/util/grub-mkstandalone.c
  19. @@ -30,6 +30,7 @@
  20. #pragma GCC diagnostic error "-Wmissing-prototypes"
  21. #pragma GCC diagnostic error "-Wmissing-declarations"
  22. +static time_t fixed_time;
  23. static char *output_image;
  24. static char **files;
  25. static int nfiles;
  26. @@ -48,6 +49,7 @@ static struct argp_option options[] = {
  27. 0, N_("save output in FILE [required]"), 2},
  28. {"format", 'O', N_("FILE"), 0, 0, 2},
  29. {"compression", 'C', "xz|none|auto", OPTION_HIDDEN, 0, 2},
  30. + {"fixed-time", 't', N_("TIMEEPOCH"), 0, N_("Use a fixed timestamp to override mtime of all files. Time since epoch is used."), 2},
  31. {0, 0, 0, 0, 0, 0}
  32. };
  33. @@ -72,6 +74,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
  34. static error_t
  35. argp_parser (int key, char *arg, struct argp_state *state)
  36. {
  37. + char *b;
  38. if (key == 'C')
  39. key = GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS;
  40. @@ -80,6 +83,14 @@ argp_parser (int key, char *arg, struct argp_state *state)
  41. switch (key)
  42. {
  43. + case 't':
  44. + fixed_time = strtoll (arg, &b, 10);
  45. + if (*b !='\0') {
  46. + printf (_("invalid fixed time number: %s\n"), arg);
  47. + argp_usage (state);
  48. + exit (1);
  49. + }
  50. + break;
  51. case 'o':
  52. if (output_image)
  53. @@ -192,7 +203,8 @@ add_tar_file (const char *from,
  54. if (grub_util_is_special_file (from))
  55. return;
  56. - mtime = grub_util_get_mtime (from);
  57. + /* use fixed_time if given for mtime */
  58. + mtime = fixed_time != -1 ? fixed_time : grub_util_get_mtime (from);
  59. optr = tcn = xmalloc (strlen (to) + 1);
  60. for (iptr = to; *iptr == '/'; iptr++);
  61. --
  62. 1.9.1