Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/test_release_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_build_is_deterministic_and_clean_installable(self) -> None:
manifest["artifact"]["sha256"], hashlib.sha256((first / name).read_bytes()).hexdigest()
)
installed = subprocess.run(
["python3", str(INSTALLER), str(first / name), "--skip-tests"],
["python3", str(INSTALLER), str(first / name)],
cwd=ROOT,
capture_output=True,
text=True,
Expand Down
24 changes: 23 additions & 1 deletion tools/verify_clean_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from __future__ import annotations

import argparse
import os
import shutil
import stat
import subprocess
import sys
Expand All @@ -28,6 +30,26 @@ def run(*arguments: str, cwd: Path) -> None:
raise ValueError((result.stdout + result.stderr).strip() or f"command failed: {arguments}")


def extract_with_modes(archive: zipfile.ZipFile, destination: Path) -> None:
"""Extract validated members without following links and restore portable modes."""

for item in archive.infolist():
relative = PurePosixPath(item.filename)
target = destination.joinpath(*relative.parts)
if item.is_dir():
target.mkdir(parents=True, exist_ok=True)
continue
mode = stat.S_IMODE(item.external_attr >> 16)
if mode not in {0o644, 0o755}:
raise ValueError(f"release ZIP has an unsupported file mode: {item.filename}")
target.parent.mkdir(parents=True, exist_ok=True)
with archive.open(item) as source, target.open("wb") as output:
shutil.copyfileobj(source, output)
os.chmod(target, mode)
if stat.S_IMODE(target.stat().st_mode) != mode:
raise ValueError(f"could not restore release file mode: {item.filename}")


def main() -> int:
args = parse_args()
try:
Expand All @@ -50,7 +72,7 @@ def main() -> int:
raise ValueError("release ZIP contains a symbolic link")
with tempfile.TemporaryDirectory(prefix="web-plan-execute-install-") as temporary:
destination = Path(temporary)
archive.extractall(destination)
extract_with_modes(archive, destination)
skill = destination / "web-plan-execute"
run(
sys.executable,
Expand Down