From 7d101805f896dd5bae1c540b10bd0662783359e3 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Wed, 22 Feb 2017 11:44:50 -0800 Subject: [PATCH] Introduce measures to start building Zips deterministically. This at least lays some groundwork for doing so, by gathering archive members by wildcard expansion rather than zip's -r parameter (which uses file system order -- essentially random), combined with LC_ALL=C so that locale sorting orders don't matter either. zip's -X option is also used so no Unix metadata (UIDs, GIDs, modes) are saved in the archive. To really complete the effect, faketime should be used to deal with file timestamps. Requiring faketime to do `make dist` seems too extreme to me, so I'm leaving it out, but the general idea is to run a command such as: faketime -f "$(TZ=UTC date -d "@$(git show -q --format=format:%ct)" \ "+%Y-%m-%d %H:%M:%S")" \ make dist This does also assume that zip's default compression algorithm never changes (eg, from DEFLATE to BZip2 or LZMA), or never releases an improved version (eg, a better DEFLATE). It's not perfect, but this should be good enough. --- Makefile | 4 ++-- scripts/makepkgs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 65aade18..5479a051 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,8 @@ DISTDOCS=COPYING.txt CREDITS.txt README.html # Due to convoluted reasons, the WADs must directly proceed the game name. dist: $(OBJS) COPYING.txt CREDITS.txt README.html - VERSION=$(VERSION) scripts/makepkgs freedm $(FREEDM) $(DISTDOCS) - VERSION=$(VERSION) scripts/makepkgs freedoom $(FREEDOOM1) $(FREEDOOM2) $(DISTDOCS) + LC_ALL=C VERSION=$(VERSION) scripts/makepkgs freedm $(FREEDM) $(DISTDOCS) + LC_ALL=C VERSION=$(VERSION) scripts/makepkgs freedoom $(FREEDOOM1) $(FREEDOOM2) $(DISTDOCS) json: $(OBJS) ifndef JSON diff --git a/scripts/makepkgs b/scripts/makepkgs index f5fcdcf1..2d3242aa 100755 --- a/scripts/makepkgs +++ b/scripts/makepkgs @@ -34,14 +34,14 @@ full_path = path + "/" + base_dir # Create directory and add files -run_command("mkdir %s" % full_path) +run_command("mkdir {}".format(full_path)) for file in FILES: - run_command("cp %s %s" % (file, full_path)) + run_command("cp {} {}".format(file, full_path)) orig_dir = os.getcwd() os.chdir(path) -run_command("rm -f %s.zip" % base_dir) -run_command("zip -r %s.zip %s" % (base_dir, base_dir)) -run_command("rm -rf %s" % base_dir) +run_command("rm -f {}.zip".format(base_dir)) +run_command("zip -X {0}.zip {0} {0}/*".format(base_dir)) +run_command("rm -rf {}".format(base_dir)) os.chdir(orig_dir)