Auto-detect the Windows 11 installation ISO
Instead of a hard-coded file name, find the ISO in install-iso/ by matching *Win*11*x64*.iso (case-insensitive), picking the highest version-sorted name when several match. The QCOW2 path is derived from the detected ISO name, falling back to an existing *Win*11*x64*.qcow2 in base-qcow2/ when the ISO is absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ks2ixr4KHXBtLuCet7Ch5Z
This commit is contained in:
1 parent
4e86a23634
commit
942c97686b
2 files changed
+48
-6
No files matched your search
@@ -22,7 +22,10 @@ Download or check selected targets:
|
|||||||
```
|
```
|
||||||
|
|
||||||
The Windows installation ISO is not downloaded because Microsoft's temporary
|
The Windows installation ISO is not downloaded because Microsoft's temporary
|
||||||
download URLs expire. Supply it manually at the path reported by
|
download URLs expire. Place it manually in `install-iso/`; the script finds it
|
||||||
|
automatically by matching `Win`, `11`, `x64` and `.iso` in that order
|
||||||
|
(`*Win*11*x64*.iso`, case-insensitive). If several files match, the highest
|
||||||
|
version-sorted name is used. Check which file was picked with
|
||||||
`./download-images.sh --print-path windows11 --iso`.
|
`./download-images.sh --print-path windows11 --iso`.
|
||||||
|
|
||||||
## Query image paths
|
## Query image paths
|
||||||
@@ -39,7 +42,10 @@ The path interface prints one absolute path without downloading anything:
|
|||||||
```
|
```
|
||||||
|
|
||||||
The Windows target prints the QCOW2 path by default. Add `--iso` to print its
|
The Windows target prints the QCOW2 path by default. Add `--iso` to print its
|
||||||
manually supplied installation ISO path.
|
manually supplied installation ISO path. The QCOW2 is named after the detected
|
||||||
|
ISO (for example `Win11_25H2_English_x64_v2.iso` →
|
||||||
|
`base-qcow2/Win11_25H2_English_x64_v2.qcow2`); if no ISO is present, an
|
||||||
|
existing `*Win*11*x64*.qcow2` in `base-qcow2/` is used instead.
|
||||||
|
|
||||||
Download URLs can be overridden with `DEBIAN_IMAGE_URL`, `ALMA_IMAGE_URL`,
|
Download URLs can be overridden with `DEBIAN_IMAGE_URL`, `ALMA_IMAGE_URL`,
|
||||||
`FEDORA_IMAGE_URL`, and `VIRTIO_WIN_ISO_URL`. The Fedora checksum can be
|
`FEDORA_IMAGE_URL`, and `VIRTIO_WIN_ISO_URL`. The Fedora checksum can be
|
||||||
|
|||||||
+40
-4
@@ -42,8 +42,42 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
virtio_image="${tools_iso_dir}/virtio-win.iso"
|
virtio_image="${tools_iso_dir}/virtio-win.iso"
|
||||||
windows_qcow2_image="${base_qcow2_dir}/Win11_25H2_English_x64_v2.qcow2"
|
|
||||||
windows_iso_image="${install_iso_dir}/Win11_25H2_English_x64_v2.iso"
|
# Find a Windows 11 x64 file in a directory by matching "Win", "11", "x64" and
|
||||||
|
# the extension in that order (case-insensitive). When several match, the
|
||||||
|
# highest version-sorted name wins.
|
||||||
|
find_windows_image() {
|
||||||
|
local dir="$1"
|
||||||
|
local extension="$2"
|
||||||
|
local match
|
||||||
|
|
||||||
|
match="$(
|
||||||
|
shopt -s nullglob nocaseglob
|
||||||
|
files=("${dir}"/*Win*11*x64*."${extension}")
|
||||||
|
((${#files[@]} == 0)) || printf '%s\n' "${files[@]}" | sort -V | tail -n 1
|
||||||
|
)"
|
||||||
|
[[ -n "$match" ]] && printf '%s\n' "$match"
|
||||||
|
}
|
||||||
|
|
||||||
|
windows_iso_path() {
|
||||||
|
if ! find_windows_image "$install_iso_dir" iso; then
|
||||||
|
printf 'Error: no Windows 11 x64 ISO (*Win*11*x64*.iso) found in %s\n' "$install_iso_dir" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# The QCOW2 is named after the installation ISO. If the ISO has been removed,
|
||||||
|
# fall back to an existing matching QCOW2.
|
||||||
|
windows_qcow2_path() {
|
||||||
|
local iso
|
||||||
|
if iso="$(find_windows_image "$install_iso_dir" iso)"; then
|
||||||
|
iso="$(basename -- "$iso")"
|
||||||
|
printf '%s/%s.qcow2\n' "$base_qcow2_dir" "${iso%.*}"
|
||||||
|
elif ! find_windows_image "$base_qcow2_dir" qcow2; then
|
||||||
|
printf 'Error: no Windows 11 x64 ISO (*Win*11*x64*.iso) found in %s\n' "$install_iso_dir" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
debian_url="${DEBIAN_IMAGE_URL:-$debian_url_default}"
|
debian_url="${DEBIAN_IMAGE_URL:-$debian_url_default}"
|
||||||
alma_url="${ALMA_IMAGE_URL:-$alma_url_default}"
|
alma_url="${ALMA_IMAGE_URL:-$alma_url_default}"
|
||||||
@@ -67,6 +101,8 @@ is auto-detected from the host; override it with VM_IMAGE_ARCH.
|
|||||||
then downloads them again from the beginning.
|
then downloads them again from the beginning.
|
||||||
--print-path prints only the absolute image path without downloading it.
|
--print-path prints only the absolute image path without downloading it.
|
||||||
For windows11 it prints the QCOW2 path by default; add --iso for the ISO path.
|
For windows11 it prints the QCOW2 path by default; add --iso for the ISO path.
|
||||||
|
The Windows ISO is found automatically in install-iso/ by matching
|
||||||
|
*Win*11*x64*.iso; the QCOW2 path is named after that ISO.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,9 +117,9 @@ print_image_path() {
|
|||||||
virtio-win) printf '%s\n' "$virtio_image" ;;
|
virtio-win) printf '%s\n' "$virtio_image" ;;
|
||||||
windows11)
|
windows11)
|
||||||
if [[ "$media" == iso ]]; then
|
if [[ "$media" == iso ]]; then
|
||||||
printf '%s\n' "$windows_iso_image"
|
windows_iso_path
|
||||||
else
|
else
|
||||||
printf '%s\n' "$windows_qcow2_image"
|
windows_qcow2_path
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
Reference in new issue
Block a user