fix: Use XML capability checks for image preparation (#2047)

This commit is contained in:
Kroese
2026-08-05 04:43:37 +02:00
committed by GitHub
parent f8c72b3404
commit b296a37d65
4 changed files with 129 additions and 130 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ hasAnswerFile() {
return 1 return 1
} }
stageAnswer() { addAnswerFile() {
local asset="$1" local asset="$1"
local language="$2" local language="$2"
+7 -5
View File
@@ -938,7 +938,7 @@ isLegacy() {
local id="$1" local id="$1"
case "${id,,}" in case "${id,,}" in
"win9"* | "win2k"* | "winxp"* | "win2003"* | \ "win9"* | "winnt4"* | "win2k"* | "winxp"* | "win2003"* | \
"winvista"* | "win7"* | "win2008"* | "reactos" ) "winvista"* | "win7"* | "win2008"* | "reactos" )
return 0 ;; return 0 ;;
esac esac
@@ -946,24 +946,26 @@ isLegacy() {
return 1 return 1
} }
supportsXML() { supportsUnattended() {
local id="$1" local id="$1"
case "${id,,}" in case "${id,,}" in
"win9"* | "winxp"* | "win2k"* | "win2003"* | "reactos" ) "win9"* | "winnt4"* | "reactos" )
return 1 ;; return 1 ;;
esac esac
return 0 return 0
} }
supportsUnattended() { supportsXML() {
local id="$1" local id="$1"
supportsUnattended "$id" || return 1
case "${id,,}" in case "${id,,}" in
"win9"* | "reactos" ) "win2k"* | "winxp"* | "win2003"* )
return 1 ;; return 1 ;;
esac esac
+4 -7
View File
@@ -614,14 +614,10 @@ canUseSetupImage() {
local id="$1" local id="$1"
local iso="$2" local iso="$2"
# Legacy installers and ReactOS require modifying or directly booting their supportsXML "$id" || return 1
# media. Standalone ESDs and nested archives are not directly bootable ISOs. [[ "${iso,,}" == *".esd" ]] && return 1
case "${id,,}" in
"win9"* | "winxp"* | "win2k"* | "win2003"* | "reactos" )
return 1 ;;
esac
[[ "${iso,,}" != *".esd" ]] && ! enabled "${UNPACK:-}" return 0
} }
createImageDirectory() { createImageDirectory() {
@@ -1748,6 +1744,7 @@ buildImage() {
desc=$(printVariant "$DETECTED" "ISO") desc=$(printVariant "$DETECTED" "ISO")
local msg="Building $desc image" local msg="Building $desc image"
[[ "${ISO,,}" == *.esd ]] && msg+=" from ESD file"
info "$msg..." && html "$msg..." info "$msg..." && html "$msg..."
[ -z "$LABEL" ] && LABEL="Windows" [ -z "$LABEL" ] && LABEL="Windows"
+117 -117
View File
@@ -142,7 +142,7 @@ prepareWindowsImage() {
# Prefer the original ISO with a small setup image whenever possible. # Prefer the original ISO with a small setup image whenever possible.
if canUseSetupImage "$DETECTED" "$iso"; then if canUseSetupImage "$DETECTED" "$iso"; then
if ! stageSetup "$XML" "$LANGUAGE" "$TMP/setup"; then if ! createOverlay "$XML" "$LANGUAGE" "$TMP/setup"; then
skipUnattended "$dir" "$iso" "$boot" || return 84 skipUnattended "$dir" "$iso" "$boot" || return 84
handled=1 handled=1
return 0 return 0
@@ -913,118 +913,6 @@ extractImage() {
return 0 return 0
} }
setMachine() {
local id="$1"
local iso="$2"
local dir="$3"
local desc="$4"
ETFS="boot/etfsboot.com"
local version=""
case "${id,,}" in
"win2k"* ) version="2k" ;;
"winxp"* ) version="xp" ;;
"win2003"* ) version="2k3" ;;
esac
if [ -n "$version" ]; then
if ! legacyInstall "$iso" "$dir" "$desc" "$version"; then
error "Failed to prepare $desc ISO!"
return 1
fi
fi
if isLegacy "$id"; then
writeState "mode" "windows_legacy" || return 1
case "${id,,}" in
"win9"* | "win2k"* | "reactos" )
writeState "vga" "cirrus" || return 1 ;;
* )
writeState "vga" "std" || return 1 ;;
esac
fi
restoreBootMode || return 1
case "${id,,}" in
"win9"* )
writeState "usb" "N" || return 1
writeState "net" "pcnet" || return 1
writeState "type" "auto" || return 1
writeState "old" "pc-i440fx-2.4" || return 1 ;;
"win2k"* )
writeState "old" "pc" || return 1
writeState "type" "auto" || return 1
writeState "net" "rtl8139" || return 1
writeState "usb" "pci-ohci" || return 1 ;;
"winxpx"* | "win2003"* )
writeState "type" "blk" || return 1
writeState "net" "rtl8139" || return 1
writeState "sound" "usb-audio" || return 1 ;;
"reactos" )
writeState "old" "pc" || return 1
writeState "type" "auto" || return 1
writeState "net" "rtl8139" || return 1
writeState "usb" "pci-ohci" || return 1 ;;
esac
if [[ "${id,,}" == "reactos" ]] && [ -z "$CUSTOM" ]; then
# The ISO is a Live-CD so we need to disable the data disk
# as it will be always wiped during the next runs currently.
REMOVE="N"
DISK_DISABLE="Y"
fi
restoreMachine || return 1
case "${id,,}" in
"win9"* | "win2k"* | *"x86"* | "reactos" )
# Legacy 32-bit Windows may enter an incompatible PAE/DEP path when the
# NX flag is exposed, causing installation failures or repeated resets.
writeState "flag" "nx=off" || return 1 ;;
esac
case "${id,,}" in
"win9"* | "win2k"* | "winxp"* | "win2003"* | \
"winvistax86"* | "win7x86"* | "reactos" )
if isQ35 "$MACHINE"; then
# pc-q35-2.11 began advertising a synthetic 64-bit PCI MMIO aperture.
# Older Windows ACPI implementations may reject that resource layout,
# so retain the pre-2.11 behavior for these guests to prevent a
# blue screen on XP and others if the 64 bit PCI hole size is >2G.
writeState "args" "-global q35-pcihost.x-pci-hole64-fix=false" || return 1
fi ;;
esac
return 0
}
prepareImage() { prepareImage() {
local iso="$1" local iso="$1"
@@ -1318,13 +1206,13 @@ addDrivers() {
return 0 return 0
} }
stageSetup() { createOverlay() {
local asset="$1" local asset="$1"
local language="$2" local language="$2"
local stage="$3" local stage="$3"
supportsUnattended "${DETECTED,,}" || return 0 supportsXML "${DETECTED,,}" || return 0
local msg="Creating overlay image..." local msg="Creating overlay image..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
@@ -1349,7 +1237,7 @@ stageSetup() {
return 1 return 1
fi fi
stageAnswer "$asset" "$language" "$stage" || return 1 addAnswerFile "$asset" "$language" "$stage" || return 1
return 0 return 0
} }
@@ -1367,7 +1255,7 @@ updateImage() {
local dat="${xml//.xml/.dat}" local dat="${xml//.xml/.dat}"
local desc path src wim name info local desc path src wim name info
supportsUnattended "${DETECTED,,}" || return 0 supportsXML "${DETECTED,,}" || return 0
if [ ! -s "$asset" ] || [ ! -f "$asset" ]; then if [ ! -s "$asset" ] || [ ! -f "$asset" ]; then
asset="" asset=""
@@ -1656,6 +1544,118 @@ restoreMachineState() {
return 0 return 0
} }
setMachine() {
local id="$1"
local iso="$2"
local dir="$3"
local desc="$4"
ETFS="boot/etfsboot.com"
local version=""
case "${id,,}" in
"win2k"* ) version="2k" ;;
"winxp"* ) version="xp" ;;
"win2003"* ) version="2k3" ;;
esac
if [ -n "$version" ]; then
if ! legacyInstall "$iso" "$dir" "$desc" "$version"; then
error "Failed to prepare $desc ISO!"
return 1
fi
fi
if isLegacy "$id"; then
writeState "mode" "windows_legacy" || return 1
case "${id,,}" in
"win9"* | "win2k"* | "reactos" )
writeState "vga" "cirrus" || return 1 ;;
* )
writeState "vga" "std" || return 1 ;;
esac
fi
restoreBootMode || return 1
case "${id,,}" in
"win9"* )
writeState "usb" "N" || return 1
writeState "net" "pcnet" || return 1
writeState "type" "auto" || return 1
writeState "old" "pc-i440fx-2.4" || return 1 ;;
"win2k"* )
writeState "old" "pc" || return 1
writeState "type" "auto" || return 1
writeState "net" "rtl8139" || return 1
writeState "usb" "pci-ohci" || return 1 ;;
"winxpx"* | "win2003"* )
writeState "type" "blk" || return 1
writeState "net" "rtl8139" || return 1
writeState "sound" "usb-audio" || return 1 ;;
"reactos" )
writeState "old" "pc" || return 1
writeState "type" "auto" || return 1
writeState "net" "rtl8139" || return 1
writeState "usb" "pci-ohci" || return 1 ;;
esac
if [[ "${id,,}" == "reactos" ]] && [ -z "$CUSTOM" ]; then
# The ISO is a Live-CD so we need to disable the data disk
# as it will be always wiped during the next runs currently.
REMOVE="N"
DISK_DISABLE="Y"
fi
restoreMachine || return 1
case "${id,,}" in
"win9"* | "win2k"* | *"x86"* | "reactos" )
# Legacy 32-bit Windows may enter an incompatible PAE/DEP path when the
# NX flag is exposed, causing installation failures or repeated resets.
writeState "flag" "nx=off" || return 1 ;;
esac
case "${id,,}" in
"win9"* | "win2k"* | "winxp"* | "win2003"* | \
"winvistax86"* | "win7x86"* | "reactos" )
if isQ35 "$MACHINE"; then
# pc-q35-2.11 began advertising a synthetic 64-bit PCI MMIO aperture.
# Older Windows ACPI implementations may reject that resource layout,
# so retain the pre-2.11 behavior for these guests to prevent a
# blue screen on XP and others if the 64 bit PCI hole size is >2G.
writeState "args" "-global q35-pcihost.x-pci-hole64-fix=false" || return 1
fi ;;
esac
return 0
}
startWindows startWindows
return 0 return 0