Update iso-prototype.py

This commit is contained in:
Kroese
2026-07-28 14:06:19 +02:00
committed by GitHub
parent 061869f3ab
commit 5d5c2b3966
+9 -5
View File
@@ -507,11 +507,6 @@ def rebuild_windows_eltorito(iso, tree: Path) -> None:
print(f" BIOS: {bios_source} ({bios_source.stat().st_size} bytes)")
print(f" UEFI: {uefi_source} ({uefi_source.stat().st_size} bytes)")
# Remove the imported catalog before touching any inode referenced by it.
# This also releases PyCdlib's incomplete hidden boot-image records.
if getattr(iso, "eltorito_boot_catalog", None) is not None:
iso.rm_eltorito()
# These private root-level records avoid depending on the source ISO's very
# small ISO9660 tree. The original Microsoft files remain available via UDF.
for iso_path in (bios_iso_path, uefi_iso_path):
@@ -567,6 +562,15 @@ def build_pycdlib(args: argparse.Namespace) -> None:
try:
print(f"Opening source ISO: {source}")
iso.open(str(source))
# PyCdlib stores directory-child indexes on imported hidden El Torito
# records. Any file removal/addition can make those indexes stale, which
# makes a later rm_eltorito() fail with "Invalid child index to remove".
# Remove the imported catalog immediately, before mutating the ISO tree.
if getattr(iso, "eltorito_boot_catalog", None) is not None:
print("Removing imported El Torito catalog before filesystem changes...")
iso.rm_eltorito()
for value in args.replace:
logical = PurePosixPath("/") / value.lstrip("/")
print(f"Replacing: {logical}")