0002-mkrescue-add-argument-fixed-time-to-get-reproducible.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From 0f1e1a29d4d019e7b2b1a3ac3db7ca22c75e8d88 Mon Sep 17 00:00:00 2001
  2. From: Alexander Couzens <lynxis@fe80.eu>
  3. Date: Fri, 4 Dec 2015 17:10:43 +0100
  4. Subject: [PATCH 09/10] mkrescue: add argument --fixed-time to get reproducible
  5. uuids
  6. The uuid generation is based on the time.
  7. ---
  8. util/grub-mkrescue.c | 15 ++++++++++++++-
  9. 1 file changed, 14 insertions(+), 1 deletion(-)
  10. diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
  11. index 238d484..a3e0155 100644
  12. --- a/util/grub-mkrescue.c
  13. +++ b/util/grub-mkrescue.c
  14. @@ -52,6 +52,7 @@ static int xorriso_arg_alloc;
  15. static char **xorriso_argv;
  16. static char *iso_uuid;
  17. static char *iso9660_dir;
  18. +static time_t fixed_time;
  19. static void
  20. xorriso_push (const char *val)
  21. @@ -110,6 +111,7 @@ static struct argp_option options[] = {
  22. {"product-version", OPTION_PRODUCT_VERSION, N_("STRING"), 0, N_("use STRING as product version"), 2},
  23. {"sparc-boot", OPTION_SPARC_BOOT, 0, 0, N_("enable sparc boot. Disables HFS+, APM, ARCS and boot as disk image for i386-pc"), 2},
  24. {"arcs-boot", OPTION_ARCS_BOOT, 0, 0, N_("enable ARCS (big-endian mips machines, mostly SGI) boot. Disables HFS+, APM, sparc64 and boot as disk image for i386-pc"), 2},
  25. + {"fixed-time", 't', N_("TIMEEPOCH"), 0, N_("use a fixed timestamp for uuid generation"), 2},
  26. {0, 0, 0, 0, 0, 0}
  27. };
  28. @@ -153,6 +155,8 @@ enum {
  29. static error_t
  30. argp_parser (int key, char *arg, struct argp_state *state)
  31. {
  32. + char *b;
  33. +
  34. if (grub_install_parse (key, arg))
  35. return 0;
  36. switch (key)
  37. @@ -212,6 +216,15 @@ argp_parser (int key, char *arg, struct argp_state *state)
  38. xorriso = xstrdup (arg);
  39. return 0;
  40. + case 't':
  41. + fixed_time = strtoll (arg, &b, 10);
  42. + if (*b !='\0') {
  43. + printf (_("invalid fixed time number: %s\n"), arg);
  44. + argp_usage (state);
  45. + exit (1);
  46. + }
  47. + return 0;
  48. +
  49. default:
  50. return ARGP_ERR_UNKNOWN;
  51. }
  52. @@ -542,7 +555,7 @@ main (int argc, char *argv[])
  53. {
  54. time_t tim;
  55. struct tm *tmm;
  56. - tim = time (NULL);
  57. + tim = fixed_time != -1 ? fixed_time : time (NULL);
  58. tmm = gmtime (&tim);
  59. iso_uuid = xmalloc (55);
  60. grub_snprintf (iso_uuid, 50,
  61. --
  62. 1.9.1