#!/usr/bin/env python3 """Record what one release build produced: the runner and tool proxy digests, and on Linux the renderer tree's pin and its archive's digest and size. The source manifest (internal/release/manifest.json, copied into the release directory) pins the programs this repository does not build. This adds the tool proxy built for this release to it, and writes the install manifest with every target's digests. make release-runner links the same tool proxy digest into the runner and the instance, and both refuse an install manifest that disagrees. """ import hashlib import json import pathlib import re import sys import tarfile root, version = pathlib.Path(sys.argv[1]), sys.argv[2] assert re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}", version) assert version not in ("dev", "latest") def digest(path): return hashlib.sha256(path.read_bytes()).hexdigest() def renderer_pin(path): """The SHA-256 of renderer.tar.gz's MANIFEST: the renderer pin make release-runner linked into the Linux runner.""" with tarfile.open(path, "r:gz") as tar: member = tar.getmember("MANIFEST") assert member.isfile() return hashlib.sha256(tar.extractfile(member).read()).hexdigest() release = json.loads((root / "manifest.json").read_text()) assert release["schema"] == 3 assert [b["name"] for b in release["binaries"]] == ["claude", "codex", "codex-code-mode-host", "bwrap"] release["binaries"].append({"name": "equipo-tool-proxy", "version": release["launcher_version"], "sha256": digest(root / "equipo-tool-proxy")}) (root / "manifest.json").write_text(json.dumps(release, indent=2) + "\n") # Every platform's runner (Mac runners spec 3.1). The top-level fields # stay the Linux runner's for older bootstraps; a Mac worker's files are # under darwin-arm64/ and it is listed only when they are there. # The renderer: its tree pin, and the archive's own digest and size (the # runner fetches it from the forge, not the instance, and checks both). archive = root / "renderer.tar.gz" targets = {"linux/amd64": {"runner_sha256": digest(root / "equipo-runner"), "tool_proxy_sha256": digest(root / "equipo-tool-proxy"), "gitleaks_sha256": digest(root / "gitleaks"), "renderer_sha256": renderer_pin(archive), "renderer_archive_sha256": digest(archive), "renderer_archive_size": archive.stat().st_size}} mac = root / "darwin-arm64" if (mac / "equipo-runner").is_file(): targets["darwin/arm64"] = {"runner_sha256": digest(mac / "equipo-runner"), "gitleaks_sha256": digest(mac / "gitleaks")} manifest = { "gitleaks": "v8.30.1", "version": version, "target": "linux/amd64", "runner_sha256": hashlib.sha256((root / "equipo-runner").read_bytes()).hexdigest(), "namespace_args": ["--unshare-user", "--unshare-pid", "--unshare-ipc", "--unshare-uts", "--unshare-cgroup", "--unshare-net", "--die-with-parent", "--new-session", "--as-pid-1", "--cap-drop", "ALL", "--json-status-fd", "3"], "release": release, "targets": targets, } (root / "install-manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")