0001-genxpi-make-XPI-files-reproducible.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From a68b0efbd2002aeb6aa1240b8611cbb97b84d7a7 Mon Sep 17 00:00:00 2001
  2. From: Jonas Witschel <diabonas@gmx.de>
  3. Date: Fri, 10 Jul 2020 19:02:43 +0200
  4. Subject: [PATCH] genxpi: make XPI files reproducible
  5. zip records the mtime of packed files, making it harder to reproduce the
  6. generated file bit for bit. Use the SOURCE_DATE_EPOCH specification that is
  7. already respected in other places of this project (package/Makefile) to set the
  8. modification time to a known, reproducible value.
  9. To avoid embedding time zone information and Unix UIDs/GIDs as further sources
  10. of unreproducibilty use "export TZ=UTC" and "zip -X", resp. Also make the mtime
  11. of the generated XPI file reproducible using "zip -o" for good measure.
  12. ---
  13. util/genxpi | 23 +++++++++++++++++------
  14. 1 file changed, 17 insertions(+), 6 deletions(-)
  15. diff --git a/util/genxpi b/util/genxpi
  16. index 9d7c39e5..36110e02 100755
  17. --- a/util/genxpi
  18. +++ b/util/genxpi
  19. @@ -60,9 +60,10 @@ find chrome/content/modules -name "*.js*" | LC_ALL=C sort > chrome/content/modul
  20. echo "Creating ${xpiFile} file"
  21. -zip -9 --must-match\
  22. - ../${xpiFile} \
  23. - chrome/content/preferences/defaultPrefs.js \
  24. +# Avoid embedding time zone information about the current system into the XPI
  25. +export TZ=UTC
  26. +
  27. +set chrome/content/preferences/defaultPrefs.js \
  28. chrome/content/modules/addrbook.jsm \
  29. chrome/content/modules/amPrefsService.jsm \
  30. chrome/content/modules/app.jsm \
  31. @@ -184,9 +185,15 @@ zip -9 --must-match\
  32. chrome/content/modules/all-modules.txt \
  33. chrome/content/am-enigprefs.xul
  34. -zip -9 \
  35. - ../${xpiFile} \
  36. - chrome/content/ui/*.* \
  37. +# Set modification timestamps to a fixed value for reproducibilty
  38. +[ -n "$SOURCE_DATE_EPOCH" ] && touch --date "@$SOURCE_DATE_EPOCH" -- "$@"
  39. +zip -9 -o -X --must-match ../${xpiFile} "$@"
  40. +
  41. +if [ $? -ne 0 ]; then
  42. + exit 1
  43. +fi
  44. +
  45. +set chrome/content/ui/*.* \
  46. chrome/skin/aero/*.* \
  47. chrome/skin/modern/*.* \
  48. chrome/skin/tb-mac/*.* \
  49. @@ -198,3 +205,7 @@ zip -9 \
  50. bootstrap.js \
  51. chrome.manifest \
  52. ${pkgFile}
  53. +
  54. +# Set modification timestamps to a fixed value for reproducibilty
  55. +[ -n "$SOURCE_DATE_EPOCH" ] && touch --date "@$SOURCE_DATE_EPOCH" -- "$@"
  56. +zip -9 -o -X ../${xpiFile} "$@"
  57. --
  58. 2.27.0