diff --git a/src/define.sh b/src/define.sh index cfe9e5098..00e535d46 100644 --- a/src/define.sh +++ b/src/define.sh @@ -404,7 +404,7 @@ printVersion() { if [ -z "$desc" ]; then desc="Windows" - [[ "${PLATFORM,,}" != "x64" ]] && desc+=" for ${PLATFORM}" + isPlatform "x64" || desc+=" for ${PLATFORM}" fi echo "$desc" diff --git a/src/image.sh b/src/image.sh index 79a6582d1..5995caf14 100644 --- a/src/image.sh +++ b/src/image.sh @@ -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" diff --git a/src/install.sh b/src/install.sh index f741ba89e..72f50ccff 100644 --- a/src/install.sh +++ b/src/install.sh @@ -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"* ]] } -isLegacyBoot() { +isPlatform() { + + local platform="$1" - local mode="${BOOT_MODE:-}" + [[ "${PLATFORM,,}" == "${platform,,}" ]] +} + +isLegacyBoot() { - [[ "${mode,,}" == "windows_legacy" ]] + [[ "${BOOT_MODE,,}" == "windows_legacy" ]] } hasBootMarker() { diff --git a/src/legacy.sh b/src/legacy.sh index fd936c04c..810151b17 100644 --- a/src/legacy.sh +++ b/src/legacy.sh @@ -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. diff --git a/src/mido.sh b/src/mido.sh index db0f5cb4b..fea1d602d 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -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 diff --git a/src/power.sh b/src/power.sh index 027b830ce..1c93b3c14 100644 --- a/src/power.sh +++ b/src/power.sh @@ -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"