From 3fdfdc71a93ce0369cb89f8f4ef433b983c3e881 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Tue, 29 Oct 2024 14:28:50 +0700 Subject: [PATCH] Makefile: Use file commit times for dist - A step to reproducible builds. - Do not rebuild `lrp_help.html` since it modifies timestamp inside. - Fail if some files are modified. --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d78f4f3..4a95039 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ +ENV_CLEAN = LC_ALL=en_US.UTF-8 TZ=Z LANGUAGE=en +GIT_RESTORE_MTIME_FLAGS = restore-mtime --commit-time +GIT_DIFF_FLAGS = --no-pager diff --exit-code --name-only MAKE_MANIFEST = tools/make_manifest.py MAKE_SW = tools/make_sw.py MANIFEST_FIREFOX_src = manifest-common.yaml manifest-part-firefox.yaml @@ -84,7 +87,7 @@ ICONS_SRC += icons/lr-64.png icons/lr-128.png OFFSCREEN_SRC += offscreen/lro_clipboard.html offscreen/lro_clipboard.js -EMACS = LC_ALL=en_US.UTF-8 TZ=Z LANGUAGE=en emacs +EMACS = $(ENV_CLEAN) emacs EMACS_FLAGS = --batch --no-init-file ORG_RUBY = org-ruby @@ -142,25 +145,31 @@ clean: $(RM) manifest.json $(RM) README.html -firefox-dist: firefox +firefox-dist: manifest-firefox.json + git $(GIT_DIFF_FLAGS) + git $(GIT_RESTORE_MTIME_FLAGS) + ln -sf manifest-firefox.json manifest.json set -e ; \ out="`cat manifest-firefox.json | \ python3 -c "import json, sys; print(json.load(sys.stdin)['version'])"`" ; \ background="`python3 -c 'import sys,json; print(" ".join(json.load(sys.stdin)["background"]["scripts"]))' < manifest.json`" ; \ file="linkremark-$${out}-unsigned.xpi" ; \ $(RM) "$$file" ; \ - zip --must-match "$$file" manifest.json $$background \ + $(ENV_CLEAN) zip --must-match "$$file" manifest.json $$background \ $(PAGES_SRC) $(CONTENT_SRC) $(ICONS_SRC) \ "_locales/en/messages.json" ; \ echo "Created $$file" -chrome-dist: chrome manifest-chrome-dist.json $(HELP_PAGE) +chrome-dist: manifest-chrome-dist.json $(SW_DIST_JS) + git $(GIT_DIFF_FLAGS) + git $(GIT_RESTORE_MTIME_FLAGS) ln -sf manifest-chrome-dist.json manifest.json + ln -sf $(SW_DIST_JS) $(SW_JS) set -e ; \ version="`python3 -c 'import json, sys; print(json.load(sys.stdin)["version"])'