raz / commit 5406a156

commit
5406a15689b30a04491ab7502f30daf6300d3027
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
16bb4f80
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 <noreply@anthropic.com>

patch · log

3 files changed, +31 -22

Makefile (history) modified +23 -12

@@ -149,22 +149,33 @@
149149 # A release's tarball, build/raz-V-linux-x86_64.tar.gz: raz, the lib/
150150 # it reads beside itself, the tools a program's make may build (the
151151 # formatter, Doc and the Scan they share) and the manual pages, V being what raz
152-# --version says. It is made of the checkout in TREE, this one unless
153-# given: CI packs the tag it checked out, and site/build.py the latest
154-# tag, which it checks out apart.
155-TREE = .
152+# --version says. It is made of the commit REV, HEAD unless given: CI
153+# packs the tag it checked out, and site/build.py each tag it lacks.
154+#
155+# The tarball is the same, byte for byte, wherever it is made, so that
156+# its SHA-256 can be checked against GitHub's or the website's. raz is
157+# built in a checkout at a fixed place, DIST, since the debugging
158+# information names the directory it was built in; the archive gives
159+# every file the commit's time, owner 0 and plain modes, in order of
160+# name, and gzip leaves out its own date.
161+REV = HEAD
162+DIST = /tmp/raz-dist
156163
157164 dist:
158- $(MAKE) -C $(TREE) raz man
159- v=$$($(TREE)/raz --version | sed 's/^raz \([^,]*\),.*/\1/'); \
165+ rm -rf $(DIST) && git worktree prune && git worktree add -q --detach $(DIST) $(REV)
166+ $(MAKE) -C $(DIST) raz man
167+ v=$$($(DIST)/raz --version | sed 's/^raz \([^,]*\),.*/\1/'); \
160168 d=raz-$$v-linux-x86_64; \
161169 rm -rf build/$$d && mkdir -p build/$$d/man && \
162- cp -r $(TREE)/raz $(TREE)/lib $(TREE)/LICENSE $(TREE)/README.md build/$$d && \
163- mkdir build/$$d/tools && cp $(TOOLS:%=$(TREE)/tools/%.raz) build/$$d/tools && \
164- cp $(TREE)/doc/raz.1 $(TREE)/doc/raz.7 $(TREE)/doc/raz-tutorial.7 \
165- $(TREE)/build/raz-lib.3 build/$$d/man && \
166- tar czf build/$$d.tar.gz -C build $$d && rm -rf build/$$d && \
167- echo build/$$d.tar.gz
170+ cp -r $(DIST)/raz $(DIST)/lib $(DIST)/LICENSE $(DIST)/README.md build/$$d && \
171+ mkdir build/$$d/tools && cp $(TOOLS:%=$(DIST)/tools/%.raz) build/$$d/tools && \
172+ cp $(DIST)/doc/raz.1 $(DIST)/doc/raz.7 $(DIST)/doc/raz-tutorial.7 \
173+ $(DIST)/build/raz-lib.3 build/$$d/man && \
174+ tar -cf - --format=gnu --sort=name --mtime=@$$(git log -1 --format=%ct $(REV)) \
175+ --owner=0 --group=0 --numeric-owner --mode=a+rX,u+w,go-w \
176+ -C build $$d | gzip -9n > build/$$d.tar.gz && \
177+ rm -rf build/$$d && echo build/$$d.tar.gz
178+ git worktree remove --force $(DIST)
168179
169180 # The website, plain files in site/public/: its home page, the tour
170181 # "Raz, Set, Go" (whose programs are run here, so the output shown is

README.md (history) modified +2 -0

@@ -220,6 +220,8 @@
220220 apart from the tree at hand); commit `site/public/` and push to publish
221221 it. Every release since 0.7.1 stays there, at its own name, and is
222222 never made again, so that its SHA-256 holds: programs pin raz by it.
223+From 0.15.0 on, `make dist` makes the same tarball, byte for byte,
224+wherever it runs, so GitHub's and the website's agree.
223225
224226 A version of the report is named by its month and a count; the report's
225227 last section says what each version changed.

site/build.py modified +6 -10

@@ -340,10 +340,11 @@
340340 with its SHA-256, and /download/latest leading to the newest; a list
341341 of (version, file name, SHA-256), oldest first. A program's CI can
342342 fetch the version it was written for by its name, so none is ever
343- taken away. Each is made of its tag's own checkout, not of the tree
343+ taken away. Each is made of its tag by make dist, not of the tree
344344 at hand. One already in public/download/ is kept as it is, never
345- made again: a new one would differ in its dates, and so its SHA-256,
346- which a program's CI may check."""
345+ made again: those before 0.14.0 were made before make dist made the
346+ same tarball each time, so a new one would differ, and so its
347+ SHA-256, which a program's CI may check."""
347348 git = lambda *a: subprocess.run(("git", "-C", ROOT) + a, capture_output=True,
348349 text=True, check=True).stdout.strip()
349350 releases = []
@@ -351,13 +352,8 @@
351352 name = "raz-%s-linux-x86_64.tar.gz" % tag[1:]
352353 made = os.path.join(OUT, "download", name)
353354 if not os.path.exists(made):
354- tree = tempfile.mkdtemp()
355- try:
356- git("worktree", "add", "--detach", tree, tag)
357- subprocess.run(["make", "-s", "-C", ROOT, "dist", "TREE=" + tree],
358- stdout=subprocess.DEVNULL, check=True)
359- finally:
360- git("worktree", "remove", "--force", tree)
355+ subprocess.run(["make", "-s", "-C", ROOT, "dist", "REV=" + tag],
356+ stdout=subprocess.DEVNULL, check=True)
361357 shutil.copy(os.path.join(ROOT, "build", name), made)
362358 digest = hashlib.sha256(open(made, "rb").read()).hexdigest()
363359 write("download/%s.sha256" % name, "%s %s\n" % (digest, name))