mirror of
https://github.com/dockur/windows.git
synced 2026-08-24 15:48:59 +01:00
feat: Centralize platform and image state checks (#2139)
This commit is contained in:
+1
-1
@@ -404,7 +404,7 @@ printVersion() {
|
|||||||
|
|
||||||
if [ -z "$desc" ]; then
|
if [ -z "$desc" ]; then
|
||||||
desc="Windows"
|
desc="Windows"
|
||||||
[[ "${PLATFORM,,}" != "x64" ]] && desc+=" for ${PLATFORM}"
|
isPlatform "x64" || desc+=" for ${PLATFORM}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$desc"
|
echo "$desc"
|
||||||
|
|||||||
+1
-1
@@ -1644,7 +1644,7 @@ extractESD() {
|
|||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
html "$msg..."
|
html "$msg..."
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if isPlatform "x64"; then
|
||||||
LABEL="CCCOMA_X64FRE_EN-US_DV9"
|
LABEL="CCCOMA_X64FRE_EN-US_DV9"
|
||||||
else
|
else
|
||||||
LABEL="CPBA_A64FRE_EN-US_DV9"
|
LABEL="CPBA_A64FRE_EN-US_DV9"
|
||||||
|
|||||||
+15
-10
@@ -387,7 +387,7 @@ startInstall() {
|
|||||||
|
|
||||||
if ! isCustomImage; then
|
if ! isCustomImage; then
|
||||||
|
|
||||||
if [ -s "$BOOT" ]; then
|
if hasImage "$BOOT"; then
|
||||||
ISO="$TMP/$(basename "$BOOT")"
|
ISO="$TMP/$(basename "$BOOT")"
|
||||||
else
|
else
|
||||||
ISO="$TMP/$file"
|
ISO="$TMP/$file"
|
||||||
@@ -397,7 +397,7 @@ startInstall() {
|
|||||||
|
|
||||||
# Keep existing 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 isCustomImage || [ ! -s "$BOOT" ]; then
|
if isCustomImage || ! hasImage "$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\" !"
|
||||||
return 50
|
return 50
|
||||||
@@ -426,7 +426,7 @@ startInstall() {
|
|||||||
|
|
||||||
# Work from the temporary directory so the persistent source path can
|
# Work from the temporary directory so the persistent source path can
|
||||||
# later contain either the preserved ISO or the rebuilt installation image.
|
# later contain either the preserved ISO or the rebuilt installation image.
|
||||||
if ! isCustomImage && [ -f "$BOOT" ] && [ -s "$BOOT" ]; then
|
if ! isCustomImage && hasImage "$BOOT"; then
|
||||||
if ! mv -f -- "$BOOT" "$ISO"; then
|
if ! mv -f -- "$BOOT" "$ISO"; then
|
||||||
error "Failed to move ISO file from \"$BOOT\" to \"$ISO\" !"
|
error "Failed to move ISO file from \"$BOOT\" to \"$ISO\" !"
|
||||||
return 50
|
return 50
|
||||||
@@ -454,7 +454,7 @@ skipUnattended() {
|
|||||||
|
|
||||||
# When automatic preparation fails, inspect extracted media to determine
|
# When automatic preparation fails, inspect extracted media to determine
|
||||||
# whether it can still be booted manually using legacy firmware.
|
# whether it can still be booted manually using legacy firmware.
|
||||||
if enabled "$aborted" && [[ "${PLATFORM,,}" == "x64" ]] && [ -d "$dir" ]; then
|
if enabled "$aborted" && isPlatform "x64" && [ -d "$dir" ]; then
|
||||||
|
|
||||||
efi=$(find "$dir" -maxdepth 1 -type d -iname efi -print -quit) || return 1
|
efi=$(find "$dir" -maxdepth 1 -type d -iname efi -print -quit) || return 1
|
||||||
efi32=$(find "$dir" -maxdepth 3 -type f -ipath '*/efi/boot/bootia32.efi' -print -quit) || return 1
|
efi32=$(find "$dir" -maxdepth 3 -type f -ipath '*/efi/boot/bootia32.efi' -print -quit) || return 1
|
||||||
@@ -581,7 +581,7 @@ finishInstall() {
|
|||||||
|
|
||||||
local base secure=0
|
local base secure=0
|
||||||
|
|
||||||
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
|
if ! hasImage "$iso"; then
|
||||||
error "Failed to find ISO file: $iso" && return 1
|
error "Failed to find ISO file: $iso" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -613,7 +613,7 @@ finishInstall() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if isPlatform "x64"; then
|
||||||
if isLegacyBoot; then
|
if isLegacyBoot; then
|
||||||
|
|
||||||
writeState "mode" "$BOOT_MODE" || {
|
writeState "mode" "$BOOT_MODE" || {
|
||||||
@@ -710,7 +710,7 @@ findFile() {
|
|||||||
file="$STORAGE/$base"
|
file="$STORAGE/$base"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$file" ] || [ ! -s "$file" ]; then
|
if ! hasImage "$file"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -777,11 +777,16 @@ isURL() {
|
|||||||
[[ "${value,,}" == "http"* ]]
|
[[ "${value,,}" == "http"* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPlatform() {
|
||||||
|
|
||||||
|
local platform="$1"
|
||||||
|
|
||||||
|
[[ "${PLATFORM,,}" == "${platform,,}" ]]
|
||||||
|
}
|
||||||
|
|
||||||
isLegacyBoot() {
|
isLegacyBoot() {
|
||||||
|
|
||||||
local mode="${BOOT_MODE:-}"
|
[[ "${BOOT_MODE,,}" == "windows_legacy" ]]
|
||||||
|
|
||||||
[[ "${mode,,}" == "windows_legacy" ]]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hasBootMarker() {
|
hasBootMarker() {
|
||||||
|
|||||||
+3
-3
@@ -70,7 +70,7 @@ setMachine() {
|
|||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "${id,,}" == "reactos" ]] && [ -z "$CUSTOM" ]; then
|
if [[ "${id,,}" == "reactos" ]] && ! isCustomImage; then
|
||||||
# The ISO is a Live-CD so we need to disable the data disk
|
# 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.
|
# as it will be always wiped during the next runs currently.
|
||||||
DISK_DISABLE="Y"
|
DISK_DISABLE="Y"
|
||||||
@@ -115,7 +115,7 @@ restoreMachine() {
|
|||||||
# Restore the saved machine only when q35 is still the default;
|
# Restore the saved machine only when q35 is still the default;
|
||||||
# an explicit user-selected machine must remain untouched.
|
# an explicit user-selected machine must remain untouched.
|
||||||
[[ "${MACHINE,,}" != "q35" ]] && return 0
|
[[ "${MACHINE,,}" != "q35" ]] && return 0
|
||||||
[[ "${PLATFORM,,}" != "x64" ]] && return 0
|
isPlatform "x64" || return 0
|
||||||
|
|
||||||
MACHINE=""
|
MACHINE=""
|
||||||
restoreState "MACHINE" "old" || return 1
|
restoreState "MACHINE" "old" || return 1
|
||||||
@@ -1016,7 +1016,7 @@ detectLegacy() {
|
|||||||
local dir="$1"
|
local dir="$1"
|
||||||
local marker
|
local marker
|
||||||
|
|
||||||
[[ "${PLATFORM,,}" == "x64" ]] || return 1
|
isPlatform "x64" || return 1
|
||||||
|
|
||||||
# Legacy media is identified from setup marker files rather than WIM
|
# Legacy media is identified from setup marker files rather than WIM
|
||||||
# metadata. The order is intentional because several releases share markers.
|
# metadata. The order is intentional because several releases share markers.
|
||||||
|
|||||||
+2
-2
@@ -320,7 +320,7 @@ downloadWindowsEval() {
|
|||||||
type="iot"
|
type="iot"
|
||||||
winVer="windows-11-iot-enterprise-ltsc-eval" ;;
|
winVer="windows-11-iot-enterprise-ltsc-eval" ;;
|
||||||
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||||
if [[ "${PLATFORM,,}" == "arm64" ]]; then
|
if isPlatform "arm64"; then
|
||||||
type="iot"
|
type="iot"
|
||||||
winVer="windows-11-iot-enterprise-ltsc-eval"
|
winVer="windows-11-iot-enterprise-ltsc-eval"
|
||||||
else
|
else
|
||||||
@@ -595,7 +595,7 @@ getWindows() {
|
|||||||
"win11${PLATFORM,,}-enterprise"* ) ;;
|
"win11${PLATFORM,,}-enterprise"* ) ;;
|
||||||
* )
|
* )
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" != "x64" ]]; then
|
if ! isPlatform "x64"; then
|
||||||
error "No download for the ${PLATFORM^^} platform available for $edition!"
|
error "No download for the ${PLATFORM^^} platform available for $edition!"
|
||||||
MIDO_URL=""
|
MIDO_URL=""
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
+2
-2
@@ -346,7 +346,7 @@ sendKey() {
|
|||||||
|
|
||||||
needsBootKey() {
|
needsBootKey() {
|
||||||
|
|
||||||
[ ! -s "$BOOT" ] && return 1
|
hasImage "$BOOT" || return 1
|
||||||
|
|
||||||
hasCompletedInstall && return 1
|
hasCompletedInstall && return 1
|
||||||
supportsBootKey "$DETECTED" || return 1
|
supportsBootKey "$DETECTED" || return 1
|
||||||
@@ -363,7 +363,7 @@ bootKeyReady() {
|
|||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "arm64" ]]; then
|
if isPlatform "arm64"; then
|
||||||
grep -Eq "$UEFI_USB_BOOT_PATTERN" "$QEMU_PTY"
|
grep -Eq "$UEFI_USB_BOOT_PATTERN" "$QEMU_PTY"
|
||||||
else
|
else
|
||||||
grep -Eq "$UEFI_DVD_BOOT_PATTERN" "$QEMU_PTY"
|
grep -Eq "$UEFI_DVD_BOOT_PATTERN" "$QEMU_PTY"
|
||||||
|
|||||||
Reference in New Issue
Block a user