From 5406a15689b30a04491ab7502f30daf6300d3027 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Thu, 15 Oct 2026 09:43:55 +0100 Subject: [PATCH] make dist: the same tarball wherever it is made raz is built in a checkout at a fixed place, /tmp/raz-dist, since its debugging information names the build directory; tar sorts by name and gives every file the commit's time, owner 0 and plain modes; gzip -n. A build on Arch and one in Ubuntu 24.04 (CI's) agree. site/build.py passes the tag as REV and no longer makes a worktree of its own. Co-Authored-By: Claude Opus 5.5 --- diff --git a/Makefile b/Makefile index 79ffa91..2873998 100644 --- a/Makefile +++ b/Makefile @@ -149,22 +149,33 @@ # A release's tarball, build/raz-V-linux-x86_64.tar.gz: raz, the lib/ # it reads beside itself, the tools a program's make may build (the # formatter, Doc and the Scan they share) and the manual pages, V being what raz -# --version says. It is made of the checkout in TREE, this one unless -# given: CI packs the tag it checked out, and site/build.py the latest -# tag, which it checks out apart. -TREE = . +# --version says. It is made of the commit REV, HEAD unless given: CI +# packs the tag it checked out, and site/build.py each tag it lacks. +# +# The tarball is the same, byte for byte, wherever it is made, so that +# its SHA-256 can be checked against GitHub's or the website's. raz is +# built in a checkout at a fixed place, DIST, since the debugging +# information names the directory it was built in; the archive gives +# every file the commit's time, owner 0 and plain modes, in order of +# name, and gzip leaves out its own date. +REV = HEAD +DIST = /tmp/raz-dist dist: - $(MAKE) -C $(TREE) raz man - v=$$($(TREE)/raz --version | sed 's/^raz \([^,]*\),.*/\1/'); \ + rm -rf $(DIST) && git worktree prune && git worktree add -q --detach $(DIST) $(REV) + $(MAKE) -C $(DIST) raz man + v=$$($(DIST)/raz --version | sed 's/^raz \([^,]*\),.*/\1/'); \ d=raz-$$v-linux-x86_64; \ rm -rf build/$$d && mkdir -p build/$$d/man && \ - cp -r $(TREE)/raz $(TREE)/lib $(TREE)/LICENSE $(TREE)/README.md build/$$d && \ - mkdir build/$$d/tools && cp $(TOOLS:%=$(TREE)/tools/%.raz) build/$$d/tools && \ - cp $(TREE)/doc/raz.1 $(TREE)/doc/raz.7 $(TREE)/doc/raz-tutorial.7 \ - $(TREE)/build/raz-lib.3 build/$$d/man && \ - tar czf build/$$d.tar.gz -C build $$d && rm -rf build/$$d && \ - echo build/$$d.tar.gz + cp -r $(DIST)/raz $(DIST)/lib $(DIST)/LICENSE $(DIST)/README.md build/$$d && \ + mkdir build/$$d/tools && cp $(TOOLS:%=$(DIST)/tools/%.raz) build/$$d/tools && \ + cp $(DIST)/doc/raz.1 $(DIST)/doc/raz.7 $(DIST)/doc/raz-tutorial.7 \ + $(DIST)/build/raz-lib.3 build/$$d/man && \ + tar -cf - --format=gnu --sort=name --mtime=@$$(git log -1 --format=%ct $(REV)) \ + --owner=0 --group=0 --numeric-owner --mode=a+rX,u+w,go-w \ + -C build $$d | gzip -9n > build/$$d.tar.gz && \ + rm -rf build/$$d && echo build/$$d.tar.gz + git worktree remove --force $(DIST) # The website, plain files in site/public/: its home page, the tour # "Raz, Set, Go" (whose programs are run here, so the output shown is diff --git a/README.md b/README.md index edd8330..743fa19 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,8 @@ apart from the tree at hand); commit `site/public/` and push to publish it. Every release since 0.7.1 stays there, at its own name, and is never made again, so that its SHA-256 holds: programs pin raz by it. +From 0.15.0 on, `make dist` makes the same tarball, byte for byte, +wherever it runs, so GitHub's and the website's agree. A version of the report is named by its month and a count; the report's last section says what each version changed. diff --git a/site/build.py b/site/build.py index 7f9c355..705ca5b 100644 --- a/site/build.py +++ b/site/build.py @@ -340,10 +340,11 @@ with its SHA-256, and /download/latest leading to the newest; a list of (version, file name, SHA-256), oldest first. A program's CI can fetch the version it was written for by its name, so none is ever - taken away. Each is made of its tag's own checkout, not of the tree + taken away. Each is made of its tag by make dist, not of the tree at hand. One already in public/download/ is kept as it is, never - made again: a new one would differ in its dates, and so its SHA-256, - which a program's CI may check.""" + made again: those before 0.14.0 were made before make dist made the + same tarball each time, so a new one would differ, and so its + SHA-256, which a program's CI may check.""" git = lambda *a: subprocess.run(("git", "-C", ROOT) + a, capture_output=True, text=True, check=True).stdout.strip() releases = [] @@ -351,13 +352,8 @@ name = "raz-%s-linux-x86_64.tar.gz" % tag[1:] made = os.path.join(OUT, "download", name) if not os.path.exists(made): - tree = tempfile.mkdtemp() - try: - git("worktree", "add", "--detach", tree, tag) - subprocess.run(["make", "-s", "-C", ROOT, "dist", "TREE=" + tree], - stdout=subprocess.DEVNULL, check=True) - finally: - git("worktree", "remove", "--force", tree) + subprocess.run(["make", "-s", "-C", ROOT, "dist", "REV=" + tag], + stdout=subprocess.DEVNULL, check=True) shutil.copy(os.path.join(ROOT, "build", name), made) digest = hashlib.sha256(open(made, "rb").read()).hexdigest() write("download/%s.sha256" % name, "%s %s\n" % (digest, name))