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>
| @@ -149,22 +149,33 @@ | ||
| 149 | 149 | # A release's tarball, build/raz-V-linux-x86_64.tar.gz: raz, the lib/ |
| 150 | 150 | # it reads beside itself, the tools a program's make may build (the |
| 151 | 151 | # 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 | |
| 156 | 163 | |
| 157 | 164 | 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/'); \ | |
| 160 | 168 | d=raz-$$v-linux-x86_64; \ |
| 161 | 169 | 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) | |
| 168 | 179 | |
| 169 | 180 | # The website, plain files in site/public/: its home page, the tour |
| 170 | 181 | # "Raz, Set, Go" (whose programs are run here, so the output shown is |
| @@ -220,6 +220,8 @@ | ||
| 220 | 220 | apart from the tree at hand); commit `site/public/` and push to publish |
| 221 | 221 | it. Every release since 0.7.1 stays there, at its own name, and is |
| 222 | 222 | 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. | |
| 223 | 225 | |
| 224 | 226 | A version of the report is named by its month and a count; the report's |
| 225 | 227 | last section says what each version changed. |
| @@ -340,10 +340,11 @@ | ||
| 340 | 340 | with its SHA-256, and /download/latest leading to the newest; a list |
| 341 | 341 | of (version, file name, SHA-256), oldest first. A program's CI can |
| 342 | 342 | 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 | |
| 344 | 344 | 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.""" | |
| 347 | 348 | git = lambda *a: subprocess.run(("git", "-C", ROOT) + a, capture_output=True, |
| 348 | 349 | text=True, check=True).stdout.strip() |
| 349 | 350 | releases = [] |
| @@ -351,13 +352,8 @@ | ||
| 351 | 352 | name = "raz-%s-linux-x86_64.tar.gz" % tag[1:] |
| 352 | 353 | made = os.path.join(OUT, "download", name) |
| 353 | 354 | 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) | |
| 361 | 357 | shutil.copy(os.path.join(ROOT, "build", name), made) |
| 362 | 358 | digest = hashlib.sha256(open(made, "rb").read()).hexdigest() |
| 363 | 359 | write("download/%s.sha256" % name, "%s %s\n" % (digest, name)) |