From ce86698b803efdb0223458992bea316721b24660 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 16:58:51 +0200 Subject: [PATCH 01/32] Update entry.sh --- src/entry.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/entry.sh b/src/entry.sh index 5e92df6..6eaac0d 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -9,6 +9,7 @@ SUPPORT="https://github.com/dockur/windows-arm" cd /run . reset.sh # Initialize system +. define.sh # Define versions . install.sh # Run installation . disk.sh # Initialize disks . display.sh # Initialize graphics From 414a900b98f117f5883c70bbb97725b6d33e2364 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 16:59:26 +0200 Subject: [PATCH 02/32] Create define.sh --- src/define.sh | 290 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 src/define.sh diff --git a/src/define.sh b/src/define.sh new file mode 100644 index 0000000..4a8f811 --- /dev/null +++ b/src/define.sh @@ -0,0 +1,290 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +: "${MANUAL:=""}" +: "${VERSION:=""}" +: "${DETECTED:=""}" + +getLink() { + + local id="$1" + local url="" + local host="https://dl.bobpony.com" + + case "${id,,}" in + "win11${PLATFORM,,}") + url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" + ;; + "win10${PLATFORM,,}") + url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" + ;; + "win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval") + url="$host/windows/10/en-us_windows_10_iot_enterprise_ltsc_2021_${PLATFORM,,}_dvd_257ad90f.iso" + ;; + "win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval") + url="$host/windows/10/en-us_windows_10_enterprise_ltsc_2021_${PLATFORM,,}_dvd_d289cf96.iso" + ;; + "win81x64") + url="$host/windows/8.x/8.1/en_windows_8.1_with_update_x64_dvd_6051480.iso" + ;; + "win2022-eval") + url="$host/windows/server/2022/en-us_windows_server_2022_updated_jan_2024_x64_dvd_2b7a0c9f.iso" + ;; + "win2019-eval") + url="$host/windows/server/2019/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso" + ;; + "win2016-eval") + url="$host/windows/server/2016/en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso" + ;; + "win2012r2-eval") + url="$host/windows/server/2012r2/en_windows_server_2012_r2_with_update_x64_dvd_6052708-004.iso" + ;; + "win2008r2") + url="$host/windows/server/2008r2/en_windows_server_2008_r2_with_sp1_x64_dvd_617601-018.iso" + ;; + "win7x64") + url="$host/windows/7/en_windows_7_enterprise_with_sp1_x64_dvd_u_677651.iso" + ;; + "winvistax64") + url="$host/windows/vista/en_windows_vista_sp2_x64_dvd_342267.iso" + ;; + "winxpx86") + url="$host/windows/xp/professional/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso" + ;; + "core11") + url="https://archive.org/download/tiny-11-core-x-64-beta-1/tiny11%20core%20x64%20beta%201.iso" + ;; + "tiny11") + url="https://archive.org/download/tiny11-2311/tiny11%202311%20x64.iso" + ;; + "tiny10") + url="https://archive.org/download/tiny-10-23-h2/tiny10%20x64%2023h2.iso" + ;; + *) + return 0 + ;; + esac + + echo "$url" + return 0 +} + +parseVersion() { + + [ -z "$VERSION" ] && VERSION="win11" + + if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then + VERSION="${VERSION:1:-1}" + fi + + case "${VERSION,,}" in + "11" | "win11") + VERSION="win11${PLATFORM}" + ;; + "10" | "win10") + VERSION="win10${PLATFORM}" + ;; + "8" | "81" | "8.1" | "win8" | "win81") + VERSION="win81x64" + ;; + "7" | "win7") + VERSION="win7x64" + ;; + "vista" | "winvista") + VERSION="winvistax64" + ;; + "xp" | "winxp") + VERSION="winxpx86" + ;; + "22" | "2022" | "win22" | "win2022") + VERSION="win2022-eval" + ;; + "19" | "2019" | "win19" | "win2019") + VERSION="win2019-eval" + ;; + "16" | "2016" | "win16" | "win2016") + VERSION="win2016-eval" + ;; + "2012" | "win2012") + VERSION="win2012r2-eval" + ;; + "2008" | "win2008") + VERSION="win2008r2" + ;; + "iot10" | "10iot" | "win10-iot" | "win10x64-iot") + VERSION="win10x64-enterprise-iot-eval" + ;; + "ltsc10" | "10ltsc" | "win10-ltsc" | "win10x64-ltsc") + VERSION="win10x64-enterprise-ltsc-eval" + ;; + esac + + if [[ "${VERSION,,}" == "win10x64-enterprise-iot-eval" ]]; then + DETECTED="win10x64-iot" + fi + + if [[ "${VERSION,,}" == "win10x64-enterprise-ltsc-eval" ]]; then + DETECTED="win10x64-ltsc" + fi + + if [[ "${VERSION,,}" == "win7x64" ]]; then + DETECTED="$VERSION" + VERSION=$(getLink "$VERSION") + fi + + if [[ "${VERSION,,}" == "winvistax64" ]]; then + DETECTED="$VERSION" + VERSION=$(getLink "$VERSION") + fi + + if [[ "${VERSION,,}" == "winxpx86" ]]; then + DETECTED="$VERSION" + VERSION=$(getLink "$VERSION") + fi + + if [[ "${VERSION,,}" == "core11" ]]; then + DETECTED="win11x64" + VERSION=$(getLink "$VERSION") + fi + + if [[ "${VERSION,,}" == "tiny11" ]]; then + DETECTED="win11x64" + VERSION=$(getLink "$VERSION") + fi + + if [[ "${VERSION,,}" == "tiny10" ]]; then + DETECTED="win10x64-ltsc" + VERSION=$(getLink "$VERSION") + fi + + return 0 +} + +printVersion() { + + local id="$1" + local desc="$2" + + [[ "$id" == "win7"* ]] && desc="Windows 7" + [[ "$id" == "win8"* ]] && desc="Windows 8" + [[ "$id" == "win10"* ]] && desc="Windows 10" + [[ "$id" == "win11"* ]] && desc="Windows 11" + [[ "$id" == "winxp"* ]] && desc="Windows XP" + [[ "$id" == "winvista"* ]] && desc="Windows Vista" + [[ "$id" == "win2025"* ]] && desc="Windows Server 2025" + [[ "$id" == "win2022"* ]] && desc="Windows Server 2022" + [[ "$id" == "win2019"* ]] && desc="Windows Server 2019" + [[ "$id" == "win2016"* ]] && desc="Windows Server 2016" + [[ "$id" == "win2012"* ]] && desc="Windows Server 2012" + [[ "$id" == "win2008"* ]] && desc="Windows Server 2008" + [[ "$id" == "win10x64-iot" ]] && desc="Windows 10 IoT" + [[ "$id" == "win11x64-iot" ]] && desc="Windows 11 IoT" + [[ "$id" == "win10x64-ltsc" ]] && desc="Windows 10 LTSC" + [[ "$id" == "win11x64-ltsc" ]] && desc="Windows 11 LTSC" + [[ "$id" == "win81x64-enterprise-eval" ]] && desc="Windows 8 Enterprise" + [[ "$id" == "win10x64-enterprise-eval" ]] && desc="Windows 10 Enterprise" + [[ "$id" == "win11x64-enterprise-eval" ]] && desc="Windows 11 Enterprise" + + [ -z "$desc" ] && desc="Windows" + + echo "$desc" + return 0 +} + +getName() { + + local file="$1" + local desc="$2" + + [[ "${file,,}" == "win11"* ]] && desc="Windows 11" + [[ "${file,,}" == "win10"* ]] && desc="Windows 10" + [[ "${file,,}" == "win8"* ]] && desc="Windows 8" + [[ "${file,,}" == "win7"* ]] && desc="Windows 7" + [[ "${file,,}" == "winxp"* ]] && desc="Windows XP" + [[ "${file,,}" == "winvista"* ]] && desc="Windows Vista" + [[ "${file,,}" == "tiny10"* ]] && desc="Tiny 10" + [[ "${file,,}" == "tiny11"* ]] && desc="Tiny 11" + [[ "${file,,}" == "tiny11_core"* ]] && desc="Tiny 11 Core" + [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11" + [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10" + [[ "${file,,}" == *"windows8"* ]] && desc="Windows 8" + [[ "${file,,}" == *"windows7"* ]] && desc="Windows 7" + [[ "${file,,}" == *"windowsxp"* ]] && desc="Windows XP" + [[ "${file,,}" == *"windowsvista"* ]] && desc="Windows Vista" + [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11" + [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10" + [[ "${file,,}" == *"windows_8"* ]] && desc="Windows 8" + [[ "${file,,}" == *"windows_7"* ]] && desc="Windows 7" + [[ "${file,,}" == *"windows_xp"* ]] && desc="Windows XP" + [[ "${file,,}" == *"windows_vista"* ]] && desc="Windows Vista" + [[ "${file,,}" == *"server2008"* ]] && desc="Windows Server 2008" + [[ "${file,,}" == *"server2012"* ]] && desc="Windows Server 2012" + [[ "${file,,}" == *"server2016"* ]] && desc="Windows Server 2016" + [[ "${file,,}" == *"server2019"* ]] && desc="Windows Server 2019" + [[ "${file,,}" == *"server2022"* ]] && desc="Windows Server 2022" + [[ "${file,,}" == *"server2025"* ]] && desc="Windows Server 2025" + [[ "${file,,}" == *"server_2008"* ]] && desc="Windows Server 2008" + [[ "${file,,}" == *"server_2012"* ]] && desc="Windows Server 2012" + [[ "${file,,}" == *"server_2016"* ]] && desc="Windows Server 2016" + [[ "${file,,}" == *"server_2019"* ]] && desc="Windows Server 2019" + [[ "${file,,}" == *"server_2022"* ]] && desc="Windows Server 2022" + [[ "${file,,}" == *"server_2025"* ]] && desc="Windows Server 2025" + + [ -z "$desc" ] && desc="Windows" + + echo "$desc" + return 0 +} + +getVersion() { + + local name="$1" + local detected="" + + [[ "${name,,}" == *"windows 7"* ]] && detected="win7x64" + [[ "${name,,}" == *"windows vista"* ]] && detected="winvistax64" + + [[ "${name,,}" == *"server 2008"* ]] && detected="win2008r2" + [[ "${name,,}" == *"server 2025"* ]] && detected="win2025-eval" + [[ "${name,,}" == *"server 2022"* ]] && detected="win2022-eval" + [[ "${name,,}" == *"server 2019"* ]] && detected="win2019-eval" + [[ "${name,,}" == *"server 2016"* ]] && detected="win2016-eval" + [[ "${name,,}" == *"server 2012"* ]] && detected="win2012r2-eval" + + if [[ "${name,,}" == *"windows 8"* ]]; then + if [[ "${name,,}" == *"enterprise evaluation"* ]]; then + detected="win81x64-enterprise-eval" + else + detected="win81x64" + fi + fi + + if [[ "${name,,}" == *"windows 11"* ]]; then + if [[ "${name,,}" == *"enterprise evaluation"* ]]; then + detected="win11x64-enterprise-eval" + else + detected="win11x64" + fi + fi + + if [[ "${name,,}" == *"windows 10"* ]]; then + if [[ "${name,,}" == *" iot "* ]]; then + detected="win10x64-iot" + else + if [[ "${name,,}" == *"ltsc"* ]]; then + detected="win10x64-ltsc" + else + if [[ "${name,,}" == *"enterprise evaluation"* ]]; then + detected="win10x64-enterprise-eval" + else + detected="win10x64" + fi + fi + fi + fi + + echo "$detected" + return 0 +} + +return 0 From 292428dd2c24e0996c572e51736caacd31a96793 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 17:07:50 +0200 Subject: [PATCH 03/32] Update install.sh --- src/install.sh | 89 ++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 71 deletions(-) diff --git a/src/install.sh b/src/install.sh index ae93b9b..47d3b19 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,33 +1,6 @@ #!/usr/bin/env bash set -Eeuo pipefail -: "${MANUAL:=""}" -: "${VERSION:=""}" -: "${DETECTED:=""}" - -[ -z "$VERSION" ] && VERSION="win11arm64" - -if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then - VERSION="${VERSION:1:-1}" -fi - -[[ "${VERSION,,}" == "11" ]] && VERSION="win11arm64" -[[ "${VERSION,,}" == "win11" ]] && VERSION="win11arm64" - -[[ "${VERSION,,}" == "10" ]] && VERSION="win10arm64" -[[ "${VERSION,,}" == "win10" ]] && VERSION="win10arm64" - -CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname windows.iso -printf "%f\n" | head -n 1) -[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1) -[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso -printf "%f\n" | head -n 1) -[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1) - -if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then - FN="${VERSION/\/storage\//}" - [[ "$FN" == "."* ]] && FN="${FN:1}" - CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname "$FN" -printf "%f\n" | head -n 1) -fi - ESD_URL="" PLATFORM="ARM64" TMP="$STORAGE/tmp" @@ -36,50 +9,6 @@ FB="falling back to manual installation!" ETFS="boot/etfsboot.com" EFISYS="efi/microsoft/boot/efisys_noprompt.bin" -printVersion() { - - local id="$1" - local desc="$2" - - [[ "$id" == "win10"* ]] && desc="Windows 10 for ARM" - [[ "$id" == "win11"* ]] && desc="Windows 11 for ARM" - - [ -z "$desc" ] && desc="Windows for ARM" - - echo "$desc" - return 0 -} - -getName() { - - local file="$1" - local desc="$2" - - [[ "${file,,}" == "win11"* ]] && desc="Windows 11 for ARM" - [[ "${file,,}" == "win10"* ]] && desc="Windows 10 for ARM" - [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11 for ARM" - [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10 for ARM" - [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11 for ARM" - [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10 for ARM" - - [ -z "$desc" ] && desc="Windows for ARM" - - echo "$desc" - return 0 -} - -getVersion() { - - local name="$1" - local detected="" - - [[ "${name,,}" == *"windows 11"* ]] && detected="win11arm64" - [[ "${name,,}" == *"windows 10"* ]] && detected="win10arm64" - - echo "$detected" - return 0 -} - hasDisk() { [ -b "${DEVICE:-}" ] && return 0 @@ -216,6 +145,22 @@ startInstall() { return 0 } +detectCustom() { + + CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname windows.iso -printf "%f\n" | head -n 1) + [ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1) + [ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso -printf "%f\n" | head -n 1) + [ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1) + + if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then + FN="${VERSION/\/storage\//}" + [[ "$FN" == "."* ]] && FN="${FN:1}" + CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname "$FN" -printf "%f\n" | head -n 1) + fi + + return 0 +} + getESD() { local dir="$1" @@ -727,6 +672,8 @@ bootWindows() { ###################################### +TODO + if ! startInstall; then bootWindows && return 0 exit 68 From 077fd3058c076e81dfaa589ad971c8da98a99da7 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 17:12:19 +0200 Subject: [PATCH 04/32] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 47d3b19..5e2308f 100644 --- a/src/install.sh +++ b/src/install.sh @@ -2,7 +2,6 @@ set -Eeuo pipefail ESD_URL="" -PLATFORM="ARM64" TMP="$STORAGE/tmp" DIR="$TMP/unpack" FB="falling back to manual installation!" @@ -672,7 +671,8 @@ bootWindows() { ###################################### -TODO +! parseVersion && exit 58 +! detectCustom && exit 59 if ! startInstall; then bootWindows && return 0 From d3df26cfbe3042a4e548251fa9b93887ef1a9b86 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 17:36:16 +0200 Subject: [PATCH 05/32] Update define.sh --- src/define.sh | 228 ++++---------------------------------------------- 1 file changed, 15 insertions(+), 213 deletions(-) diff --git a/src/define.sh b/src/define.sh index 4a8f811..e5a72f0 100644 --- a/src/define.sh +++ b/src/define.sh @@ -4,6 +4,7 @@ set -Eeuo pipefail : "${MANUAL:=""}" : "${VERSION:=""}" : "${DETECTED:=""}" +: "${PLATFORM:="ARM64"}" getLink() { @@ -18,51 +19,6 @@ getLink() { "win10${PLATFORM,,}") url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" ;; - "win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval") - url="$host/windows/10/en-us_windows_10_iot_enterprise_ltsc_2021_${PLATFORM,,}_dvd_257ad90f.iso" - ;; - "win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval") - url="$host/windows/10/en-us_windows_10_enterprise_ltsc_2021_${PLATFORM,,}_dvd_d289cf96.iso" - ;; - "win81x64") - url="$host/windows/8.x/8.1/en_windows_8.1_with_update_x64_dvd_6051480.iso" - ;; - "win2022-eval") - url="$host/windows/server/2022/en-us_windows_server_2022_updated_jan_2024_x64_dvd_2b7a0c9f.iso" - ;; - "win2019-eval") - url="$host/windows/server/2019/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso" - ;; - "win2016-eval") - url="$host/windows/server/2016/en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso" - ;; - "win2012r2-eval") - url="$host/windows/server/2012r2/en_windows_server_2012_r2_with_update_x64_dvd_6052708-004.iso" - ;; - "win2008r2") - url="$host/windows/server/2008r2/en_windows_server_2008_r2_with_sp1_x64_dvd_617601-018.iso" - ;; - "win7x64") - url="$host/windows/7/en_windows_7_enterprise_with_sp1_x64_dvd_u_677651.iso" - ;; - "winvistax64") - url="$host/windows/vista/en_windows_vista_sp2_x64_dvd_342267.iso" - ;; - "winxpx86") - url="$host/windows/xp/professional/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso" - ;; - "core11") - url="https://archive.org/download/tiny-11-core-x-64-beta-1/tiny11%20core%20x64%20beta%201.iso" - ;; - "tiny11") - url="https://archive.org/download/tiny11-2311/tiny11%202311%20x64.iso" - ;; - "tiny10") - url="https://archive.org/download/tiny-10-23-h2/tiny10%20x64%2023h2.iso" - ;; - *) - return 0 - ;; esac echo "$url" @@ -79,84 +35,13 @@ parseVersion() { case "${VERSION,,}" in "11" | "win11") - VERSION="win11${PLATFORM}" + VERSION="win11${PLATFORM,,}" ;; "10" | "win10") - VERSION="win10${PLATFORM}" - ;; - "8" | "81" | "8.1" | "win8" | "win81") - VERSION="win81x64" - ;; - "7" | "win7") - VERSION="win7x64" - ;; - "vista" | "winvista") - VERSION="winvistax64" - ;; - "xp" | "winxp") - VERSION="winxpx86" - ;; - "22" | "2022" | "win22" | "win2022") - VERSION="win2022-eval" - ;; - "19" | "2019" | "win19" | "win2019") - VERSION="win2019-eval" - ;; - "16" | "2016" | "win16" | "win2016") - VERSION="win2016-eval" - ;; - "2012" | "win2012") - VERSION="win2012r2-eval" - ;; - "2008" | "win2008") - VERSION="win2008r2" - ;; - "iot10" | "10iot" | "win10-iot" | "win10x64-iot") - VERSION="win10x64-enterprise-iot-eval" - ;; - "ltsc10" | "10ltsc" | "win10-ltsc" | "win10x64-ltsc") - VERSION="win10x64-enterprise-ltsc-eval" + VERSION="win10${PLATFORM,,}" ;; esac - if [[ "${VERSION,,}" == "win10x64-enterprise-iot-eval" ]]; then - DETECTED="win10x64-iot" - fi - - if [[ "${VERSION,,}" == "win10x64-enterprise-ltsc-eval" ]]; then - DETECTED="win10x64-ltsc" - fi - - if [[ "${VERSION,,}" == "win7x64" ]]; then - DETECTED="$VERSION" - VERSION=$(getLink "$VERSION") - fi - - if [[ "${VERSION,,}" == "winvistax64" ]]; then - DETECTED="$VERSION" - VERSION=$(getLink "$VERSION") - fi - - if [[ "${VERSION,,}" == "winxpx86" ]]; then - DETECTED="$VERSION" - VERSION=$(getLink "$VERSION") - fi - - if [[ "${VERSION,,}" == "core11" ]]; then - DETECTED="win11x64" - VERSION=$(getLink "$VERSION") - fi - - if [[ "${VERSION,,}" == "tiny11" ]]; then - DETECTED="win11x64" - VERSION=$(getLink "$VERSION") - fi - - if [[ "${VERSION,,}" == "tiny10" ]]; then - DETECTED="win10x64-ltsc" - VERSION=$(getLink "$VERSION") - fi - return 0 } @@ -165,27 +50,10 @@ printVersion() { local id="$1" local desc="$2" - [[ "$id" == "win7"* ]] && desc="Windows 7" - [[ "$id" == "win8"* ]] && desc="Windows 8" - [[ "$id" == "win10"* ]] && desc="Windows 10" - [[ "$id" == "win11"* ]] && desc="Windows 11" - [[ "$id" == "winxp"* ]] && desc="Windows XP" - [[ "$id" == "winvista"* ]] && desc="Windows Vista" - [[ "$id" == "win2025"* ]] && desc="Windows Server 2025" - [[ "$id" == "win2022"* ]] && desc="Windows Server 2022" - [[ "$id" == "win2019"* ]] && desc="Windows Server 2019" - [[ "$id" == "win2016"* ]] && desc="Windows Server 2016" - [[ "$id" == "win2012"* ]] && desc="Windows Server 2012" - [[ "$id" == "win2008"* ]] && desc="Windows Server 2008" - [[ "$id" == "win10x64-iot" ]] && desc="Windows 10 IoT" - [[ "$id" == "win11x64-iot" ]] && desc="Windows 11 IoT" - [[ "$id" == "win10x64-ltsc" ]] && desc="Windows 10 LTSC" - [[ "$id" == "win11x64-ltsc" ]] && desc="Windows 11 LTSC" - [[ "$id" == "win81x64-enterprise-eval" ]] && desc="Windows 8 Enterprise" - [[ "$id" == "win10x64-enterprise-eval" ]] && desc="Windows 10 Enterprise" - [[ "$id" == "win11x64-enterprise-eval" ]] && desc="Windows 11 Enterprise" + [[ "$id" == "win10"* ]] && desc="Windows 10 for ${PLATFORM}" + [[ "$id" == "win11"* ]] && desc="Windows 11 for ${PLATFORM}" - [ -z "$desc" ] && desc="Windows" + [ -z "$desc" ] && desc="Windows for ${PLATFORM}" echo "$desc" return 0 @@ -196,41 +64,14 @@ getName() { local file="$1" local desc="$2" - [[ "${file,,}" == "win11"* ]] && desc="Windows 11" - [[ "${file,,}" == "win10"* ]] && desc="Windows 10" - [[ "${file,,}" == "win8"* ]] && desc="Windows 8" - [[ "${file,,}" == "win7"* ]] && desc="Windows 7" - [[ "${file,,}" == "winxp"* ]] && desc="Windows XP" - [[ "${file,,}" == "winvista"* ]] && desc="Windows Vista" - [[ "${file,,}" == "tiny10"* ]] && desc="Tiny 10" - [[ "${file,,}" == "tiny11"* ]] && desc="Tiny 11" - [[ "${file,,}" == "tiny11_core"* ]] && desc="Tiny 11 Core" - [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11" - [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10" - [[ "${file,,}" == *"windows8"* ]] && desc="Windows 8" - [[ "${file,,}" == *"windows7"* ]] && desc="Windows 7" - [[ "${file,,}" == *"windowsxp"* ]] && desc="Windows XP" - [[ "${file,,}" == *"windowsvista"* ]] && desc="Windows Vista" - [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11" - [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10" - [[ "${file,,}" == *"windows_8"* ]] && desc="Windows 8" - [[ "${file,,}" == *"windows_7"* ]] && desc="Windows 7" - [[ "${file,,}" == *"windows_xp"* ]] && desc="Windows XP" - [[ "${file,,}" == *"windows_vista"* ]] && desc="Windows Vista" - [[ "${file,,}" == *"server2008"* ]] && desc="Windows Server 2008" - [[ "${file,,}" == *"server2012"* ]] && desc="Windows Server 2012" - [[ "${file,,}" == *"server2016"* ]] && desc="Windows Server 2016" - [[ "${file,,}" == *"server2019"* ]] && desc="Windows Server 2019" - [[ "${file,,}" == *"server2022"* ]] && desc="Windows Server 2022" - [[ "${file,,}" == *"server2025"* ]] && desc="Windows Server 2025" - [[ "${file,,}" == *"server_2008"* ]] && desc="Windows Server 2008" - [[ "${file,,}" == *"server_2012"* ]] && desc="Windows Server 2012" - [[ "${file,,}" == *"server_2016"* ]] && desc="Windows Server 2016" - [[ "${file,,}" == *"server_2019"* ]] && desc="Windows Server 2019" - [[ "${file,,}" == *"server_2022"* ]] && desc="Windows Server 2022" - [[ "${file,,}" == *"server_2025"* ]] && desc="Windows Server 2025" + [[ "${file,,}" == "win11"* ]] && desc="Windows 11 for ${PLATFORM}" + [[ "${file,,}" == "win10"* ]] && desc="Windows 10 for ${PLATFORM}" + [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11 for ${PLATFORM}" + [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10 for ${PLATFORM}" + [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11 for ${PLATFORM}" + [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10 for ${PLATFORM}" - [ -z "$desc" ] && desc="Windows" + [ -z "$desc" ] && desc="Windows for ${PLATFORM}" echo "$desc" return 0 @@ -241,47 +82,8 @@ getVersion() { local name="$1" local detected="" - [[ "${name,,}" == *"windows 7"* ]] && detected="win7x64" - [[ "${name,,}" == *"windows vista"* ]] && detected="winvistax64" - - [[ "${name,,}" == *"server 2008"* ]] && detected="win2008r2" - [[ "${name,,}" == *"server 2025"* ]] && detected="win2025-eval" - [[ "${name,,}" == *"server 2022"* ]] && detected="win2022-eval" - [[ "${name,,}" == *"server 2019"* ]] && detected="win2019-eval" - [[ "${name,,}" == *"server 2016"* ]] && detected="win2016-eval" - [[ "${name,,}" == *"server 2012"* ]] && detected="win2012r2-eval" - - if [[ "${name,,}" == *"windows 8"* ]]; then - if [[ "${name,,}" == *"enterprise evaluation"* ]]; then - detected="win81x64-enterprise-eval" - else - detected="win81x64" - fi - fi - - if [[ "${name,,}" == *"windows 11"* ]]; then - if [[ "${name,,}" == *"enterprise evaluation"* ]]; then - detected="win11x64-enterprise-eval" - else - detected="win11x64" - fi - fi - - if [[ "${name,,}" == *"windows 10"* ]]; then - if [[ "${name,,}" == *" iot "* ]]; then - detected="win10x64-iot" - else - if [[ "${name,,}" == *"ltsc"* ]]; then - detected="win10x64-ltsc" - else - if [[ "${name,,}" == *"enterprise evaluation"* ]]; then - detected="win10x64-enterprise-eval" - else - detected="win10x64" - fi - fi - fi - fi + [[ "${name,,}" == *"windows 11"* ]] && detected="win11${PLATFORM,,}" + [[ "${name,,}" == *"windows 10"* ]] && detected="win10${PLATFORM,,}" echo "$detected" return 0 From 602f1da96549a400978301dd7a54b5ed048ee5bc Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 17:37:49 +0200 Subject: [PATCH 06/32] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 5e2308f..ed0908b 100644 --- a/src/install.sh +++ b/src/install.sh @@ -269,7 +269,7 @@ downloadImage() { if [[ "$EXTERNAL" != [Yy1]* ]]; then - desc=$(printVersion "$VERSION" "Windows for ARM") + desc=$(printVersion "$VERSION" "Windows for ${PLATFORM}") else @@ -324,7 +324,7 @@ extractESD() { local dir="$2" local size size_gb space space_gb desc - desc=$(printVersion "$VERSION" "Windows for ARM") + desc=$(printVersion "$VERSION" "Windows for ${PLATFORM}") local msg="Extracting $desc bootdisk..." info "$msg" && html "$msg" From a202b61033719d2fcdedc9d5315f8db89d8ee521 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 17:42:17 +0200 Subject: [PATCH 07/32] Update install.sh --- src/install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index ed0908b..17d1a8a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -44,9 +44,12 @@ finishInstall() { fi fi + rm -f "$STORAGE/windows.ver" + rm -f "$STORAGE/windows.old" rm -f "$STORAGE/windows.boot" + rm -f "$STORAGE/windows.mode" + cp /run/version "$STORAGE/windows.ver" - rm -f "$STORAGE/windows.old" rm -rf "$TMP" return 0 From 9a72aa1982a3d3cafe5a059ac2b2ff56882ec284 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 19:42:19 +0200 Subject: [PATCH 08/32] Update define.sh --- src/define.sh | 52 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/define.sh b/src/define.sh index e5a72f0..9dd6856 100644 --- a/src/define.sh +++ b/src/define.sh @@ -45,17 +45,33 @@ parseVersion() { return 0 } +isESD() { + + local id="$1" + + case "${id,,}" in + "win11${PLATFORM,,}") + return 0 + ;; + "win10${PLATFORM,,}") + return 0 + ;; + esac + + return 1 +} + printVersion() { local id="$1" local desc="$2" - [[ "$id" == "win10"* ]] && desc="Windows 10 for ${PLATFORM}" - [[ "$id" == "win11"* ]] && desc="Windows 11 for ${PLATFORM}" + [[ "$id" == "win10"* ]] && desc="Windows 10" + [[ "$id" == "win11"* ]] && desc="Windows 11" - [ -z "$desc" ] && desc="Windows for ${PLATFORM}" + [ -z "$desc" ] && desc="Windows" - echo "$desc" + echo "$desc for ${PLATFORM}" return 0 } @@ -64,16 +80,26 @@ getName() { local file="$1" local desc="$2" - [[ "${file,,}" == "win11"* ]] && desc="Windows 11 for ${PLATFORM}" - [[ "${file,,}" == "win10"* ]] && desc="Windows 10 for ${PLATFORM}" - [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11 for ${PLATFORM}" - [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10 for ${PLATFORM}" - [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11 for ${PLATFORM}" - [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10 for ${PLATFORM}" - - [ -z "$desc" ] && desc="Windows for ${PLATFORM}" + [[ "${file,,}" == "win11"* ]] && desc="Windows 11" + [[ "${file,,}" == "win10"* ]] && desc="Windows 10" + [[ "${file,,}" == *"windows11"* ]] && desc="Windows 11" + [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10" + [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11" + [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10" + + if [ -z "$desc" ]; then + desc="Windows" + else + if [[ "$desc" == "Windows 1"* ]] && [[ "${file,,}" == *"_iot_"* ]]; then + desc="$desc IoT" + else + if [[ "$desc" == "Windows 1"* ]] && [[ "${file,,}" == *"_ltsc_"* ]]; then + desc="$desc LTSC" + fi + fi + fi - echo "$desc" + echo "$desc for ${PLATFORM}" return 0 } From 346587914149287923e58d52a9fc0a6011afc8dc Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 20:08:25 +0200 Subject: [PATCH 09/32] Update install.sh --- src/install.sh | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/install.sh b/src/install.sh index 17d1a8a..d883250 100644 --- a/src/install.sh +++ b/src/install.sh @@ -166,9 +166,10 @@ detectCustom() { getESD() { local dir="$1" + local version="$2" local winCatalog size - case "${VERSION,,}" in + case "${version,,}" in "win11${PLATFORM,,}") winCatalog="https://go.microsoft.com/fwlink?linkid=2156292" ;; @@ -176,7 +177,7 @@ getESD() { winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361" ;; *) - error "Invalid version specified: $VERSION" && return 1 + error "Invalid version specified: $version" && return 1 ;; esac @@ -267,55 +268,50 @@ downloadFile() { downloadImage() { local iso="$1" - local url="$2" + local version="$2" + local url="" local rc desc - if [[ "$EXTERNAL" != [Yy1]* ]]; then + if [[ "${version,,}" != "http"* ]]; then - desc=$(printVersion "$VERSION" "Windows for ${PLATFORM}") + desc=$(printVersion "$version" "Windows for ${PLATFORM}") else + url="$version" desc=$(getName "$BASE" "$BASE") fi - if [[ "$EXTERNAL" != [Yy1]* ]]; then + if [ -z "$url" ]; then + if isESD "$version"; then - if ! getESD "$TMP/esd"; then - url="" - else - url="$ESD_URL" - fi + getESD "$TMP/esd" "$version" && url="$ESD_URL" + fi fi if [ -n "$url" ]; then downloadFile "$iso" "$url" "$desc" && return 0 fi - [[ "$EXTERNAL" == [Yy1]* ]] && return 1 - - case "${VERSION,,}" in - "win11${PLATFORM,,}") - url="https://dl.bobpony.com/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" - ;; - "win10${PLATFORM,,}") - url="https://dl.bobpony.com/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" - ;; - *) - return 1 - ;; - esac + [[ "${version,,}" == "http"* ]] && return 1 + url=$(getLink "$version") + + if [ -z "$url" ]; then + ! isESD "$version" && error "Invalid version specified: $version" + return 1 + fi + info "Failed to download $desc from Microsoft, will try another mirror now..." - rm -rf "$TMP" - mkdir -p "$TMP" - ISO="$TMP/$BASE" iso="$ISO" + rm -rf "$TMP" + mkdir -p "$TMP" + downloadFile "$iso" "$url" "$desc" && return 0 return 1 From 930d7900fbf01a961a2308c9abbffbccd23c4a7d Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 22:14:58 +0200 Subject: [PATCH 10/32] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index d883250..c4e193a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -304,7 +304,7 @@ downloadImage() { return 1 fi - info "Failed to download $desc from Microsoft, will try another mirror now..." + isESD "$version" && info "Failed to download $desc from Microsoft, will try another mirror now..." ISO="$TMP/$BASE" iso="$ISO" From cf19d9e2062a99705a9c5ee4e9ae3352b585d19d Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 28 Apr 2024 22:21:03 +0200 Subject: [PATCH 11/32] Update readme.md --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index fdd17a5..aa983e0 100644 --- a/readme.md +++ b/readme.md @@ -80,10 +80,10 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_ Select from the values below: - | **Value** | **Description** | **Platform** | **Source** | **Size** | - |---|---|---|---|---| - | `win11` | Windows 11 Pro | ARM64 | Microsoft | 4.6 GB | - | `win10` | Windows 10 Pro | ARM64 | Microsoft | 3.9 GB | + | **Value** | **Description** | **Platform** | **Size** | + |---|---|---|---| + | `win11` | Windows 11 Pro | ARM64 | 4.6 GB | + | `win10` | Windows 10 Pro | ARM64 | 3.9 GB | To install x86 or x64 versions of Windows use [dockur/windows](https://github.com/dockur/windows/). From 118ef763b458247480ba6cb3c99e17fdec21c956 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 03:46:41 +0200 Subject: [PATCH 12/32] Update define.sh --- src/define.sh | 54 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/src/define.sh b/src/define.sh index 9dd6856..1b1e6a1 100644 --- a/src/define.sh +++ b/src/define.sh @@ -6,25 +6,6 @@ set -Eeuo pipefail : "${DETECTED:=""}" : "${PLATFORM:="ARM64"}" -getLink() { - - local id="$1" - local url="" - local host="https://dl.bobpony.com" - - case "${id,,}" in - "win11${PLATFORM,,}") - url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" - ;; - "win10${PLATFORM,,}") - url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" - ;; - esac - - echo "$url" - return 0 -} - parseVersion() { [ -z "$VERSION" ] && VERSION="win11" @@ -45,6 +26,22 @@ parseVersion() { return 0 } +validVersion() { + + local id="$1" + + case "${id,,}" in + "win11${PLATFORM,,}") + return 0 + ;; + "win10${PLATFORM,,}") + return 0 + ;; + esac + + return 1 +} + isESD() { local id="$1" @@ -115,4 +112,23 @@ getVersion() { return 0 } +getLink() { + + local id="$1" + local url="" + local host="https://dl.bobpony.com" + + case "${id,,}" in + "win11${PLATFORM,,}") + url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" + ;; + "win10${PLATFORM,,}") + url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" + ;; + esac + + echo "$url" + return 0 +} + return 0 From 0638aed46da4aff61ceb0a035845e6b3af630fe4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 03:57:00 +0200 Subject: [PATCH 13/32] Update install.sh --- src/install.sh | 55 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/install.sh b/src/install.sh index c4e193a..940b529 100644 --- a/src/install.sh +++ b/src/install.sh @@ -270,22 +270,25 @@ downloadImage() { local iso="$1" local version="$2" local url="" + local tried="n" local rc desc - if [[ "${version,,}" != "http"* ]]; then + if [[ "${version,,}" == "http"* ]]; then - desc=$(printVersion "$version" "Windows for ${PLATFORM}") + url="$version" + desc=$(getName "$BASE" "$BASE") else - url="$version" - desc=$(getName "$BASE" "$BASE") + if ! validVersion "$version"; then + error "Invalid VERSION value: $version" && return 1 + fi - fi + desc=$(printVersion "$version" "Windows for ${PLATFORM}") - if [ -z "$url" ]; then if isESD "$version"; then + tried="y" getESD "$TMP/esd" "$version" && url="$ESD_URL" fi @@ -297,22 +300,40 @@ downloadImage() { [[ "${version,,}" == "http"* ]] && return 1 + ISO="$TMP/$BASE" + iso="$ISO" + url=$(getLink "$version") - - if [ -z "$url" ]; then - ! isESD "$version" && error "Invalid version specified: $version" - return 1 + + if [ -n "$url" ]; then + + if [[ "$tried" != "n" ]]; then + info "Failed to download $desc from Microsoft, will try another mirror now..." + fi + + tried="y" + rm -rf "$TMP" + mkdir -p "$TMP" + + downloadFile "$iso" "$url" "$desc" && return 0 + fi - - isESD "$version" && info "Failed to download $desc from Microsoft, will try another mirror now..." - ISO="$TMP/$BASE" - iso="$ISO" + url=$(secondLink "$version") - rm -rf "$TMP" - mkdir -p "$TMP" + if [ -n "$url" ]; then + + if [[ "$tried" != "n" ]]; then + info "Failed to download $desc, will try another mirror now..." + fi + + tried="y" + rm -rf "$TMP" + mkdir -p "$TMP" + + downloadFile "$iso" "$url" "$desc" && return 0 - downloadFile "$iso" "$url" "$desc" && return 0 + fi return 1 } From 144752a2126958235d3bf55932bea4ca1043279f Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 04:07:45 +0200 Subject: [PATCH 14/32] Update install.sh --- src/install.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/install.sh b/src/install.sh index 940b529..5db8be7 100644 --- a/src/install.sh +++ b/src/install.sh @@ -269,37 +269,33 @@ downloadImage() { local iso="$1" local version="$2" - local url="" local tried="n" - local rc desc + local url rc desc if [[ "${version,,}" == "http"* ]]; then - url="$version" desc=$(getName "$BASE" "$BASE") + downloadFile "$iso" "$version" "$desc" && return 0 + return 1 - else + fi - if ! validVersion "$version"; then - error "Invalid VERSION value: $version" && return 1 - fi + if ! validVersion "$version"; then + error "Invalid VERSION value: $version" && return 1 + fi - desc=$(printVersion "$version" "Windows for ${PLATFORM}") + desc=$(printVersion "$version" "Windows for ${PLATFORM}") - if isESD "$version"; then + if isESD "$version"; then - tried="y" - getESD "$TMP/esd" "$version" && url="$ESD_URL" + tried="y" + if getESD "$TMP/esd" "$version"; then + downloadFile "$iso" "$ESD_URL" "$desc" && return 0 fi - fi - if [ -n "$url" ]; then - downloadFile "$iso" "$url" "$desc" && return 0 fi - [[ "${version,,}" == "http"* ]] && return 1 - ISO="$TMP/$BASE" iso="$ISO" From 80679b8fe8da2cf9d279b125a00c632b0ec8483f Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 04:17:06 +0200 Subject: [PATCH 15/32] Update install.sh --- src/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install.sh b/src/install.sh index 5db8be7..613ee7a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -270,7 +270,7 @@ downloadImage() { local iso="$1" local version="$2" local tried="n" - local url rc desc + local url desc if [[ "${version,,}" == "http"* ]]; then From 2bc1ad16fdf0cef008ffdde0ca8079945eb9c14e Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 12:01:00 +0200 Subject: [PATCH 16/32] Update install.sh --- src/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 613ee7a..62873ce 100644 --- a/src/install.sh +++ b/src/install.sh @@ -189,7 +189,7 @@ getESD() { local wFile="catalog.cab" - { wget "$winCatalog" -O "$dir/$wFile" -q --no-check-certificate; rc=$?; } || : + { wget "$winCatalog" -O "$dir/$wFile" -q; rc=$?; } || : (( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1 cd "$dir" @@ -249,7 +249,7 @@ downloadFile() { info "$msg" && html "$msg" /run/progress.sh "$iso" "Downloading $desc ([P])..." & - { wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || : + { wget "$url" -O "$iso" -q --show-progress "$progress"; rc=$?; } || : fKill "progress.sh" From f29f8b8dcca2b4fe1854dbbe84799ebf80fd6830 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 16:13:29 +0200 Subject: [PATCH 17/32] Update install.sh --- src/install.sh | 115 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 36 deletions(-) diff --git a/src/install.sh b/src/install.sh index 62873ce..2d648f6 100644 --- a/src/install.sh +++ b/src/install.sh @@ -51,6 +51,23 @@ finishInstall() { cp /run/version "$STORAGE/windows.ver" + if [[ "${PLATFORM,,}" == "x64" ]]; then + if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then + if [[ "${MACHINE,,}" != "q35" ]]; then + echo "$MACHINE" > "$STORAGE/windows.old" + fi + echo "$BOOT_MODE" > "$STORAGE/windows.mode" + else + # Enable secure boot + TPM on manual installs as Win11 requires + if [[ "$MANUAL" == [Yy1]* ]] || [[ "$aborted" == [Yy1]* ]]; then + if [[ "${DETECTED,,}" == "win11"* ]]; then + BOOT_MODE="windows_secure" + echo "$BOOT_MODE" > "$STORAGE/windows.mode" + fi + fi + fi + fi + rm -rf "$TMP" return 0 } @@ -104,9 +121,13 @@ startInstall() { fi fi + if [[ "${PLATFORM,,}" == "x64" ]]; then + ! migrateFiles "$BASE" "$VERSION" && error "Migration failed!" && exit 57 + fi + if skipInstall; then [ ! -f "$STORAGE/$BASE" ] && BASE="" - VGA="virtio-gpu" + [[ "${PLATFORM,,}" == "arm64" ]] && VGA="virtio-gpu" return 1 fi @@ -135,10 +156,9 @@ startInstall() { if [ ! -f "$STORAGE/$CUSTOM" ]; then CUSTOM="" - if [[ "$EXTERNAL" == [Yy1]* ]]; then - ISO="$TMP/$BASE" - else - ISO="$TMP/$VERSION.esd" + ISO="$TMP/$BASE" + if [[ "${PLATFORM,,}" == "arm64" ]]; then + [[ "$EXTERNAL" != [Yy1]* ]] && ISO="$TMP/$VERSION.esd" fi else ISO="$STORAGE/$CUSTOM" @@ -177,7 +197,7 @@ getESD() { winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361" ;; *) - error "Invalid version specified: $version" && return 1 + error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;; esac @@ -188,6 +208,9 @@ getESD() { mkdir -p "$dir" local wFile="catalog.cab" + local xFile="products.xml" + local eFile="esd_edition.xml" + local fFile="products_filter.xml" { wget "$winCatalog" -O "$dir/$wFile" -q; rc=$?; } || : (( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1 @@ -196,33 +219,33 @@ getESD() { if ! cabextract "$wFile" > /dev/null; then cd /run - error "Failed to extract CAB file!" && return 1 + error "Failed to extract $wFile!" && return 1 fi cd /run - if [ ! -s "$dir/products.xml" ]; then - error "Failed to find products.xml!" && return 1 + if [ ! -s "$dir/$xFile" ]; then + error "Failed to find $xFile in $wFile!" && return 1 fi local esdLang="en-us" local editionName="Professional" local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]' - echo -e '' > "${dir}/products_filter.xml" - xmllint --nonet --xpath "${edQuery}" "${dir}/products.xml" >> "${dir}/products_filter.xml" 2>/dev/null - echo -e ''>> "${dir}/products_filter.xml" - xmllint --nonet --xpath '//File[LanguageCode="'${esdLang}'"]' "${dir}/products_filter.xml" >"${dir}/esd_edition.xml" + echo -e '' > "$dir/$fFile" + xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" >> "$dir/$fFile" 2>/dev/null + echo -e ''>> "$dir/$fFile" + xmllint --nonet --xpath '//File[LanguageCode="'${esdLang}'"]' "$dir/$fFile" >"$dir/$eFile" - size=$(stat -c%s "${dir}/esd_edition.xml") + size=$(stat -c%s "$dir/$eFile") if ((size<20)); then - error "Failed to find Windows product!" && return 1 + error "Failed to find Windows product in $eFile!" && return 1 fi - ESD_URL=$(xmllint --nonet --xpath '//FilePath' "${dir}/esd_edition.xml" | sed -E -e 's/<[\/]?FilePath>//g') + ESD_URL=$(xmllint --nonet --xpath '//FilePath' "$dir/$eFile" | sed -E -e 's/<[\/]?FilePath>//g') if [ -z "$ESD_URL" ]; then - error "Failed to find ESD URL!" && return 1 + error "Failed to find ESD URL in $eFile!" && return 1 fi rm -rf "$dir" @@ -281,10 +304,14 @@ downloadImage() { fi if ! validVersion "$version"; then - error "Invalid VERSION value: $version" && return 1 + error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 fi - desc=$(printVersion "$version" "Windows for ${PLATFORM}") + if [[ "${PLATFORM,,}" == "x64" ]]; then + desc=$(printVersion "$version" "Windows") + else + desc=$(printVersion "$version" "Windows for ${PLATFORM}") + fi if isESD "$version"; then @@ -338,9 +365,10 @@ extractESD() { local iso="$1" local dir="$2" + local version="$3" + local desc="$4" local size size_gb space space_gb desc - desc=$(printVersion "$VERSION" "Windows for ${PLATFORM}") local msg="Extracting $desc bootdisk..." info "$msg" && html "$msg" @@ -365,7 +393,7 @@ extractESD() { wimlib-imagex apply "$iso" 1 "${dir}" --quiet 2>/dev/null || { retVal=$? - error "Extracting bootdisk failed" && return $retVal + error "Extracting $desc bootdisk failed" && return $retVal } local bootWimFile="${dir}/sources/boot.wim" @@ -392,7 +420,7 @@ extractESD() { local edition imageIndex imageEdition - case "${VERSION,,}" in + case "${version,,}" in "win11${PLATFORM,,}") edition="11 pro" ;; @@ -400,7 +428,7 @@ extractESD() { edition="10 pro" ;; *) - error "Invalid version specified: $VERSION" && return 1 + error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;; esac @@ -409,7 +437,7 @@ extractESD() { [[ "${imageEdition,,}" != *"$edition"* ]] && continue wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || { retVal=$? - error "Addition of ${imageIndex} to the image failed" && return $retVal + error "Addition of ${imageIndex} to the $desc image failed" && return $retVal } return 0 done @@ -421,16 +449,17 @@ extractImage() { local iso="$1" local dir="$2" + local version="$3" local desc="downloaded ISO" local size size_gb space space_gb - if [[ "${iso,,}" == *".esd" ]]; then - extractESD "$iso" "$dir" && return 0 - return 1 + if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then + desc=$(printVersion "$version" "downloaded ISO") fi - if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then - desc=$(printVersion "$VERSION" "downloaded ISO") + if [[ "${iso,,}" == *".esd" ]]; then + extractESD "$iso" "$dir" "$version" "$desc" && return 0 + return 1 fi local msg="Extracting $desc image..." @@ -487,7 +516,7 @@ detectImage() { local dsc dsc=$(printVersion "$DETECTED" "$DETECTED") - warn "got $dsc, but no matching XML file exists, $FB." + warn "got $dsc, but no matching $DETECTED.xml file exists, $FB." fi return 0 @@ -495,10 +524,18 @@ detectImage() { info "Detecting Windows version from ISO image..." + if [[ "${PLATFORM,,}" == "x64" ]]; then + if [ -f "$dir/WIN51" ] || [ -f "$dir/SETUPXP.HTM" ]; then + DETECTED="winxpx86" + info "Detected: Windows XP" && return 0 + fi + fi + local src loc tag result name name2 desc src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1) if [ ! -d "$src" ]; then + [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" warn "failed to locate 'sources' folder in ISO image, $FB" && return 1 fi @@ -506,6 +543,7 @@ detectImage() { [ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1) if [ ! -f "$loc" ]; then + [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1 fi @@ -533,7 +571,7 @@ detectImage() { [[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml" info "Detected: $desc" else - warn "detected $desc, but no matching XML file exists, $FB." + warn "detected $desc, but no matching $DETECTED.xml file exists, $FB." fi return 0 @@ -572,6 +610,7 @@ updateImage() { src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1) if [ ! -d "$src" ]; then + [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" warn "failed to locate 'sources' folder in ISO image, $FB" && return 1 fi @@ -579,10 +618,11 @@ updateImage() { [ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1) if [ ! -f "$loc" ]; then + [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1 fi - info "Adding XML file for automatic installation..." + info "Adding "$(basename $asset)" for automatic installation..." index="1" result=$(wimlib-imagex info -xml "$loc" | tr -d '\000') @@ -592,7 +632,7 @@ updateImage() { fi if ! wimlib-imagex update "$loc" "$index" --command "add $asset /autounattend.xml" > /dev/null; then - warn "failed to add XML to ISO image, $FB" && return 1 + warn "failed to add "$(basename $asset)" to ISO image, $FB" && return 1 fi return 0 @@ -675,13 +715,16 @@ buildImage() { bootWindows() { + rm -rf "$TMP" + if [ -s "$STORAGE/windows.mode" ] && [ -f "$STORAGE/windows.mode" ]; then BOOT_MODE=$(<"$STORAGE/windows.mode") - rm -rf "$TMP" + if [ -s "$STORAGE/windows.old" ] && [ -f "$STORAGE/windows.old" ]; then + [[ "${PLATFORM,,}" == "x64" ]] && MACHINE=$(<"$STORAGE/windows.old") + fi return 0 fi - rm -rf "$TMP" return 0 } @@ -702,7 +745,7 @@ if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then fi fi -if ! extractImage "$ISO" "$DIR"; then +if ! extractImage "$ISO" "$DIR" "$VERSION"; then rm -f "$ISO" exit 62 fi From 0d57c4334f636d5d3fe8bbad07f2a2a292e3536d Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 16:50:51 +0200 Subject: [PATCH 18/32] Update install.sh --- src/install.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/install.sh b/src/install.sh index 2d648f6..3452d21 100644 --- a/src/install.sh +++ b/src/install.sh @@ -582,17 +582,37 @@ prepareImage() { local iso="$1" local dir="$2" - if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then - return 0 + if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then + if [[ "${DETECTED,,}" != "winxp"* ]] && [[ "${DETECTED,,}" != "win2008"* ]]; then + if [[ "${DETECTED,,}" != "winvista"* ]] && [[ "${DETECTED,,}" != "win7"* ]]; then + + if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then + return 0 + fi + + if [ ! -f "$dir/$ETFS" ]; then + warn "failed to locate file 'etfsboot.com' in ISO image, falling back to legacy boot!" + else + warn "failed to locate file 'efisys_noprompt.bin' in ISO image, falling back to legacy boot!" + fi + + fi + fi fi - if [ ! -f "$dir/$ETFS" ]; then - warn "failed to locate file 'etfsboot.com' in ISO image!" + [[ "${PLATFORM,,}" == "arm64" ]] && return 1 + + if [[ "${DETECTED,,}" == "winxp"* ]]; then + if ! prepareXP "$iso" "$dir"; then + error "Failed to prepare Windows XP ISO!" && return 1 + fi else - warn "failed to locate file 'efisys_noprompt.bin' in ISO image!" + if ! prepareLegacy "$iso" "$dir"; then + error "Failed to prepare Windows ISO!" && return 1 + fi fi - return 1 + return 0 } updateImage() { From a959cc58a90e7447a6cad457bb64d86c26387c98 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 16:57:16 +0200 Subject: [PATCH 19/32] Update install.sh --- src/install.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/install.sh b/src/install.sh index 3452d21..379170a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -745,6 +745,40 @@ bootWindows() { return 0 fi + # Migrations + + [[ "${PLATFORM,,}" != "x64" ]] && return 0 + + if [ -f "$STORAGE/windows.old" ]; then + MACHINE=$(<"$STORAGE/windows.old") + [ -z "$MACHINE" ] && MACHINE="q35" + BOOT_MODE="windows_legacy" + echo "$BOOT_MODE" > "$STORAGE/windows.mode" + return 0 + fi + + local creation="1.10" + local minimal="2.14" + + if [ -f "$STORAGE/windows.ver" ]; then + creation=$(<"$STORAGE/windows.ver") + [[ "${creation}" != *"."* ]] && creation="$minimal" + fi + + # Force secure boot on installs created prior to v2.14 + if (( $(echo "$creation < $minimal" | bc -l) )); then + if [[ "${BOOT_MODE,,}" == "windows" ]]; then + BOOT_MODE="windows_secure" + echo "$BOOT_MODE" > "$STORAGE/windows.mode" + if [ -f "$STORAGE/windows.rom" ] && [ ! -f "$STORAGE/$BOOT_MODE.rom" ]; then + mv "$STORAGE/windows.rom" "$STORAGE/$BOOT_MODE.rom" + fi + if [ -f "$STORAGE/windows.vars" ] && [ ! -f "$STORAGE/$BOOT_MODE.vars" ]; then + mv "$STORAGE/windows.vars" "$STORAGE/$BOOT_MODE.vars" + fi + fi + fi + return 0 } From 063928c917fbc4a29a34c99851d14270149fe010 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 17:01:50 +0200 Subject: [PATCH 20/32] Update install.sh --- src/install.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 379170a..8a50e65 100644 --- a/src/install.sh +++ b/src/install.sh @@ -690,6 +690,7 @@ copyOEM() { buildImage() { local dir="$1" + local failed="N" local cat="BOOT.CAT" local label="${BASE%.*}" local log="/run/shm/iso.log" @@ -713,8 +714,33 @@ buildImage() { error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1 fi - if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \ - -udf -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -allow-limited-size -quiet "$dir" 2> "$log"; then + if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then + + if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \ + -udf -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -allow-limited-size -quiet "$dir" 2> "$log"; then + failed="Y" + fi + + else + + if [[ "${DETECTED,,}" != "winxp"* ]]; then + + if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \ + -udf -allow-limited-size -quiet "$dir" 2> "$log"; then + failed="Y" + fi + + else + + if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -c "$cat" -iso-level 2 -J -l -D -N -joliet-long \ + -relaxed-filenames -V "$label" -quiet "$dir" 2> "$log"; then + failed="Y" + fi + + fi + fi + + if [[ "$failed" != "N" ]]; then [ -s "$log" ] && echo "$(<"$log")" error "Failed to build image!" && return 1 fi From 3e1c3b1a3705a03108c710e5a402e0bd7c5b4bac Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 17:07:54 +0200 Subject: [PATCH 21/32] Update install.sh --- src/install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/install.sh b/src/install.sh index 8a50e65..2b7cb46 100644 --- a/src/install.sh +++ b/src/install.sh @@ -313,8 +313,25 @@ downloadImage() { desc=$(printVersion "$version" "Windows for ${PLATFORM}") fi + if [[ "${PLATFORM,,}" == "x64" ]]; then + if isMido "$version"; then + tried="y" + doMido "$iso" "$version" "$desc" && return 0 + fi + fi + if isESD "$version"; then + if [[ "${PLATFORM,,}" == "x64" ]]; then + + [[ "$tried" != "n" ]] && info "Failed to download $desc using Mido, will try a different method now..." + + ISO="$TMP/$version.esd" + iso="$ISO" + rm -rf "$TMP" + mkdir -p "$TMP" + fi + tried="y" if getESD "$TMP/esd" "$version"; then From a73b13b5f14926a2519a7e99b08c179f063247f6 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 18:21:36 +0200 Subject: [PATCH 22/32] Update power.sh --- src/power.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/power.sh b/src/power.sh index 5b3849d..1a4722c 100644 --- a/src/power.sh +++ b/src/power.sh @@ -23,6 +23,21 @@ _trap() { done } +boot() { + + [ -f "$QEMU_END" ] && return 0 + + if [ -s "$QEMU_PTY" ]; then + if grep -iq " hard" "$QEMU_PTY"; then + info "Windows started succesfully, visit http://localhost:8006/ to view the screen..." + return 0 + fi + fi + + error "Timeout while waiting for QEMU to boot the machine!" + return 0 +} + ready() { [ -f "$STORAGE/windows.boot" ] && return 0 From 2273977dc1ffdc5a94d93ff0b518d61d00e63508 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 29 Apr 2024 18:22:34 +0200 Subject: [PATCH 23/32] Update entry.sh --- src/entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entry.sh b/src/entry.sh index 6eaac0d..7b59927 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -29,8 +29,8 @@ info "Booting ${APP}${BOOT_DESC}..." (( rc != 0 )) && error "$(<"$QEMU_LOG")" && exit 15 terminal +( sleep 10; boot ) & tail -fn +0 "$QEMU_LOG" 2>/dev/null & -( sleep 10; [ ! -f "$QEMU_END" ] && info "Windows started succesfully, visit http://localhost:8006/ to view the screen..." ) & cat "$QEMU_TERM" 2> /dev/null | tee "$QEMU_PTY" & wait $! || : From fc4ff994ae4ffc629f5aa4b2b518047941e7b651 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 00:33:04 +0200 Subject: [PATCH 24/32] build: Update qemu-arm to v1.16 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 78c294a..948b83f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM scratch -COPY --from=qemux/qemu-arm:1.15 / / +COPY --from=qemux/qemu-arm:1.16 / / ARG DEBCONF_NOWARNINGS "yes" ARG DEBIAN_FRONTEND "noninteractive" From 1fbd1511e07e85818f5de35796629d0a8f813272 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 03:35:38 +0200 Subject: [PATCH 25/32] Update install.sh --- src/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/install.sh b/src/install.sh index 2b7cb46..aac1556 100644 --- a/src/install.sh +++ b/src/install.sh @@ -257,7 +257,7 @@ downloadFile() { local iso="$1" local url="$2" local desc="$3" - local rc progress + local rc progress domain rm -f "$iso" @@ -268,7 +268,9 @@ downloadFile() { progress="--progress=dot:giga" fi - local msg="Downloading $desc..." + domain=$(echo "$url" | awk -F/ '{print $3}') + local msg="Downloading $desc from $domain..." + info "$msg" && html "$msg" /run/progress.sh "$iso" "Downloading $desc ([P])..." & From c5a65c40a7e682c355fa5c2ee1ca84bb6881188f Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 06:19:56 +0200 Subject: [PATCH 26/32] Update install.sh --- src/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/install.sh b/src/install.sh index aac1556..31ecdd3 100644 --- a/src/install.sh +++ b/src/install.sh @@ -269,6 +269,7 @@ downloadFile() { fi domain=$(echo "$url" | awk -F/ '{print $3}') + domain=$(expr match "$domain" '.*\.\(.*\..*\)') local msg="Downloading $desc from $domain..." info "$msg" && html "$msg" @@ -320,6 +321,7 @@ downloadImage() { tried="y" doMido "$iso" "$version" "$desc" && return 0 fi + switchEdition "$version" fi if isESD "$version"; then From 7ad1456d4796fd104228a99ff6c8c1c61f8cfcc5 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 06:21:38 +0200 Subject: [PATCH 27/32] Update define.sh --- src/define.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/define.sh b/src/define.sh index 1b1e6a1..ca2e394 100644 --- a/src/define.sh +++ b/src/define.sh @@ -112,7 +112,7 @@ getVersion() { return 0 } -getLink() { +secondLink() { local id="$1" local url="" From 65b680124a80af2c6082f9a37ad4a6b77dab48e1 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 06:34:01 +0200 Subject: [PATCH 28/32] Update define.sh --- src/define.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/define.sh b/src/define.sh index ca2e394..78f82a2 100644 --- a/src/define.sh +++ b/src/define.sh @@ -112,8 +112,31 @@ getVersion() { return 0 } +getLink() { + + # Fallbacks for users who cannot connect to the Microsoft servers + + local id="$1" + local url="" + local host="https://drive.massgrave.dev" + + case "${id,,}" in + "win11${PLATFORM,,}") + url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO" + ;; + "win10${PLATFORM,,}") + url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO" + ;; + esac + + echo "$url" + return 0 +} + secondLink() { + # Fallbacks for users who cannot connect to the Microsoft servers + local id="$1" local url="" local host="https://dl.bobpony.com" From 9d28015354020a3d7249cfe6fdff8ac02c97db78 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 06:47:05 +0200 Subject: [PATCH 29/32] Update define.sh --- src/define.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/define.sh b/src/define.sh index 78f82a2..423ee5b 100644 --- a/src/define.sh +++ b/src/define.sh @@ -15,10 +15,10 @@ parseVersion() { fi case "${VERSION,,}" in - "11" | "win11") + "11" | "win11" | "windows11" | "windows 11") VERSION="win11${PLATFORM,,}" ;; - "10" | "win10") + "10" | "win10" | "windows10" | "windows 10") VERSION="win10${PLATFORM,,}" ;; esac From 17f5a7481655141fe687513a4710fff9b0497937 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 07:06:58 +0200 Subject: [PATCH 30/32] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index aa983e0..adcc189 100644 --- a/readme.md +++ b/readme.md @@ -80,7 +80,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_ Select from the values below: - | **Value** | **Description** | **Platform** | **Size** | + | **Value** | **Version** | **Platform** | **Size** | |---|---|---|---| | `win11` | Windows 11 Pro | ARM64 | 4.6 GB | | `win10` | Windows 10 Pro | ARM64 | 3.9 GB | From cacb1e6fda1086ab9d29156fcf9fde780b968510 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 23:02:33 +0200 Subject: [PATCH 31/32] Update install.sh --- src/install.sh | 77 ++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/src/install.sh b/src/install.sh index 31ecdd3..3f5ef53 100644 --- a/src/install.sh +++ b/src/install.sh @@ -34,13 +34,13 @@ finishInstall() { local aborted="$2" if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then - error "Failed to find ISO: $iso" && return 1 + error "Failed to find ISO file: $iso" && return 1 fi if [ -w "$iso" ] && [[ "$aborted" != [Yy1]* ]]; then # Mark ISO as prepared via magic byte if ! printf '\x16' | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then - error "Failed to set magic byte!" && return 1 + error "Failed to set magic byte in ISO file: $iso" && return 1 fi fi @@ -53,10 +53,10 @@ finishInstall() { if [[ "${PLATFORM,,}" == "x64" ]]; then if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then + echo "$BOOT_MODE" > "$STORAGE/windows.mode" if [[ "${MACHINE,,}" != "q35" ]]; then echo "$MACHINE" > "$STORAGE/windows.old" fi - echo "$BOOT_MODE" > "$STORAGE/windows.mode" else # Enable secure boot + TPM on manual installs as Win11 requires if [[ "$MANUAL" == [Yy1]* ]] || [[ "$aborted" == [Yy1]* ]]; then @@ -78,7 +78,7 @@ abortInstall() { if [[ "$iso" != "$STORAGE/$BASE" ]]; then if ! mv -f "$iso" "$STORAGE/$BASE"; then - error "Failed to move ISO: $iso" && return 1 + error "Failed to move ISO file: $iso" && return 1 fi fi @@ -102,18 +102,14 @@ startInstall() { CUSTOM="" - if [[ "${VERSION,,}" == "http"* ]]; then - EXTERNAL="Y" - else - EXTERNAL="N" - fi - - if [[ "$EXTERNAL" != [Yy1]* ]]; then + if [[ "${VERSION,,}" != "http"* ]]; then + EXTERNAL="N" BASE="$VERSION.iso" else + EXTERNAL="Y" BASE=$(basename "${VERSION%%\?*}") : "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}" BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') @@ -157,9 +153,6 @@ startInstall() { if [ ! -f "$STORAGE/$CUSTOM" ]; then CUSTOM="" ISO="$TMP/$BASE" - if [[ "${PLATFORM,,}" == "arm64" ]]; then - [[ "$EXTERNAL" != [Yy1]* ]] && ISO="$TMP/$VERSION.esd" - fi else ISO="$STORAGE/$CUSTOM" fi @@ -268,9 +261,11 @@ downloadFile() { progress="--progress=dot:giga" fi + local msg="Downloading $desc..." + domain=$(echo "$url" | awk -F/ '{print $3}') - domain=$(expr match "$domain" '.*\.\(.*\..*\)') - local msg="Downloading $desc from $domain..." + domain=$(expr "$domain" : '.*\.\(.*\..*\)') + [[ "${domain,,}" != *"microsoft.com" ]] && msg="Downloading $desc from $domain..." info "$msg" && html "$msg" /run/progress.sh "$iso" "Downloading $desc ([P])..." & @@ -326,27 +321,20 @@ downloadImage() { if isESD "$version"; then - if [[ "${PLATFORM,,}" == "x64" ]]; then - - [[ "$tried" != "n" ]] && info "Failed to download $desc using Mido, will try a different method now..." - - ISO="$TMP/$version.esd" - iso="$ISO" - rm -rf "$TMP" - mkdir -p "$TMP" + if [[ "$tried" != "n" ]]; then + info "Failed to download $desc using Mido, will try a diferent method now..." fi tried="y" if getESD "$TMP/esd" "$version"; then - downloadFile "$iso" "$ESD_URL" "$desc" && return 0 + ISO="$TMP/$version.esd" + downloadFile "$ISO" "$ESD_URL" "$desc" && return 0 + ISO="$TMP/$BASE" fi fi - ISO="$TMP/$BASE" - iso="$ISO" - url=$(getLink "$version") if [ -n "$url" ]; then @@ -356,9 +344,6 @@ downloadImage() { fi tried="y" - rm -rf "$TMP" - mkdir -p "$TMP" - downloadFile "$iso" "$url" "$desc" && return 0 fi @@ -372,9 +357,6 @@ downloadImage() { fi tried="y" - rm -rf "$TMP" - mkdir -p "$TMP" - downloadFile "$iso" "$url" "$desc" && return 0 fi @@ -515,6 +497,7 @@ extractImage() { detectImage() { XML="" + local dsc local dir="$1" if [ -n "$CUSTOM" ]; then @@ -534,10 +517,9 @@ detectImage() { if [[ "${DETECTED,,}" != "winxp"* ]]; then - local dsc dsc=$(printVersion "$DETECTED" "$DETECTED") - warn "got $dsc, but no matching $DETECTED.xml file exists, $FB." + warn "got $dsc, but no matching file called $DETECTED.xml exists, $FB." fi return 0 @@ -547,8 +529,14 @@ detectImage() { if [[ "${PLATFORM,,}" == "x64" ]]; then if [ -f "$dir/WIN51" ] || [ -f "$dir/SETUPXP.HTM" ]; then - DETECTED="winxpx86" - info "Detected: Windows XP" && return 0 + if [ -d "$dir/AMD64" ]; then + DETECTED="winxpx64" + else + DETECTED="winxpx86" + fi + dsc=$(printVersion "$DETECTED" "$DETECTED") + info "Detected: $dsc" + return 0 fi fi @@ -592,7 +580,7 @@ detectImage() { [[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml" info "Detected: $desc" else - warn "detected $desc, but no matching $DETECTED.xml file exists, $FB." + warn "detected $desc, but no matching file called $DETECTED.xml exists, $FB." fi return 0 @@ -641,7 +629,7 @@ updateImage() { local iso="$1" local dir="$2" local asset="/run/assets/$3" - local path src loc index result + local path src loc xml index result [ ! -s "$asset" ] || [ ! -f "$asset" ] && return 0 @@ -663,7 +651,8 @@ updateImage() { warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1 fi - info "Adding "$(basename $asset)" for automatic installation..." + xml=$(basename "$asset") + info "Adding $xml for automatic installation..." index="1" result=$(wimlib-imagex info -xml "$loc" | tr -d '\000') @@ -673,7 +662,7 @@ updateImage() { fi if ! wimlib-imagex update "$loc" "$index" --command "add $asset /autounattend.xml" > /dev/null; then - warn "failed to add "$(basename $asset)" to ISO image, $FB" && return 1 + warn "failed to add $xml to ISO image, $FB" && return 1 fi return 0 @@ -841,13 +830,13 @@ fi if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then if ! downloadImage "$ISO" "$VERSION"; then - rm -f "$ISO" + rm -f "$ISO" 2> /dev/null || true exit 61 fi fi if ! extractImage "$ISO" "$DIR" "$VERSION"; then - rm -f "$ISO" + rm -f "$ISO" 2> /dev/null || true exit 62 fi From fb989990267387cd25c3f82946ad740df8514c1e Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 30 Apr 2024 23:20:15 +0200 Subject: [PATCH 32/32] Update define.sh --- src/define.sh | 90 +++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 50 deletions(-) diff --git a/src/define.sh b/src/define.sh index 423ee5b..2175587 100644 --- a/src/define.sh +++ b/src/define.sh @@ -26,38 +26,6 @@ parseVersion() { return 0 } -validVersion() { - - local id="$1" - - case "${id,,}" in - "win11${PLATFORM,,}") - return 0 - ;; - "win10${PLATFORM,,}") - return 0 - ;; - esac - - return 1 -} - -isESD() { - - local id="$1" - - case "${id,,}" in - "win11${PLATFORM,,}") - return 0 - ;; - "win10${PLATFORM,,}") - return 0 - ;; - esac - - return 1 -} - printVersion() { local id="$1" @@ -83,18 +51,10 @@ getName() { [[ "${file,,}" == *"windows10"* ]] && desc="Windows 10" [[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11" [[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10" + [[ "${file,,}" == *"windows 11"* ]] && desc="Windows 11" + [[ "${file,,}" == *"windows 10"* ]] && desc="Windows 10" - if [ -z "$desc" ]; then - desc="Windows" - else - if [[ "$desc" == "Windows 1"* ]] && [[ "${file,,}" == *"_iot_"* ]]; then - desc="$desc IoT" - else - if [[ "$desc" == "Windows 1"* ]] && [[ "${file,,}" == *"_ltsc_"* ]]; then - desc="$desc LTSC" - fi - fi - fi + [ -z "$desc" ] && desc="Windows" echo "$desc for ${PLATFORM}" return 0 @@ -112,20 +72,36 @@ getVersion() { return 0 } +isESD() { + + local id="$1" + + case "${id,,}" in + "win11${PLATFORM,,}") + return 0 + ;; + "win10${PLATFORM,,}") + return 0 + ;; + esac + + return 1 +} + getLink() { # Fallbacks for users who cannot connect to the Microsoft servers local id="$1" local url="" - local host="https://drive.massgrave.dev" + local host="https://dl.bobpony.com" case "${id,,}" in "win11${PLATFORM,,}") - url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO" + url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" ;; "win10${PLATFORM,,}") - url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO" + url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" ;; esac @@ -139,14 +115,14 @@ secondLink() { local id="$1" local url="" - local host="https://dl.bobpony.com" + local host="https://drive.massgrave.dev" case "${id,,}" in "win11${PLATFORM,,}") - url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso" + url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO" ;; "win10${PLATFORM,,}") - url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso" + url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO" ;; esac @@ -154,4 +130,18 @@ secondLink() { return 0 } -return 0 +validVersion() { + + local id="$1" + local url + + isESD "$id" && return 0 + + url=$(getLink "$id") + [ -n "$url" ] && return 0 + + url=$(secondLink "$id") + [ -n "$url" ] && return 0 + + return 1 +}