fix(deploy-win): extract ISO with 7z so no-prompt boot patch works

xorriso -extract reads the ISO9660 name tree, which on a Windows ISO has
no Rock Ridge — names come back upper-cased/truncated, so the
`efi/microsoft/boot/efisys_noprompt.bin` lookup failed ("missing from
ISO") and a repack from that tree would corrupt Windows' long file names.

Extract with 7z instead (reads the UDF/Joliet tree, preserving the real
lower-case paths), excluding 7z's synthetic `[BOOT]` dump. Verified
end-to-end on the cached 26100.32860 ISO: 7z extract → xorriso repack
yields a 5 GB ISO with autounattend.xml + post-install.ps1 at the root and
efisys_noprompt.bin as the UEFI El Torito image (no boot prompt).

Also: cap the Joliet volume id at 16 chars (silence xorriso warning), add
a 7z preflight check, and add p7zip-full to setup-host-linux.sh.
This commit is contained in:
2026-06-08 23:31:18 +02:00
parent c757e7bec2
commit 0df7305841
4 changed files with 29 additions and 7 deletions
+1
View File
@@ -2174,6 +2174,7 @@ def template_deploy_win(
(f"vmrun found: {vmrun}", bool(shutil.which(vmrun) or Path(vmrun).is_file())),
(f"vmware-vdiskmanager found: {vdisk_mgr}", Path(vdisk_mgr).is_file()),
("xorriso in PATH", shutil.which("xorriso") is not None),
("7z in PATH", any(shutil.which(n) for n in ("7z", "7za", "7zr"))),
(f"VMware Tools ISO: {tools_iso}", tools_iso.is_file()),
]
for label, ok in checks:
+20 -3
View File
@@ -30,6 +30,14 @@ def _require_xorriso() -> str:
return exe
def _require_7z() -> str:
for name in ("7z", "7za", "7zr"):
exe = shutil.which(name)
if exe is not None:
return exe
raise click.ClickException("7z not found. Install p7zip-full.")
def _read_volid(base_iso: Path) -> str:
"""Read the ISO volume id (label); fall back to a sane default."""
label = ""
@@ -42,7 +50,8 @@ def _read_volid(base_iso: Path) -> str:
check=False,
)
label = proc.stdout.strip()
return (label or "WINSERVER")[:32]
# Joliet volume ids are capped at 16 chars; longer ids make xorriso warn.
return (label or "WINSERVER")[:16]
def _check_free_space(base_iso: Path, work_parent: Path) -> None:
@@ -66,6 +75,7 @@ def patch_iso(
) -> Path:
"""Inject answer files + no-prompt boot into ``base_iso`` → ``out_iso``."""
xorriso = _require_xorriso()
sevenz = _require_7z()
if not base_iso.is_file():
raise click.ClickException(f"base ISO not found: {base_iso}")
@@ -79,12 +89,19 @@ def patch_iso(
tree.mkdir(parents=True)
try:
# Extract with 7z (reads the UDF/Joliet tree) so the long, lower-case
# Windows paths survive. xorriso's -extract uses the ISO9660 name tree
# (upper-case / truncated, no Rock Ridge on Windows ISOs), which both
# breaks the efisys_noprompt.bin lookup and would corrupt Windows file
# names in the repacked image. ``[BOOT]`` is 7z's synthetic El Torito
# dump — excluded so it does not pollute the tree.
click.echo(f" [iso] extracting base ISO: {base_iso.name}")
subprocess.run(
[xorriso, "-osirrox", "on", "-indev", str(base_iso), "-extract", "/", str(tree)],
[sevenz, "x", str(base_iso), f"-o{tree}", "-y", "-bd", "-x![BOOT]"],
check=True,
stdout=subprocess.DEVNULL,
)
# Extracted files are read-only; make the tree writable so we can add files.
# Extracted files may be read-only; make the tree writable so we can add files.
subprocess.run(["chmod", "-R", "u+w", str(tree)], check=True)
efi_boot = tree / _EFI_BOOT_NOPROMPT