mirror of
https://github.com/dockur/windows.git
synced 2026-08-24 15:48:59 +01:00
fix: Reduce amount of state variables (#2107)
This commit is contained in:
@@ -175,6 +175,5 @@ Also see [Dynamic memory allocation](https://github.com/qemus/qemu/blob/master/d
|
|||||||
| `DEBUG` | `N` | Enables verbose debug output. |
|
| `DEBUG` | `N` | Enables verbose debug output. |
|
||||||
| `TRACE` | `N` | Enables shell command tracing. |
|
| `TRACE` | `N` | Enables shell command tracing. |
|
||||||
| `LOG` | `N` | Saves all output from `install.bat` to `C:\OEM\install.log` for troubleshooting. |
|
| `LOG` | `N` | Saves all output from `install.bat` to `C:\OEM\install.log` for troubleshooting. |
|
||||||
| `DETECTED` | | Overrides the automatically detected Windows image identifier. |
|
|
||||||
| `SERIAL` | `mon:stdio` | QEMU serial device configuration. |
|
| `SERIAL` | `mon:stdio` | QEMU serial device configuration. |
|
||||||
| `MONITOR` | | QEMU monitor configuration. |
|
| `MONITOR` | | QEMU monitor configuration. |
|
||||||
|
|||||||
+24
-54
@@ -13,7 +13,6 @@ set -Eeuo pipefail
|
|||||||
: "${REMOVE:=""}"
|
: "${REMOVE:=""}"
|
||||||
: "${VERSION:=""}"
|
: "${VERSION:=""}"
|
||||||
: "${COMMAND:=""}"
|
: "${COMMAND:=""}"
|
||||||
: "${DETECTED:=""}"
|
|
||||||
: "${KEYBOARD:=""}"
|
: "${KEYBOARD:=""}"
|
||||||
: "${LANGUAGE:=""}"
|
: "${LANGUAGE:=""}"
|
||||||
: "${USERNAME:=""}"
|
: "${USERNAME:=""}"
|
||||||
@@ -41,7 +40,7 @@ MIRRORS=4
|
|||||||
|
|
||||||
parseVersion() {
|
parseVersion() {
|
||||||
|
|
||||||
SUGGEST=""
|
DETECTED=""
|
||||||
VERSION=$(strip "$VERSION")
|
VERSION=$(strip "$VERSION")
|
||||||
[ -z "$VERSION" ] && VERSION="win11"
|
[ -z "$VERSION" ] && VERSION="win11"
|
||||||
|
|
||||||
@@ -51,41 +50,49 @@ parseVersion() {
|
|||||||
"11e" | "win11e" | "windows11e" | "windows 11e" )
|
"11e" | "win11e" | "windows11e" | "windows 11e" )
|
||||||
VERSION="win11x64-enterprise-eval" ;;
|
VERSION="win11x64-enterprise-eval" ;;
|
||||||
"11l" | "11ltsc" | "ltsc11" | "win11l" | "win11-ltsc" | "win11x64-ltsc" )
|
"11l" | "11ltsc" | "ltsc11" | "win11l" | "win11-ltsc" | "win11x64-ltsc" )
|
||||||
VERSION="win11x64-enterprise-ltsc-eval" ;;
|
VERSION="win11x64-enterprise-ltsc-eval"
|
||||||
|
DETECTED="win11x64-ltsc" ;;
|
||||||
"11i" | "11iot" | "iot11" | "win11i" | "win11-iot" | "win11x64-iot" )
|
"11i" | "11iot" | "iot11" | "win11i" | "win11-iot" | "win11x64-iot" )
|
||||||
VERSION="win11x64-enterprise-iot-eval" ;;
|
VERSION="win11x64-enterprise-iot-eval"
|
||||||
|
DETECTED="win11x64-iot" ;;
|
||||||
"10" | "10p" | "win10" | "pro10" | "win10p" | "windows10" | "windows 10" )
|
"10" | "10p" | "win10" | "pro10" | "win10p" | "windows10" | "windows 10" )
|
||||||
VERSION="win10x64" ;;
|
VERSION="win10x64" ;;
|
||||||
"10e" | "win10e" | "windows10e" | "windows 10e" )
|
"10e" | "win10e" | "windows10e" | "windows 10e" )
|
||||||
VERSION="win10x64-enterprise-eval" ;;
|
VERSION="win10x64-enterprise-eval" ;;
|
||||||
"10l" | "10ltsc" | "ltsc10" | "win10l" | "win10-ltsc" | "win10x64-ltsc" )
|
"10l" | "10ltsc" | "ltsc10" | "win10l" | "win10-ltsc" | "win10x64-ltsc" )
|
||||||
VERSION="win10x64-enterprise-ltsc-eval" ;;
|
VERSION="win10x64-enterprise-ltsc-eval"
|
||||||
|
DETECTED="win10x64-ltsc" ;;
|
||||||
"10i" | "10iot" | "iot10" | "win10i" | "win10-iot" | "win10x64-iot" )
|
"10i" | "10iot" | "iot10" | "win10i" | "win10-iot" | "win10x64-iot" )
|
||||||
VERSION="win10x64-enterprise-iot-eval" ;;
|
VERSION="win10x64-enterprise-iot-eval"
|
||||||
|
DETECTED="win10x64-iot" ;;
|
||||||
"8" | "8p" | "81" | "81p" | "pro8" | "8.1" | "win8" | "win8p" | "win81" | "win81p" | "windows 8" )
|
"8" | "8p" | "81" | "81p" | "pro8" | "8.1" | "win8" | "win8p" | "win81" | "win81p" | "windows 8" )
|
||||||
VERSION="win81x64" ;;
|
VERSION="win81x64" ;;
|
||||||
"8e" | "81e" | "8.1e" | "win8e" | "win81e" | "windows 8e" )
|
"8e" | "81e" | "8.1e" | "win8e" | "win81e" | "windows 8e" )
|
||||||
VERSION="win81x64-enterprise-eval" ;;
|
VERSION="win81x64-enterprise-eval" ;;
|
||||||
"7" | "win7" | "windows7" | "windows 7" )
|
"7" | "win7" | "windows7" | "windows 7" )
|
||||||
VERSION="win7x64" ;;
|
VERSION="win7x64"
|
||||||
|
DETECTED="win7x64-ultimate" ;;
|
||||||
"7u" | "win7u" | "windows7u" | "windows 7u" )
|
"7u" | "win7u" | "windows7u" | "windows 7u" )
|
||||||
VERSION="win7x64-ultimate" ;;
|
VERSION="win7x64-ultimate" ;;
|
||||||
"7e" | "win7e" | "windows7e" | "windows 7e" )
|
"7e" | "win7e" | "windows7e" | "windows 7e" )
|
||||||
VERSION="win7x64-enterprise" ;;
|
VERSION="win7x64-enterprise" ;;
|
||||||
"7x86" | "win7x86" | "win732" | "windows7x86" )
|
"7x86" | "win7x86" | "win732" | "windows7x86" )
|
||||||
VERSION="win7x86" ;;
|
VERSION="win7x86"
|
||||||
|
DETECTED="win7x86-ultimate" ;;
|
||||||
"7ux86" | "7u32" | "win7x86-ultimate" )
|
"7ux86" | "7u32" | "win7x86-ultimate" )
|
||||||
VERSION="win7x86-ultimate" ;;
|
VERSION="win7x86-ultimate" ;;
|
||||||
"7ex86" | "7e32" | "win7x86-enterprise" )
|
"7ex86" | "7e32" | "win7x86-enterprise" )
|
||||||
VERSION="win7x86-enterprise" ;;
|
VERSION="win7x86-enterprise" ;;
|
||||||
"vista" | "vs" | "6" | "winvista" | "windowsvista" | "windows vista" )
|
"vista" | "vs" | "6" | "winvista" | "windowsvista" | "windows vista" )
|
||||||
VERSION="winvistax64" ;;
|
VERSION="winvistax64"
|
||||||
|
DETECTED="winvistax64-ultimate" ;;
|
||||||
"vistu" | "vu" | "6u" | "winvistu" )
|
"vistu" | "vu" | "6u" | "winvistu" )
|
||||||
VERSION="winvistax64-ultimate" ;;
|
VERSION="winvistax64-ultimate" ;;
|
||||||
"viste" | "ve" | "6e" | "winviste" )
|
"viste" | "ve" | "6e" | "winviste" )
|
||||||
VERSION="winvistax64-enterprise" ;;
|
VERSION="winvistax64-enterprise" ;;
|
||||||
"vistax86" | "vista32" | "6x86" | "winvistax86" | "windowsvistax86" )
|
"vistax86" | "vista32" | "6x86" | "winvistax86" | "windowsvistax86" )
|
||||||
VERSION="winvistax86" ;;
|
VERSION="winvistax86"
|
||||||
|
DETECTED="winvistax86-ultimate" ;;
|
||||||
"vux86" | "vu32" | "winvistax86-ultimate" )
|
"vux86" | "vu32" | "winvistax86-ultimate" )
|
||||||
VERSION="winvistax86-ultimate" ;;
|
VERSION="winvistax86-ultimate" ;;
|
||||||
"vex86" | "ve32" | "winvistax86-enterprise" )
|
"vex86" | "ve32" | "winvistax86-enterprise" )
|
||||||
@@ -113,45 +120,18 @@ parseVersion() {
|
|||||||
"2003" | "2003r2" | "win2003" | "win2003r2" | "windows2003" | "windows 2003" )
|
"2003" | "2003r2" | "win2003" | "win2003r2" | "windows2003" | "windows 2003" )
|
||||||
VERSION="win2003r2" ;;
|
VERSION="win2003r2" ;;
|
||||||
"core11" | "core 11" )
|
"core11" | "core 11" )
|
||||||
VERSION="core11" ;;
|
VERSION="core11"
|
||||||
|
DETECTED="win11x64" ;;
|
||||||
"tiny11" | "tiny 11" )
|
"tiny11" | "tiny 11" )
|
||||||
VERSION="tiny11" ;;
|
VERSION="tiny11"
|
||||||
|
DETECTED="win11x64" ;;
|
||||||
"tiny10" | "tiny 10" )
|
"tiny10" | "tiny 10" )
|
||||||
VERSION="tiny10" ;;
|
VERSION="tiny10"
|
||||||
|
DETECTED="win10x64-ltsc" ;;
|
||||||
"reactos" | "react os" )
|
"reactos" | "react os" )
|
||||||
VERSION="reactos" ;;
|
VERSION="reactos" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
SUGGEST=$(getSuggestedVersion "$VERSION")
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
getSuggestedVersion() {
|
|
||||||
|
|
||||||
local id="${1,,}"
|
|
||||||
|
|
||||||
[[ "$id" == http* ]] && return 0
|
|
||||||
|
|
||||||
case "$id" in
|
|
||||||
"win10x64" | "win11x64" )
|
|
||||||
echo "$id" ;;
|
|
||||||
"win7x64" | "win7x86" | "winvistax64" | "winvistax86" )
|
|
||||||
echo "$id-ultimate" ;;
|
|
||||||
"tiny10" )
|
|
||||||
echo "win10x64-ltsc" ;;
|
|
||||||
*"-enterprise-ltsc-eval" )
|
|
||||||
echo "${id%-enterprise-ltsc-eval}-ltsc" ;;
|
|
||||||
*"-enterprise-iot-eval" )
|
|
||||||
echo "${id%-enterprise-iot-eval}-iot" ;;
|
|
||||||
*"-enterprise-ltsc" )
|
|
||||||
echo "${id%-enterprise-ltsc}-ltsc" ;;
|
|
||||||
*"-enterprise-iot" )
|
|
||||||
echo "${id%-enterprise-iot}-iot" ;;
|
|
||||||
*"-eval" )
|
|
||||||
echo "${id%-eval}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +279,7 @@ getLanguage() {
|
|||||||
"pt-"* )
|
"pt-"* )
|
||||||
short="pp"
|
short="pp"
|
||||||
lang="Portuguese"
|
lang="Portuguese"
|
||||||
culture="pt-BR" ;;
|
culture="pt-PT" ;;
|
||||||
"ro" | "ro-"* | "romanian" | "română" | "romana" )
|
"ro" | "ro-"* | "romanian" | "română" | "romana" )
|
||||||
[[ "$input" == "romanian" || "$input" == "română" || "$input" == "romana" ]] && id="ro"
|
[[ "$input" == "romanian" || "$input" == "română" || "$input" == "romana" ]] && id="ro"
|
||||||
short="ro"
|
short="ro"
|
||||||
@@ -1031,16 +1011,6 @@ getDriverFolder() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
switchEdition() {
|
|
||||||
|
|
||||||
local version="$1"
|
|
||||||
|
|
||||||
[[ "${version,,}" == *"-eval" ]] || return 1
|
|
||||||
|
|
||||||
echo "${version::-5}"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
getMido() {
|
getMido() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
|||||||
+3
-18
@@ -1307,6 +1307,7 @@ parseWimHeader() {
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
findImage() {
|
findImage() {
|
||||||
|
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
@@ -1353,16 +1354,6 @@ readImageInfo() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getSuggestion() {
|
|
||||||
|
|
||||||
[ -z "$CUSTOM" ] || return 0
|
|
||||||
[ -n "${REUSED_ISO:-}" ] || return 0
|
|
||||||
|
|
||||||
# A reused ISO may still correspond to the originally requested catalog
|
|
||||||
# version, but the suggestion remains only a preference during detection.
|
|
||||||
echo "${SUGGEST:-}"
|
|
||||||
}
|
|
||||||
|
|
||||||
validateEdition() {
|
validateEdition() {
|
||||||
|
|
||||||
[ -n "$EDITION" ] || return 0
|
[ -n "$EDITION" ] || return 0
|
||||||
@@ -1470,21 +1461,15 @@ detectImageInfo() {
|
|||||||
|
|
||||||
local image_info="$1"
|
local image_info="$1"
|
||||||
|
|
||||||
local desc suggested index rc
|
local desc index rc
|
||||||
|
|
||||||
checkPlatform "$image_info" || {
|
checkPlatform "$image_info" || {
|
||||||
enabled "$DEBUG" && echo "Platform validation failed for the Windows image metadata." >&2
|
enabled "$DEBUG" && echo "Platform validation failed for the Windows image metadata." >&2
|
||||||
exit 67
|
exit 67
|
||||||
}
|
}
|
||||||
|
|
||||||
suggested=$(getSuggestion) || {
|
|
||||||
rc=$?
|
|
||||||
enabled "$DEBUG" && echo "Failed to determine the suggested Windows image edition (status $rc)." >&2
|
|
||||||
return "$rc"
|
|
||||||
}
|
|
||||||
|
|
||||||
local output
|
local output
|
||||||
output=$(detectVersion "$image_info" "$suggested") || {
|
output=$(detectVersion "$image_info") || {
|
||||||
enabled "$DEBUG" && echo "Version detection failed while parsing the Windows image metadata." >&2
|
enabled "$DEBUG" && echo "Version detection failed while parsing the Windows image metadata." >&2
|
||||||
error "Failed to detect Windows version from image metadata!"
|
error "Failed to detect Windows version from image metadata!"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
+24
-62
@@ -43,8 +43,15 @@ selectWindowsImage() {
|
|||||||
local dir="$2"
|
local dir="$2"
|
||||||
local boot="$3"
|
local boot="$3"
|
||||||
|
|
||||||
# Known versions already provide the required image metadata.
|
XML=""
|
||||||
if resolveImage "$VERSION"; then
|
FB="falling back to manual installation!"
|
||||||
|
|
||||||
|
# Known catalog versions already provide the required image metadata.
|
||||||
|
if [ -z "$DETECTED" ] && [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then
|
||||||
|
DETECTED="$VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$DETECTED" ]; then
|
||||||
|
|
||||||
if ! setImage; then
|
if ! setImage; then
|
||||||
return 70
|
return 70
|
||||||
@@ -99,7 +106,7 @@ configureMachine() {
|
|||||||
desc=$(printVariant "$DETECTED" "$DETECTED") || return 78
|
desc=$(printVariant "$DETECTED" "$DETECTED") || return 78
|
||||||
|
|
||||||
if ! checkMemory "$DETECTED" "$desc"; then
|
if ! checkMemory "$DETECTED" "$desc"; then
|
||||||
if [ -n "${REUSED_ISO:-}" ]; then
|
if [ -z "$CUSTOM" ]; then
|
||||||
useOriginalImage "$iso" || return 79
|
useOriginalImage "$iso" || return 79
|
||||||
fi
|
fi
|
||||||
return 79
|
return 79
|
||||||
@@ -220,18 +227,6 @@ startInstall() {
|
|||||||
|
|
||||||
BOOT="$STORAGE/$boot"
|
BOOT="$STORAGE/$boot"
|
||||||
|
|
||||||
REUSED_ISO=""
|
|
||||||
[ -s "$BOOT" ] && REUSED_ISO="Y"
|
|
||||||
|
|
||||||
# Use the suggested answer file for a new automatic download. When an
|
|
||||||
# existing ISO is reused, leave DETECTED empty so its actual image can
|
|
||||||
# be inspected instead.
|
|
||||||
if [ -n "$DETECTED" ]; then
|
|
||||||
DETECTED_ORG="Y"
|
|
||||||
elif [ -z "$REUSED_ISO" ]; then
|
|
||||||
DETECTED="$SUGGEST"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMP="$STORAGE/tmp"
|
TMP="$STORAGE/tmp"
|
||||||
@@ -275,7 +270,7 @@ startInstall() {
|
|||||||
|
|
||||||
if [ -z "$CUSTOM" ]; then
|
if [ -z "$CUSTOM" ]; then
|
||||||
|
|
||||||
if [ -n "$REUSED_ISO" ]; then
|
if [ -s "$BOOT" ]; then
|
||||||
ISO="$TMP/$(basename "$BOOT")"
|
ISO="$TMP/$(basename "$BOOT")"
|
||||||
else
|
else
|
||||||
ISO="$TMP/$file"
|
ISO="$TMP/$file"
|
||||||
@@ -283,9 +278,9 @@ startInstall() {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Keep reusable media at its persistent path until all storage cleanup has
|
# Keep existing media at its persistent path until all storage cleanup has
|
||||||
# completed successfully, so a later failure cannot strand it under $TMP.
|
# completed successfully, so a later failure cannot strand it under $TMP.
|
||||||
if [ -n "$CUSTOM" ] || [ -z "$REUSED_ISO" ]; then
|
if [ -n "$CUSTOM" ] || [ ! -s "$BOOT" ]; then
|
||||||
if ! rm -f -- "$BOOT"; then
|
if ! rm -f -- "$BOOT"; then
|
||||||
error "Failed to remove obsolete ISO file \"$BOOT\" !"
|
error "Failed to remove obsolete ISO file \"$BOOT\" !"
|
||||||
exit 50
|
exit 50
|
||||||
@@ -307,7 +302,7 @@ startInstall() {
|
|||||||
exit 50
|
exit 50
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$CUSTOM" ] && [ -z "$REUSED_ISO" ] && [[ "${VERSION,,}" != "http"* ]]; then
|
if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then
|
||||||
checkMemory "$VERSION" || exit 67
|
checkMemory "$VERSION" || exit 67
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -592,10 +587,18 @@ detectCustom() {
|
|||||||
CUSTOM=""
|
CUSTOM=""
|
||||||
|
|
||||||
findFile "custom.iso" || return 1
|
findFile "custom.iso" || return 1
|
||||||
[ -n "$CUSTOM" ] && return 0
|
|
||||||
|
if [ -n "$CUSTOM" ]; then
|
||||||
|
DETECTED=""
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
findFile "boot.iso" || return 1
|
findFile "boot.iso" || return 1
|
||||||
[ -n "$CUSTOM" ] && return 0
|
|
||||||
|
if [ -n "$CUSTOM" ]; then
|
||||||
|
DETECTED=""
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -621,47 +624,6 @@ removeImage() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveImage() {
|
|
||||||
|
|
||||||
local version="$1"
|
|
||||||
|
|
||||||
XML=""
|
|
||||||
FB="falling back to manual installation!"
|
|
||||||
|
|
||||||
[ -z "$DETECTED" ] || return 0
|
|
||||||
|
|
||||||
# Reused and arbitrary URL media must be inspected because their actual
|
|
||||||
# contents may no longer match the requested VERSION.
|
|
||||||
[ -z "${REUSED_ISO:-}" ] || return 1
|
|
||||||
[[ "${version,,}" != "http"* ]] || return 1
|
|
||||||
|
|
||||||
# Only direct-boot custom media can safely bypass content detection.
|
|
||||||
if [ -n "$CUSTOM" ]; then
|
|
||||||
supportsUnattended "$version" && return 1
|
|
||||||
DETECTED="$version"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local file="/run/assets/$version.xml"
|
|
||||||
|
|
||||||
if [ -s "$file" ]; then
|
|
||||||
DETECTED="$version"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Evaluation media may reuse the normal edition's answer-file template.
|
|
||||||
if [[ "${version,,}" == *"-eval" ]]; then
|
|
||||||
local source="/run/assets/${version%-eval}.xml"
|
|
||||||
|
|
||||||
if [ -s "$source" ]; then
|
|
||||||
DETECTED="$version"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
setImage() {
|
setImage() {
|
||||||
|
|
||||||
supportsXML "${DETECTED,,}" || return 0
|
supportsXML "${DETECTED,,}" || return 0
|
||||||
|
|||||||
+9
-127
@@ -549,97 +549,6 @@ downloadWindowsEval() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getMidoDetected() {
|
|
||||||
|
|
||||||
# Return the answer-file identity for the Microsoft source that actually
|
|
||||||
# succeeded without changing the global DETECTED value.
|
|
||||||
|
|
||||||
local version="${1,,}"
|
|
||||||
local source="${2,,}"
|
|
||||||
local current="$3"
|
|
||||||
local default="$version"
|
|
||||||
local detected
|
|
||||||
|
|
||||||
[ -z "$source" ] && source="$version"
|
|
||||||
|
|
||||||
# Preserve a DETECTED value that existed before SUGGEST was assigned.
|
|
||||||
if enabled "${DETECTED_ORG:-}"; then
|
|
||||||
echo "$current"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Derive the normal answer-file identity from the requested download route.
|
|
||||||
case "$default" in
|
|
||||||
*"-enterprise-ltsc-eval" )
|
|
||||||
default="${default%-enterprise-ltsc-eval}-ltsc" ;;
|
|
||||||
*"-enterprise-iot-eval" )
|
|
||||||
default="${default%-enterprise-iot-eval}-iot" ;;
|
|
||||||
*"-eval" )
|
|
||||||
default="${default%-eval}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Preserve a genuinely different DETECTED override.
|
|
||||||
if [ -n "$current" ] && [[ "${current,,}" != "$default" ]]; then
|
|
||||||
echo "$current"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Select the answer-file identity for the source that actually succeeded.
|
|
||||||
case "$source" in
|
|
||||||
*"-enterprise-ltsc-eval" )
|
|
||||||
detected="${source%-enterprise-ltsc-eval}-ltsc-eval" ;;
|
|
||||||
*"-enterprise-iot-eval" )
|
|
||||||
detected="${source%-enterprise-iot-eval}-iot-eval" ;;
|
|
||||||
*"-eval" )
|
|
||||||
detected="$source" ;;
|
|
||||||
* )
|
|
||||||
detected="${current:-$default}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "$detected"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadWindowsLtsc() {
|
|
||||||
|
|
||||||
local id="$1"
|
|
||||||
local lang="$2"
|
|
||||||
local desc="$3"
|
|
||||||
|
|
||||||
local alternate alternate_desc rc
|
|
||||||
|
|
||||||
case "${id,,}" in
|
|
||||||
"win11${PLATFORM,,}-enterprise-iot-eval" )
|
|
||||||
alternate="win11${PLATFORM,,}-enterprise-ltsc-eval" ;;
|
|
||||||
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
|
||||||
alternate="win11${PLATFORM,,}-enterprise-iot-eval" ;;
|
|
||||||
* )
|
|
||||||
error "Invalid VERSION specified, value \"$id\" is not recognized!"
|
|
||||||
return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# IoT and LTSC share related evaluation sources and may become unavailable
|
|
||||||
# independently, so use the sibling edition as a compatibility fallback.
|
|
||||||
if downloadWindowsEval "$id" "$lang" "$desc" > /dev/null 2>&1; then
|
|
||||||
MIDO_SOURCE="$id"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
rc=$?
|
|
||||||
(( rc == 1 )) || return "$rc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
alternate_desc=$(printEdition "$alternate" "$alternate" "Y")
|
|
||||||
|
|
||||||
info "Primary download source failed, trying $alternate_desc instead..."
|
|
||||||
|
|
||||||
downloadWindowsEval "$alternate" "$lang" "$alternate_desc" || return
|
|
||||||
|
|
||||||
MIDO_SOURCE="$alternate"
|
|
||||||
warn "the requested $desc was unavailable, using $alternate_desc instead."
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
getWindows() {
|
getWindows() {
|
||||||
|
|
||||||
local version="$1"
|
local version="$1"
|
||||||
@@ -649,7 +558,6 @@ getWindows() {
|
|||||||
|
|
||||||
local language edition rc
|
local language edition rc
|
||||||
|
|
||||||
MIDO_SOURCE=""
|
|
||||||
MIDO_STATIC="N"
|
MIDO_STATIC="N"
|
||||||
|
|
||||||
language=$(getLanguage "$lang" "desc")
|
language=$(getLanguage "$lang" "desc")
|
||||||
@@ -693,17 +601,6 @@ getWindows() {
|
|||||||
"win10x64" | "win11${PLATFORM,,}" )
|
"win10x64" | "win11${PLATFORM,,}" )
|
||||||
|
|
||||||
if downloadWindows "$version" "$lang" "$edition"; then
|
if downloadWindows "$version" "$lang" "$edition"; then
|
||||||
MIDO_SOURCE="$version"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
rc=$?
|
|
||||||
(( rc == 1 )) || return "$rc"
|
|
||||||
fi ;;
|
|
||||||
|
|
||||||
"win11${PLATFORM,,}-enterprise-iot-eval" | \
|
|
||||||
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
|
||||||
|
|
||||||
if downloadWindowsLtsc "$version" "$lang" "$edition"; then
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rc=$?
|
rc=$?
|
||||||
@@ -713,7 +610,6 @@ getWindows() {
|
|||||||
"win11${PLATFORM,,}-enterprise"* )
|
"win11${PLATFORM,,}-enterprise"* )
|
||||||
|
|
||||||
if downloadWindowsEval "$version" "$lang" "$edition"; then
|
if downloadWindowsEval "$version" "$lang" "$edition"; then
|
||||||
MIDO_SOURCE="$version"
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rc=$?
|
rc=$?
|
||||||
@@ -724,7 +620,6 @@ getWindows() {
|
|||||||
"win2019-hv" | "win2016-eval" | "win2012r2-eval" )
|
"win2019-hv" | "win2016-eval" | "win2012r2-eval" )
|
||||||
|
|
||||||
if downloadWindowsEval "$version" "$lang" "$edition"; then
|
if downloadWindowsEval "$version" "$lang" "$edition"; then
|
||||||
MIDO_SOURCE="$version"
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rc=$?
|
rc=$?
|
||||||
@@ -745,12 +640,6 @@ getWindows() {
|
|||||||
|
|
||||||
MIDO_STATIC="Y"
|
MIDO_STATIC="Y"
|
||||||
|
|
||||||
if [[ "${version,,}" == "win2008r2"* ]]; then
|
|
||||||
MIDO_SOURCE="win2008r2-eval"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
MIDO_SOURCE="$version"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1373,10 +1262,9 @@ downloadImage() {
|
|||||||
local version="$2"
|
local version="$2"
|
||||||
local lang="$3"
|
local lang="$3"
|
||||||
|
|
||||||
local detected="$DETECTED"
|
local requested="$version"
|
||||||
local requested="$version" switched=""
|
|
||||||
local tried="n" success="n" seconds="5"
|
local tried="n" success="n" seconds="5"
|
||||||
local i url sum size base language desc web_desc metadata rc
|
local i url sum size base language desc web_desc rc
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
if [[ "${version,,}" == "http"* ]]; then
|
||||||
|
|
||||||
@@ -1436,17 +1324,15 @@ downloadImage() {
|
|||||||
|
|
||||||
if [[ "$success" == "y" ]]; then
|
if [[ "$success" == "y" ]]; then
|
||||||
|
|
||||||
detected=$(getMidoDetected "$version" "$MIDO_SOURCE" "$DETECTED")
|
url=$(getMido "$version" "$lang" "")
|
||||||
metadata="${MIDO_SOURCE:-$version}"
|
|
||||||
url=$(getMido "$metadata" "$lang" "")
|
|
||||||
|
|
||||||
sum=""
|
sum=""
|
||||||
size=""
|
size=""
|
||||||
|
|
||||||
# Apply the metadata belonging to the configured static URL.
|
# Apply the metadata belonging to the configured static URL.
|
||||||
if [[ "${MIDO_URL%%\?*}" == "${url%%\?*}" ]]; then
|
if [[ "${MIDO_URL%%\?*}" == "${url%%\?*}" ]]; then
|
||||||
size=$(getMido "$metadata" "$lang" "size")
|
size=$(getMido "$version" "$lang" "size")
|
||||||
sum=$(getMido "$metadata" "$lang" "sum")
|
sum=$(getMido "$version" "$lang" "sum")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local download_desc="$desc"
|
local download_desc="$desc"
|
||||||
@@ -1455,8 +1341,6 @@ downloadImage() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if tryDownload "$iso" "$MIDO_URL" "$sum" "$size" "$download_desc" "$seconds" "$web_desc"; then
|
if tryDownload "$iso" "$MIDO_URL" "$sum" "$size" "$download_desc" "$seconds" "$web_desc"; then
|
||||||
# Commit the candidate only after the image was downloaded and verified.
|
|
||||||
DETECTED="$detected"
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rc=$?
|
rc=$?
|
||||||
@@ -1468,14 +1352,12 @@ downloadImage() {
|
|||||||
|
|
||||||
# If an evaluation version was requested, switch to the
|
# If an evaluation version was requested, switch to the
|
||||||
# normal edition since none of our mirrors provide those.
|
# normal edition since none of our mirrors provide those.
|
||||||
if switched=$(switchEdition "$version"); then
|
if [[ "${version,,}" == *"-eval" ]]; then
|
||||||
|
|
||||||
validDownload "$switched" || return 1
|
version="${version::-5}"
|
||||||
version="$switched"
|
validDownload "$version" || return 1
|
||||||
|
|
||||||
if ! enabled "${DETECTED_ORG:-}"; then
|
[ -n "$DETECTED" ] || DETECTED="$version"
|
||||||
DETECTED="${SUGGEST:-$version}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
desc=$(printVariant "$DETECTED" "" "Y")
|
desc=$(printVariant "$DETECTED" "" "Y")
|
||||||
web_desc=$(printVariant "$DETECTED" "")
|
web_desc=$(printVariant "$DETECTED" "")
|
||||||
|
|||||||
Reference in New Issue
Block a user