|
|
@@ -279,14 +279,27 @@ def package_base(output: Path) -> Path:
|
|
|
"base_zip_sha256": "BOUND_EXTERNALLY_BY_BASE_REQUIRED",
|
|
|
"stable_content_fingerprint": base_id, "creation_source_commit": commit,
|
|
|
"creation_source_tree": tree}, indent=2, sort_keys=True) + "\n").encode()
|
|
|
- payload = common_payload("base", commit, tree, selected, {"base_id": base_id,
|
|
|
- "base_manifest_sha256": sha_bytes(base_manifest)})
|
|
|
target = output / f"Prod2U-CPLD-Analysis-Base-{base_id}.zip"
|
|
|
- if target.exists():
|
|
|
- existing_id, _existing_manifest, existing_base_manifest_sha = base_metadata(target)
|
|
|
+ # Base identity is global within the canonical package root, not just one
|
|
|
+ # timestamp/commit output directory. Reuse the first verified byte image.
|
|
|
+ candidates = sorted(output.parent.rglob(target.name)) if output.parent.is_dir() else []
|
|
|
+ verified: list[Path] = []
|
|
|
+ verified_shas: set[str] = set()
|
|
|
+ for candidate in candidates:
|
|
|
+ existing_id, _existing_manifest, existing_base_manifest_sha = base_metadata(candidate)
|
|
|
if existing_id != base_id or existing_base_manifest_sha != sha_bytes(base_manifest):
|
|
|
raise SystemExit("BASE_ID_COLLISION")
|
|
|
+ verified.append(candidate)
|
|
|
+ verified_shas.add(sha_file(candidate))
|
|
|
+ if len(verified_shas) > 1:
|
|
|
+ raise SystemExit("BASE_ID_COLLISION")
|
|
|
+ if verified:
|
|
|
+ if target not in verified:
|
|
|
+ target.parent.mkdir(parents=True, exist_ok=True)
|
|
|
+ shutil.copy2(verified[0], target)
|
|
|
return target
|
|
|
+ payload = common_payload("base", commit, tree, selected, {"base_id": base_id,
|
|
|
+ "base_manifest_sha256": sha_bytes(base_manifest)})
|
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
|
candidate = write_zip(Path(tmp) / target.name, payload)
|
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|