fix: write the published checksums in split_pack

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 16:43:46 +01:00
1 parent 83f7693ccb
commit ef7884500e
10 files changed
+88 -35

No files matched your search

+3 -4
View File
@@ -17,7 +17,7 @@ from core.options import reject_unknown
from model.registry import list_registered_platforms
from model.targets import load_target_config
from packs.archive import write_generated_member
from packs.integrity import generate_sha256sums, verify_pack, verify_pack_against_platform
from packs.integrity import verify_pack, verify_pack_against_platform
from packs.naming import expected_pack_names, narrows_contents, pack_archives
from packs.scope import annotate_pack_systems
@@ -35,7 +35,7 @@ def baseline_shortfall(excluded: int, absent: int) -> list[str]:
return parts
# Post-generation pack verification + manifest + SHA256SUMS
# Post-generation pack verification + manifest
def inject_manifest(zip_path: str, manifest: dict) -> None:
@@ -156,7 +156,7 @@ def verify_and_finalize_packs(
db: dict,
**options: Unpack[FinalizeOptions],
) -> bool:
"""Verify all packs, inject manifests, generate SHA256SUMS.
"""Verify all packs and inject their manifests.
pack_systems_by_name gives, per pack file name, the systems its
manifest.json records (pack_systems).
@@ -225,7 +225,6 @@ def verify_and_finalize_packs(
all_ok = False
failing.append(f"{name} ({pname})")
generate_sha256sums(output_dir)
if failing:
# Named at the end, where a 4,000-line log is read, and on stderr.
print(f"ERROR: packs failed verification: {', '.join(failing)}", file=sys.stderr)
+1 -18
View File
@@ -22,7 +22,7 @@ from resolve.nativemode import hash_mismatch_excludes_file
import sys
from resolve.cores import filter_systems_by_target
from core.hashing import (
compute_hashes, file_digest, md5_composite, md5_composite_of, md5sum, parse_hash_list,
compute_hashes, md5_composite, md5_composite_of, md5sum, parse_hash_list,
stream_hashes,
)
from core.options import reject_unknown
@@ -43,7 +43,6 @@ from resolve.cores import resolve_platform_cores
from core.paths import BIOS_DIR, EMULATORS_DIR, declared_destination
import zipfile
from collections.abc import Callable
from pathlib import Path
# Imported at run time where typing has it: a test reads the signature of
# verify_pack_against_platform with its annotations evaluated.
@@ -316,22 +315,6 @@ def verify_pack(
all_ok = len(errors) == 0
return all_ok, manifest
def generate_sha256sums(output_dir: str) -> str | None:
"""Generate SHA256SUMS.txt for all ZIP files in output_dir."""
sums_path = os.path.join(output_dir, "SHA256SUMS.txt")
entries = []
for name in sorted(os.listdir(output_dir)):
if not name.endswith(".zip"):
continue
path = os.path.join(output_dir, name)
entries.append(f"{file_digest(Path(path), 'sha256')} {name}")
if not entries:
return None
with open(sums_path, "w") as f:
f.write("\n".join(entries) + "\n")
print(f"\n{sums_path}: {len(entries)} pack checksums")
return sums_path
def _check_member_hash(
zf: zipfile.ZipFile, member: str, file_entry: dict, mode: str, rule: str = ""
) -> str | None:
+1 -1
View File
@@ -7,9 +7,9 @@ import subprocess
from dataclasses import dataclass
from model.largefiles import LARGE_FILES_REPO, digests_of
from release.sums import SUMS
SUMS = "SHA256SUMS.txt"
SIGNATURE = SUMS + ".sig"
@dataclass(frozen=True)
class Asset:
+33
View File
@@ -0,0 +1,33 @@
"""The checksum list of the pack files a release publishes."""
from __future__ import annotations
from pathlib import Path
from core.hashing import file_digest
from model.releaserecord import PACK_SUFFIX
SUMS = "SHA256SUMS.txt"
def published_packs(directory: Path) -> list[Path]:
"""The pack files a release uploads from a directory: whole packs and parts."""
stem = PACK_SUFFIX.removesuffix(".zip")
return sorted(
path for path in Path(directory).glob(f"*{stem}*.zip") if path.is_file()
)
def write_sums(directory: Path) -> Path | None:
"""Write SHA256SUMS.txt over the published packs, in `sha256sum` form.
Returns its path, or None when the directory holds no pack.
"""
lines = [
f"{file_digest(path, 'sha256')} {path.name}" for path in published_packs(directory)
]
if not lines:
return None
sums = Path(directory) / SUMS
sums.write_text("\n".join(lines) + "\n", encoding="utf-8")
return sums
+7
View File
@@ -11,6 +11,9 @@ the pack it belongs to, its number, and the name and size of every part.
Extracted with the files, the markers let `install.py --check` name a part
that is missing from the folder.
The directory's SHA256SUMS.txt is then written over the pack files a
release publishes, the list the release signs and uploads.
Usage:
python scripts/split_pack.py dist/
python scripts/split_pack.py dist/RetroArch_v1.22.2_BIOS_Pack.zip
@@ -26,6 +29,7 @@ from pathlib import Path
from core.artifacts import ArtifactLockBusy, artifact_lock
from packs.parts import ASSET_LIMIT, parse_size, split_directory, split_pack
from release.sums import write_sums
def main() -> int:
@@ -53,11 +57,14 @@ def main() -> int:
published = split_directory(args.target, args.max_size)
else:
published = split_pack(args.target, args.max_size)
sums = write_sums(directory)
except (ArtifactLockBusy, OSError, ValueError, zipfile.BadZipFile) as exc:
print(f"Error: {exc}", file=sys.stderr)
return 1
for path in published:
print(f"{path.stat().st_size:>13,} {path.name}")
if sums is not None:
print(f"{sums}: checksums of the files to publish")
return 0