Compare commits

..

4 commits

Author SHA1 Message Date
renovate[bot]
ef850e9837
chore(deps): update qemux/qemu docker tag to v7.13 (#1400)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-17 19:20:08 +02:00
Kroese
0903fad26b
feat: Backup disk image (#1399) 2025-09-17 17:24:41 +02:00
Sultaniiazov David
d08b7aeb27
fix: Typo (#1397) 2025-09-17 16:18:53 +02:00
Kroese
2239792fa9
feat: Allow for easier switching between versions (#1398)
When the VERSION variable is changed, it will now automaticly clean the /storage folder instead of warning the user to manually do it.
2025-09-17 16:17:42 +02:00
4 changed files with 56 additions and 37 deletions

View file

@ -3,7 +3,7 @@
ARG VERSION_ARG="latest" ARG VERSION_ARG="latest"
FROM scratch AS build-amd64 FROM scratch AS build-amd64
COPY --from=qemux/qemu:7.12 / / COPY --from=qemux/qemu:7.13 / /
ARG TARGETARCH ARG TARGETARCH
ARG DEBCONF_NOWARNINGS="yes" ARG DEBCONF_NOWARNINGS="yes"

View file

@ -23,7 +23,7 @@ parseVersion() {
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
VERSION="${VERSION:1:-1}" VERSION="${VERSION:1:-1}"
fi fi
VERSION=$(expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$") VERSION=$(expr "$VERSION" : "^\ *\(.*[^ ]\)\ *$")
[ -z "$VERSION" ] && VERSION="win11" [ -z "$VERSION" ] && VERSION="win11"

View file

@ -1,10 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -Eeuo pipefail set -Eeuo pipefail
TMP="$STORAGE/tmp"
DIR="$TMP/unpack"
FB="falling back to manual installation!"
ETFS="boot/etfsboot.com" ETFS="boot/etfsboot.com"
FB="falling back to manual installation!"
EFISYS="efi/microsoft/boot/efisys_noprompt.bin" EFISYS="efi/microsoft/boot/efisys_noprompt.bin"
skipInstall() { skipInstall() {
@ -16,28 +14,52 @@ skipInstall() {
local previous="$STORAGE/windows.base" local previous="$STORAGE/windows.base"
if [ -f "$previous" ]; then if [ -f "$previous" ]; then
previous=$(<"$previous") previous=$(<"$previous")
previous="${previous//[![:print:]]/}" previous="${previous//[![:print:]]/}"
if [ -n "$previous" ]; then if [ -n "$previous" ]; then
if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then
if [ -f "$boot" ] && hasDisk; then
if [[ "${iso,,}" == "${STORAGE,,}/windows."* ]]; then if ! hasDisk; then
method="your custom .iso file"
else rm -f "$STORAGE/$previous"
if [[ "${previous,,}" != "windows."* ]]; then return 1
method="the VERSION variable"
fi
fi
if [ -n "$method" ]; then
info "Detected that $method was changed, but ignoring this because Windows is already installed."
info "Please start with an empty /storage folder, if you want to install a different version of Windows."
fi
return 0
fi fi
rm -f "$STORAGE/$previous"
if [[ "${iso,,}" == "${STORAGE,,}/windows."* ]]; then
method="your custom .iso file was changed"
else
if [[ "${previous,,}" != "windows."* ]]; then
method="the VERSION variable was changed"
else
method="your custom .iso file was removed"
if [ -f "$boot" ]; then
info "Detected that $method, will be ignored."
return 0
fi
fi
fi
info "Detected that $method, a backup of your previous installation will be saved..."
local dir="$STORAGE/${previous%.*}.old"
rm -rf "$dir"
mkdir -p "$dir"
[ -f "$STORAGE/$previous" ] && mv -f "$STORAGE/$previous" "$dir/"
find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -exec mv -n {} "$dir/" \;
find "$STORAGE" -maxdepth 1 -type f \( -iname 'data.*' -or -iname 'windows.*' \) -exec mv -n {} "$dir/" \;
return 1 return 1
fi fi
fi fi
fi fi
[ -f "$boot" ] && hasDisk && return 0 [ -f "$boot" ] && hasDisk && return 0
@ -51,8 +73,10 @@ skipInstall() {
byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17"
if [[ "$magic" != "$byte" ]]; then if [[ "$magic" != "$byte" ]]; then
info "The ISO will be processed again because the configuration was changed..." info "The ISO will be processed again because the configuration was changed..."
return 1 return 1
fi fi
return 0 return 0
@ -88,9 +112,11 @@ startInstall() {
fi fi
TMP="$STORAGE/tmp"
rm -rf "$TMP"
skipInstall "$BOOT" && return 1 skipInstall "$BOOT" && return 1
rm -rf "$TMP"
mkdir -p "$TMP" mkdir -p "$TMP"
if [ -z "$CUSTOM" ]; then if [ -z "$CUSTOM" ]; then
@ -105,6 +131,11 @@ startInstall() {
fi fi
rm -f "$BOOT" rm -f "$BOOT"
find "$STORAGE" -maxdepth 1 -type f -iname 'data.*' -delete
find "$STORAGE" -maxdepth 1 -type f -iname 'windows.*' -not -iname '*.iso' -delete
find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -delete
return 0 return 0
} }
@ -126,16 +157,6 @@ finishInstall() {
fi fi
fi fi
rm -f "$STORAGE/windows.old"
rm -f "$STORAGE/windows.vga"
rm -f "$STORAGE/windows.net"
rm -f "$STORAGE/windows.usb"
rm -f "$STORAGE/windows.args"
rm -f "$STORAGE/windows.base"
rm -f "$STORAGE/windows.boot"
rm -f "$STORAGE/windows.mode"
rm -f "$STORAGE/windows.type"
cp -f /run/version "$STORAGE/windows.ver" cp -f /run/version "$STORAGE/windows.ver"
if [[ "$iso" == "$STORAGE/"* ]]; then if [[ "$iso" == "$STORAGE/"* ]]; then
@ -612,8 +633,7 @@ detectImage() {
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 fi
wim=$(find "$src" -maxdepth 1 -type f -iname install.wim -print -quit) wim=$(find "$src" -maxdepth 1 -type f \( -iname install.wim -or -iname install.esd \) -print -quit)
[ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname install.esd -print -quit)
if [ ! -f "$wim" ]; then if [ ! -f "$wim" ]; then
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1 warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1
@ -913,8 +933,7 @@ updateImage() {
error "failed to locate 'sources' folder in ISO image, $FB" && return 1 error "failed to locate 'sources' folder in ISO image, $FB" && return 1
fi fi
wim=$(find "$src" -maxdepth 1 -type f -iname boot.wim -print -quit) wim=$(find "$src" -maxdepth 1 -type f \( -iname boot.wim -or -iname boot.esd \) -print -quit)
[ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname boot.esd -print -quit)
if [ ! -f "$wim" ]; then if [ ! -f "$wim" ]; then
error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1 error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1
@ -1076,8 +1095,6 @@ buildImage() {
bootWindows() { bootWindows() {
rm -rf "$TMP"
if [ -f "$STORAGE/windows.args" ]; then if [ -f "$STORAGE/windows.args" ]; then
ARGS=$(<"$STORAGE/windows.args") ARGS=$(<"$STORAGE/windows.args")
ARGS="${ARGS//[![:print:]]/}" ARGS="${ARGS//[![:print:]]/}"
@ -1145,6 +1162,8 @@ if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then
fi fi
fi fi
DIR="$TMP/unpack"
if ! extractImage "$ISO" "$DIR" "$VERSION"; then if ! extractImage "$ISO" "$DIR" "$VERSION"; then
rm -f "$ISO" 2> /dev/null || true rm -f "$ISO" 2> /dev/null || true
exit 62 exit 62

View file

@ -689,7 +689,7 @@ downloadImage() {
if isESD "$version" "$lang"; then if isESD "$version" "$lang"; then
if [[ "$tried" != "n" ]]; then if [[ "$tried" != "n" ]]; then
info "Failed to download $desc, will try a diferent method now..." info "Failed to download $desc, will try a different method now..."
fi fi
tried="y" tried="y"