release: consume standalone zsh artifacts

This commit is contained in:
Michael Bolin
2026-06-25 13:28:14 -07:00
parent 5185180544
commit 0b9345fc8d
6 changed files with 111 additions and 22 deletions

View File

@@ -73,4 +73,6 @@ The patched zsh fork used by `shell_zsh_fork` is fetched from the DotSlash
manifest at `scripts/codex_package/codex-zsh` when the selected target has a
matching prebuilt artifact. Downloaded archives are cached under
`$TMPDIR/codex-package/<target>-zsh` and installed at
`codex-resources/zsh/bin/zsh`.
`codex-resources/zsh/bin/zsh`. Pass `--zsh-manifest` to use a different
DotSlash manifest, such as the manifest published with a standalone zsh
artifact release.

View File

@@ -90,6 +90,14 @@ def parse_args() -> argparse.Namespace:
"targets, bwrap is built with Cargo."
),
)
parser.add_argument(
"--zsh-manifest",
type=Path,
help=(
"Optional DotSlash manifest for the patched zsh fork instead of "
"scripts/codex_package/codex-zsh."
),
)
parser.add_argument(
"--codex-command-runner-bin",
type=Path,
@@ -160,7 +168,7 @@ def main() -> int:
inputs = PackageInputs(
entrypoint_bin=source_outputs.entrypoint_bin,
rg_bin=resolve_rg_bin(spec, args.rg_bin),
zsh_bin=resolve_zsh_bin(spec),
zsh_bin=resolve_zsh_bin(spec, args.zsh_manifest),
bwrap_bin=source_outputs.bwrap_bin,
codex_command_runner_bin=source_outputs.codex_command_runner_bin,
codex_windows_sandbox_setup_bin=source_outputs.codex_windows_sandbox_setup_bin,

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env python3
import hashlib
import json
from pathlib import Path
import sys
import tarfile
import tempfile
import unittest
from unittest.mock import patch
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from codex_package.targets import TARGET_SPECS
from codex_package.zsh import resolve_zsh_bin
class ResolveZshBinTest(unittest.TestCase):
def test_uses_manifest_override(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
root = Path(temp_dir)
archive = root / "codex-zsh.tar.gz"
source = root / "zsh"
source.write_bytes(b"standalone zsh")
with tarfile.open(archive, "w:gz") as tar:
tar.add(source, arcname="codex-zsh/bin/zsh")
manifest = root / "codex-zsh"
manifest.write_text(
json.dumps(
{
"platforms": {
"linux-x86_64": {
"size": archive.stat().st_size,
"hash": "sha256",
"digest": hashlib.sha256(
archive.read_bytes()
).hexdigest(),
"format": "tar.gz",
"path": "codex-zsh/bin/zsh",
"providers": [{"url": archive.as_uri()}],
}
}
}
),
encoding="utf-8",
)
with patch(
"codex_package.dotslash.default_cache_root",
return_value=root / "cache",
):
zsh_bin = resolve_zsh_bin(
TARGET_SPECS["x86_64-unknown-linux-musl"], manifest
)
self.assertIsNotNone(zsh_bin)
assert zsh_bin is not None
self.assertEqual(zsh_bin.read_bytes(), b"standalone zsh")
if __name__ == "__main__":
unittest.main()

View File

@@ -11,10 +11,13 @@ ZSH_MANIFEST = REPO_ROOT / "scripts" / "codex_package" / "codex-zsh"
ZSH_RESOURCE_PATH = Path("zsh") / "bin" / "zsh"
def resolve_zsh_bin(spec: TargetSpec) -> Path | None:
def resolve_zsh_bin(
spec: TargetSpec,
manifest_path: Path | None = None,
) -> Path | None:
return fetch_dotslash_executable(
spec,
manifest_path=ZSH_MANIFEST,
manifest_path=manifest_path or ZSH_MANIFEST,
artifact_label="codex-zsh",
cache_key=f"{spec.target}-zsh",
dest_name="zsh",