diff --git a/assets/win10arm64.xml b/assets/win10arm64.xml
index 4fe9fc0..5c08974 100644
--- a/assets/win10arm64.xml
+++ b/assets/win10arm64.xml
@@ -392,7 +392,12 @@
12
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Power" /v "HibernateEnabled" /t REG_DWORD /d 0 /f
- Disable Hibernation Mode
+ Disable Hibernation
+
+
+ 13
+ cmd /C POWERCFG -X -standby-timeout-ac 0
+ Disable Sleep
diff --git a/assets/win11arm64.xml b/assets/win11arm64.xml
index 32022b5..c7e5574 100644
--- a/assets/win11arm64.xml
+++ b/assets/win11arm64.xml
@@ -411,15 +411,20 @@
12
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Power" /v "HibernateEnabled" /t REG_DWORD /d 0 /f
- Disable Hibernation Mode
+ Disable Hibernation
13
+ cmd /C POWERCFG -X -standby-timeout-ac 0
+ Disable Sleep
+
+
+ 14
reg.exe add "HKCU\Control Panel\UnsupportedHardwareNotificationCache" /v SV1 /d 0 /t REG_DWORD /f
Disable unsupported hardware notifications
- 14
+ 15
reg.exe add "HKCU\Control Panel\UnsupportedHardwareNotificationCache" /v SV2 /d 0 /t REG_DWORD /f
Disable unsupported hardware notifications
diff --git a/src/entry.sh b/src/entry.sh
index 47a7652..0537683 100644
--- a/src/entry.sh
+++ b/src/entry.sh
@@ -29,7 +29,7 @@ info "Booting ${APP}${BOOT_DESC} on a ${CPU} using QEMU v${VERS} with kernel $(u
terminal
tail -fn +0 "$QEMU_LOG" 2>/dev/null &
-( sleep 6; [ ! -f "$QEMU_END" ] && info "Windows started succesfully, visit http://localhost:8006/ to view the screen..." ) &
+( 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 $! || :
diff --git a/src/install.sh b/src/install.sh
index 0645877..cb0bb4d 100644
--- a/src/install.sh
+++ b/src/install.sh
@@ -2,8 +2,10 @@
set -Eeuo pipefail
: "${MANUAL:=""}"
+: "${VERSION:=""}"
: "${DETECTED:=""}"
-: "${VERSION:="win11arm64"}"
+
+[ -z "$VERSION" ] && VERSION="win11arm64"
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
VERSION="${VERSION:1:-1}"
@@ -27,6 +29,7 @@ if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then
fi
ESD_URL=""
+PLATFORM="ARM64"
TMP="$STORAGE/tmp"
DIR="$TMP/unpack"
FB="falling back to manual installation!"
@@ -36,11 +39,13 @@ EFISYS="efi/microsoft/boot/efisys_noprompt.bin"
printVersion() {
local id="$1"
- local desc=""
+ 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
}
@@ -48,7 +53,7 @@ printVersion() {
getName() {
local file="$1"
- local desc=""
+ local desc="$2"
[[ "${file,,}" == "win11"* ]] && desc="Windows 11 for ARM"
[[ "${file,,}" == "win10"* ]] && desc="Windows 10 for ARM"
@@ -57,6 +62,8 @@ getName() {
[[ "${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
}
@@ -99,15 +106,13 @@ finishInstall() {
local aborted="$2"
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
- error "Failed to find ISO: $iso"
- return 1
+ error "Failed to find ISO: $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!" && return 1
fi
fi
@@ -125,17 +130,13 @@ abortInstall() {
if [[ "$iso" != "$STORAGE/$BASE" ]]; then
if ! mv -f "$iso" "$STORAGE/$BASE"; then
- error "Failed to move ISO: $iso"
- exit 69
+ error "Failed to move ISO: $iso" && return 1
fi
fi
- if ! finishInstall "$STORAGE/$BASE" "Y"; then
- error "Failed to finish installation!"
- exit 69
- fi
+ finishInstall "$STORAGE/$BASE" "Y" && return 0
- return 0
+ return 1
}
startInstall() {
@@ -218,20 +219,17 @@ startInstall() {
getESD() {
local dir="$1"
- local file="$2"
- local architecture="ARM64"
local winCatalog size
case "${VERSION,,}" in
- win11arm64)
+ "win11${PLATFORM,,}")
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
;;
- win10arm64)
+ "win10${PLATFORM,,}")
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
;;
*)
- error "Invalid version specified: $VERSION"
- return 1
+ error "Invalid version specified: $VERSION" && return 1
;;
esac
@@ -261,7 +259,7 @@ getESD() {
local esdLang="en-us"
local editionName="Professional"
- local edQuery='//File[Architecture="'${architecture}'"][Edition="'${editionName}'"]'
+ 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
@@ -276,48 +274,22 @@ getESD() {
ESD_URL=$(xmllint --nonet --xpath '//FilePath' "${dir}/esd_edition.xml" | 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!" && return 1
fi
rm -rf "$dir"
return 0
}
-downloadImage() {
+downloadFile() {
local iso="$1"
local url="$2"
- local desc rc progress
+ local desc="$3"
+ local rc progress
rm -f "$iso"
- if [[ "$EXTERNAL" != [Yy1]* ]]; then
-
- desc=$(printVersion "$VERSION")
- [ -z "$desc" ] && desc="Windows"
-
- else
-
- desc=$(getName "$BASE")
- [ -z "$desc" ] && desc="$BASE"
-
- fi
-
- if [[ "$EXTERNAL" != [Yy1]* ]]; then
-
- if ! getESD "$TMP/esd" "$iso"; then
- return 1
- fi
-
- url="$ESD_URL"
-
- fi
-
- local msg="Downloading $desc..."
- info "$msg" && html "$msg"
-
- /run/progress.sh "$iso" "Downloading $desc ([P])..." &
-
# Check if running with interactive TTY or redirected to docker log
if [ -t 1 ]; then
progress="--progress=bar:noscroll"
@@ -325,15 +297,81 @@ downloadImage() {
progress="--progress=dot:giga"
fi
+ local msg="Downloading $desc..."
+ info "$msg" && html "$msg"
+ /run/progress.sh "$iso" "Downloading $desc ([P])..." &
+
{ wget "$url" -O "$iso" -q --no-check-certificate --show-progress "$progress"; rc=$?; } || :
fKill "progress.sh"
- (( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60
- [ ! -s "$iso" ] || [ ! -f "$iso" ] && return 1
+ if (( rc == 0 )) && [ -f "$iso" ]; then
+ if [ "$(stat -c%s "$iso")" -gt 100000000 ]; then
+ html "Download finished successfully..." && return 0
+ fi
+ fi
- html "Download finished successfully..."
- return 0
+ rm -f "$iso"
+ error "Failed to download $url , reason: $rc"
+
+ return 1
+}
+
+downloadImage() {
+
+ local iso="$1"
+ local url="$2"
+ local rc desc
+
+ if [[ "$EXTERNAL" != [Yy1]* ]]; then
+
+ desc=$(printVersion "$VERSION" "Windows for ARM")
+
+ else
+
+ desc=$(getName "$BASE" "$BASE")
+
+ fi
+
+ if [[ "$EXTERNAL" != [Yy1]* ]]; then
+
+ if ! getESD "$TMP/esd"; then
+ url=""
+ else
+ 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
+
+ info "Failed to download $desc from Microsoft, will try another mirror now..."
+
+ rm -rf "$TMP"
+ mkdir -p "$TMP"
+
+ ISO="$TMP/$BASE"
+ iso="$ISO"
+
+ downloadFile "$iso" "$url" "$desc" && return 0
+
+ return 1
}
extractESD() {
@@ -342,26 +380,26 @@ extractESD() {
local dir="$2"
local size size_gb space space_gb desc
- desc=$(printVersion "$VERSION")
+ desc=$(printVersion "$VERSION" "Windows for ARM")
local msg="Extracting $desc bootdisk..."
info "$msg" && html "$msg"
- size=16106127360
- size_gb=$(( (size + 1073741823)/1073741824 ))
- space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
- space_gb=$(( (space + 1073741823)/1073741824 ))
-
- if ((size<10000000)); then
- error "Invalid ESD file: Size is smaller than 10 MB" && exit 62
- fi
-
- if (( size > space )); then
- error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63
+ if [ "$(stat -c%s "$iso")" -lt 100000000 ]; then
+ error "Invalid ESD file: Size is smaller than 100 MB" && return 1
fi
rm -rf "$dir"
mkdir -p "$dir"
+ size=16106127360
+ size_gb=$(( (size + 1073741823)/1073741824 ))
+ space=$(df --output=avail -B 1 "$dir" | tail -n 1)
+ space_gb=$(( (space + 1073741823)/1073741824 ))
+
+ if (( size > space )); then
+ error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
+ fi
+
local esdImageCount
esdImageCount=$(wimlib-imagex info "${iso}" | awk '/Image Count:/ {print $3}')
@@ -395,15 +433,14 @@ extractESD() {
local edition imageIndex imageEdition
case "${VERSION,,}" in
- win11arm64)
+ "win11${PLATFORM,,}")
edition="11 pro"
;;
- win10arm64)
+ "win10${PLATFORM,,}")
edition="10 pro"
;;
*)
- error "Invalid version specified: $VERSION"
- return 1
+ error "Invalid version specified: $VERSION" && return 1
;;
esac
@@ -417,8 +454,7 @@ extractESD() {
return 0
done
- error "Failed to find product in install.wim!"
- return 1
+ error "Failed to find product in install.wim!" && return 1
}
extractImage() {
@@ -429,42 +465,38 @@ extractImage() {
local size size_gb space space_gb
if [[ "${iso,,}" == *".esd" ]]; then
- if ! extractESD "$iso" "$dir"; then
- rm -f "$iso"
- error "Failed to extract ESD file!"
- exit 67
- fi
- return 0
+ extractESD "$iso" "$dir" && return 0
+ return 1
fi
if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then
- desc=$(printVersion "$VERSION")
- [ -z "$desc" ] && desc="downloaded ISO"
+ desc=$(printVersion "$VERSION" "downloaded ISO")
fi
local msg="Extracting $desc image..."
[ -n "$CUSTOM" ] && msg="Extracting local ISO image..."
info "$msg" && html "$msg"
+ rm -rf "$dir"
+ mkdir -p "$dir"
+
size=$(stat -c%s "$iso")
size_gb=$(( (size + 1073741823)/1073741824 ))
- space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
+ space=$(df --output=avail -B 1 "$dir" | tail -n 1)
space_gb=$(( (space + 1073741823)/1073741824 ))
- if ((size<10000000)); then
- error "Invalid ISO file: Size is smaller than 10 MB" && exit 62
+ if ((size<100000000)); then
+ error "Invalid ISO file: Size is smaller than 100 MB" && return 1
fi
if (( size > space )); then
- error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && exit 63
+ error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
fi
rm -rf "$dir"
if ! 7z x "$iso" -o"$dir" > /dev/null; then
- rm -f "$iso"
- error "Failed to extract ISO file!"
- exit 66
+ error "Failed to extract ISO file: $iso" && return 1
fi
return 0
@@ -493,8 +525,7 @@ detectImage() {
if [[ "${DETECTED,,}" != "winxp"* ]]; then
local dsc
- dsc=$(printVersion "$DETECTED")
- [ -z "$dsc" ] && dsc="$DETECTED"
+ dsc=$(printVersion "$DETECTED" "$DETECTED")
warn "got $dsc, but no matching XML file exists, $FB."
fi
@@ -508,16 +539,14 @@ detectImage() {
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1)
if [ ! -d "$src" ]; then
- warn "failed to locate 'sources' folder in ISO image, $FB"
- return 0
+ warn "failed to locate 'sources' folder in ISO image, $FB" && return 1
fi
loc=$(find "$src" -maxdepth 1 -type f -iname install.wim | head -n 1)
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1)
if [ ! -f "$loc" ]; then
- warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB"
- return 0
+ warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1
fi
tag="DISPLAYNAME"
@@ -535,12 +564,10 @@ detectImage() {
fi
if [ -z "$DETECTED" ]; then
- warn "failed to determine Windows version from string '$name', $FB"
- return 0
+ warn "failed to determine Windows version from string '$name', $FB" && return 0
fi
- desc=$(printVersion "$DETECTED")
- [ -z "$desc" ] && desc="$DETECTED"
+ desc=$(printVersion "$DETECTED" "$DETECTED")
if [ -f "/run/assets/$DETECTED.xml" ]; then
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
@@ -585,16 +612,14 @@ updateImage() {
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1)
if [ ! -d "$src" ]; then
- warn "failed to locate 'sources' folder in ISO image, $FB"
- return 1
+ warn "failed to locate 'sources' folder in ISO image, $FB" && return 1
fi
loc=$(find "$src" -maxdepth 1 -type f -iname boot.wim | head -n 1)
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1)
if [ ! -f "$loc" ]; then
- warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
- return 1
+ warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1
fi
info "Adding XML file for automatic installation..."
@@ -607,8 +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 XML to ISO image, $FB" && return 1
fi
return 0
@@ -626,8 +650,7 @@ buildImage() {
local out="$TMP/$label.tmp"
rm -f "$out"
- desc=$(printVersion "$DETECTED")
- [ -z "$desc" ] && desc="ISO"
+ desc=$(printVersion "$DETECTED" "ISO")
local msg="Building $desc image..."
info "$msg" && html "$msg"
@@ -638,14 +661,13 @@ buildImage() {
space_gb=$(( (space + 1073741823)/1073741824 ))
if (( size > space )); then
- error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB."
- return 1
+ 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
[ -s "$log" ] && echo "$(<"$log")"
- return 1
+ error "Failed to build image!" && return 1
fi
local error=""
@@ -655,8 +677,7 @@ buildImage() {
[[ "$error" != "$hide" ]] && echo "$error"
if [ -f "$STORAGE/$BASE" ]; then
- error "File $STORAGE/$BASE does already exist?!"
- return 1
+ error "File $STORAGE/$BASE does already exist?!" && return 1
fi
mv "$out" "$STORAGE/$BASE"
@@ -678,39 +699,35 @@ bootWindows() {
######################################
if ! startInstall; then
- if ! bootWindows; then
- error "Failed to boot Windows!"
- exit 68
- fi
- return 0
+ bootWindows && return 0
+ exit 68
fi
if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then
- rm -f "$ISO"
if ! downloadImage "$ISO" "$VERSION"; then
- error "Failed to download $VERSION"
+ rm -f "$ISO"
exit 61
fi
fi
if ! extractImage "$ISO" "$DIR"; then
- abortInstall "$ISO"
- return 0
+ rm -f "$ISO"
+ exit 62
fi
if ! detectImage "$DIR"; then
- abortInstall "$ISO"
- return 0
+ abortInstall "$ISO" && return 0
+ exit 60
fi
if ! prepareImage "$ISO" "$DIR"; then
- abortInstall "$ISO"
- return 0
+ abortInstall "$ISO" && return 0
+ exit 60
fi
if ! updateImage "$ISO" "$DIR" "$XML"; then
- abortInstall "$ISO"
- return 0
+ abortInstall "$ISO" && return 0
+ exit 60
fi
if ! rm -f "$ISO" 2> /dev/null; then
@@ -720,12 +737,10 @@ if ! rm -f "$ISO" 2> /dev/null; then
fi
if ! buildImage "$DIR"; then
- error "Failed to build image!"
exit 65
fi
if ! finishInstall "$STORAGE/$BASE" "N"; then
- error "Failed to finish installation!"
exit 69
fi