mirror of
https://github.com/dockur/windows.git
synced 2026-08-24 07:39:00 +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
|
||||
desc="Windows"
|
||||
[[ "${PLATFORM,,}" != "x64" ]] && desc+=" for ${PLATFORM}"
|
||||
isPlatform "x64" || desc+=" for ${PLATFORM}"
|
||||
fi
|
||||
|
||||
echo "$desc"
|
||||
|
||||
+1
-1
@@ -1644,7 +1644,7 @@ extractESD() {
|
||||
fKill "progress.sh"
|
||||
html "$msg..."
|
||||
|
||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
||||
if isPlatform "x64"; then
|
||||
LABEL="CCCOMA_X64FRE_EN-US_DV9"
|
||||
else
|
||||
LABEL="CPBA_A64FRE_EN-US_DV9"
|
||||
|
||||
+15
-10
@@ -387,7 +387,7 @@ startInstall() {
|
||||
|
||||
if ! isCustomImage; then
|
||||
|
||||
if [ -s "$BOOT" ]; then
|
||||
if hasImage "$BOOT"; then
|
||||
ISO="$TMP/$(basename "$BOOT")"
|
||||
else
|
||||
ISO="$TMP/$file"
|
||||
@@ -397,7 +397,7 @@ startInstall() {
|
||||
|
||||
# Keep existing media at its persistent path until all storage cleanup has
|
||||
# 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
|
||||
error "Failed to remove obsolete ISO file \"$BOOT\" !"
|
||||
return 50
|
||||
@@ -426,7 +426,7 @@ startInstall() {
|
||||
|
||||
# Work from the temporary directory so the persistent source path can
|
||||
# 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
|
||||
error "Failed to move ISO file from \"$BOOT\" to \"$ISO\" !"
|
||||
return 50
|
||||
@@ -454,7 +454,7 @@ skipUnattended() {
|
||||
|
||||
# When automatic preparation fails, inspect extracted media to determine
|
||||
# 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
|
||||
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
|
||||
|
||||
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
|
||||
if ! hasImage "$iso"; then
|
||||
error "Failed to find ISO file: $iso" && return 1
|
||||
fi
|
||||
|
||||
@@ -613,7 +613,7 @@ finishInstall() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
||||
if isPlatform "x64"; then
|
||||
if isLegacyBoot; then
|
||||
|
||||
writeState "mode" "$BOOT_MODE" || {
|
||||
@@ -710,7 +710,7 @@ findFile() {
|
||||
file="$STORAGE/$base"
|
||||
fi
|
||||
|
||||
if [ ! -f "$file" ] || [ ! -s "$file" ]; then
|
||||
if ! hasImage "$file"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -777,11 +777,16 @@ isURL() {
|
||||
[[ "${value,,}" == "http"* ]]
|
||||
}
|
||||
|
||||
isPlatform() {
|
||||
|
||||
local platform="$1"
|
||||
|
||||
[[ "${PLATFORM,,}" == "${platform,,}" ]]
|
||||
}
|
||||
|
||||
isLegacyBoot() {
|
||||
|
||||
local mode="${BOOT_MODE:-}"
|
||||
|
||||
[[ "${mode,,}" == "windows_legacy" ]]
|
||||
[[ "${BOOT_MODE,,}" == "windows_legacy" ]]
|
||||
}
|
||||
|
||||
hasBootMarker() {
|
||||
|
||||
+3
-3
@@ -70,7 +70,7 @@ setMachine() {
|
||||
|
||||
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
|
||||
# as it will be always wiped during the next runs currently.
|
||||
DISK_DISABLE="Y"
|
||||
@@ -115,7 +115,7 @@ restoreMachine() {
|
||||
# Restore the saved machine only when q35 is still the default;
|
||||
# an explicit user-selected machine must remain untouched.
|
||||
[[ "${MACHINE,,}" != "q35" ]] && return 0
|
||||
[[ "${PLATFORM,,}" != "x64" ]] && return 0
|
||||
isPlatform "x64" || return 0
|
||||
|
||||
MACHINE=""
|
||||
restoreState "MACHINE" "old" || return 1
|
||||
@@ -1016,7 +1016,7 @@ detectLegacy() {
|
||||
local dir="$1"
|
||||
local marker
|
||||
|
||||
[[ "${PLATFORM,,}" == "x64" ]] || return 1
|
||||
isPlatform "x64" || return 1
|
||||
|
||||
# Legacy media is identified from setup marker files rather than WIM
|
||||
# metadata. The order is intentional because several releases share markers.
|
||||
|
||||
+2
-2
@@ -320,7 +320,7 @@ downloadWindowsEval() {
|
||||
type="iot"
|
||||
winVer="windows-11-iot-enterprise-ltsc-eval" ;;
|
||||
"win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||
if [[ "${PLATFORM,,}" == "arm64" ]]; then
|
||||
if isPlatform "arm64"; then
|
||||
type="iot"
|
||||
winVer="windows-11-iot-enterprise-ltsc-eval"
|
||||
else
|
||||
@@ -595,7 +595,7 @@ getWindows() {
|
||||
"win11${PLATFORM,,}-enterprise"* ) ;;
|
||||
* )
|
||||
|
||||
if [[ "${PLATFORM,,}" != "x64" ]]; then
|
||||
if ! isPlatform "x64"; then
|
||||
error "No download for the ${PLATFORM^^} platform available for $edition!"
|
||||
MIDO_URL=""
|
||||
return 1
|
||||
|
||||
+2
-2
@@ -346,7 +346,7 @@ sendKey() {
|
||||
|
||||
needsBootKey() {
|
||||
|
||||
[ ! -s "$BOOT" ] && return 1
|
||||
hasImage "$BOOT" || return 1
|
||||
|
||||
hasCompletedInstall && return 1
|
||||
supportsBootKey "$DETECTED" || return 1
|
||||
@@ -363,7 +363,7 @@ bootKeyReady() {
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [[ "${PLATFORM,,}" == "arm64" ]]; then
|
||||
if isPlatform "arm64"; then
|
||||
grep -Eq "$UEFI_USB_BOOT_PATTERN" "$QEMU_PTY"
|
||||
else
|
||||
grep -Eq "$UEFI_DVD_BOOT_PATTERN" "$QEMU_PTY"
|
||||
|
||||
Reference in New Issue
Block a user