oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Record what one release build produced: the runner and tool proxy digests,
3and on Linux the renderer tree's pin and its archive's digest and size.
4
5The source manifest (internal/release/manifest.json, copied into the
6release directory) pins the programs this repository does not build. This
7adds the tool proxy built for this release to it, and writes the install
8manifest with every target's digests. make release-runner links the same
9tool proxy digest into the runner and the instance, and both refuse an
10install manifest that disagrees.
11"""
12import hashlib
13import json
14import pathlib
15import re
16import sys
17import tarfile
18
19root, version = pathlib.Path(sys.argv[1]), sys.argv[2]
20assert re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}", version)
21assert version not in ("dev", "latest")
22def digest(path):
23 return hashlib.sha256(path.read_bytes()).hexdigest()
24
25
26def renderer_pin(path):
27 """The SHA-256 of renderer.tar.gz's MANIFEST: the renderer pin make
28 release-runner linked into the Linux runner."""
29 with tarfile.open(path, "r:gz") as tar:
30 member = tar.getmember("MANIFEST")
31 assert member.isfile()
32 return hashlib.sha256(tar.extractfile(member).read()).hexdigest()
33
34
35release = json.loads((root / "manifest.json").read_text())
36assert release["schema"] == 3
37assert [b["name"] for b in release["binaries"]] == ["claude", "codex", "codex-code-mode-host", "bwrap"]
38release["binaries"].append({"name": "equipo-tool-proxy", "version": release["launcher_version"],
39 "sha256": digest(root / "equipo-tool-proxy")})
40(root / "manifest.json").write_text(json.dumps(release, indent=2) + "\n")
41
42
43# Every platform's runner (Mac runners spec 3.1). The top-level fields
44# stay the Linux runner's for older bootstraps; a Mac worker's files are
45# under darwin-arm64/ and it is listed only when they are there.
46# The renderer: its tree pin, and the archive's own digest and size (the
47# runner fetches it from the forge, not the instance, and checks both).
48archive = root / "renderer.tar.gz"
49targets = {"linux/amd64": {"runner_sha256": digest(root / "equipo-runner"),
50 "tool_proxy_sha256": digest(root / "equipo-tool-proxy"), "gitleaks_sha256": digest(root / "gitleaks"),
51 "renderer_sha256": renderer_pin(archive),
52 "renderer_archive_sha256": digest(archive), "renderer_archive_size": archive.stat().st_size}}
53mac = root / "darwin-arm64"
54if (mac / "equipo-runner").is_file():
55 targets["darwin/arm64"] = {"runner_sha256": digest(mac / "equipo-runner"), "gitleaks_sha256": digest(mac / "gitleaks")}
56manifest = {
57 "gitleaks": "v8.30.1",
58 "version": version,
59 "target": "linux/amd64",
60 "runner_sha256": hashlib.sha256((root / "equipo-runner").read_bytes()).hexdigest(),
61 "namespace_args": ["--unshare-user", "--unshare-pid", "--unshare-ipc",
62 "--unshare-uts", "--unshare-cgroup", "--unshare-net",
63 "--die-with-parent", "--new-session", "--as-pid-1",
64 "--cap-drop", "ALL", "--json-status-fd", "3"],
65 "release": release,
66 "targets": targets,
67}
68(root / "install-manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
69