From 65fe8ada74ab860d9b616ca49b821bc816a304b3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Thu, 6 Aug 2026 20:40:43 +0200 Subject: [PATCH] feat: Use detected architecture for driver fallback (#2084) --- src/image.sh | 15 +++++++++------ src/install.sh | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/image.sh b/src/image.sh index ad4bed48..b5959817 100644 --- a/src/image.sh +++ b/src/image.sh @@ -521,6 +521,7 @@ checkPlatform() { local xml="$1" local platform + IMAGE_PLATFORM="" platform=$(getPlatform "$xml") || return 1 case "${platform,,}" in @@ -535,20 +536,22 @@ checkPlatform() { case "${PLATFORM,,}" in "x64" ) - if [[ "${platform,,}" == "x64" || "${platform,,}" == "x86" ]]; then - return 0 + if [[ "${platform,,}" != "x64" && "${platform,,}" != "x86" ]]; then + error "You cannot boot ${platform^^} images on a $PLATFORM CPU!" + return 1 fi ;; "arm64" ) - if [[ "${platform,,}" == "arm64" ]]; then - return 0 + if [[ "${platform,,}" != "arm64" ]]; then + error "You cannot boot ${platform^^} images on a $PLATFORM CPU!" + return 1 fi ;; * ) error "Unsupported container platform: $PLATFORM" return 1 ;; esac - error "You cannot boot ${platform^^} images on a $PLATFORM CPU!" - return 1 + IMAGE_PLATFORM="${platform,,}" + return 0 } getPlatform() { diff --git a/src/install.sh b/src/install.sh index 39f681d0..3bbd9c88 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1131,6 +1131,7 @@ addDrivers() { local version="$2" local drivers="$stage/drivers" + local msg="Windows version and architecture are unknown; cannot select drivers!" rm -rf "$drivers" || return 1 mkdir -p "$drivers" || return 1 @@ -1138,8 +1139,22 @@ addDrivers() { info "Adding drivers to image..." if [ -z "$version" ]; then - version="win11x64" - warn "Windows version unknown, falling back to Windows 11 drivers..." + + if [ -z "${IMAGE_PLATFORM:-}" ]; then + error "$msg" && return 1 + fi + + case "${IMAGE_PLATFORM,,}" in + "x86" ) version="win7x86" ;; + "x64" ) version="win11x64" ;; + "arm64" ) version="win11arm64" ;; + * ) error "$msg" && return 1 ;; + esac + + local desc + desc=$(printVersion "$version" "") || return 1 + + warn "Windows version unknown, falling back to $desc drivers..." fi if ! bsdtar -xf /var/drivers.txz -C "$drivers"; then