feat: Added option to prevent rebuild of the image (#1970)

This commit is contained in:
Kroese
2026-07-26 00:02:17 +02:00
committed by GitHub
parent 0a3bff5a7d
commit 4e35ead612
4 changed files with 82 additions and 56 deletions
-45
View File
@@ -1557,49 +1557,4 @@ legacyInstall() {
return 0
}
legacyPrepare() {
local iso="$1"
local dir="$2"
local desc="$3"
local tmp="$TMP/boot-images"
local image="$tmp/eltorito_img1_bios.img"
ETFS="boot.img"
[ -f "$dir/$ETFS" ] && [ -s "$dir/$ETFS" ] && return 0
rm -f "$dir/$ETFS" || return 1
rm -rf "$tmp" || return 1
LC_ALL=C xorriso \
-no_rc \
-osirrox on \
-indev "$iso" \
-extract_boot_images "$tmp" >/dev/null 2>&1 || {
local rc=$?
rm -rf "$tmp" || true
(( rc > 128 )) && exit "$rc"
error "Failed to extract boot image from $desc ISO!"
return 1
}
if [ ! -s "$image" ]; then
rm -rf "$tmp" || true
error "Failed to locate BIOS boot image in $desc ISO!"
return 1
fi
if ! mv -f "$image" "$dir/$ETFS"; then
rm -rf "$tmp" || true
error "Failed to save boot image from $desc ISO!"
return 1
fi
rm -rf "$tmp" || return 1
return 0
}
return 0
+1
View File
@@ -11,6 +11,7 @@ set -Eeuo pipefail
: "${EDITION:=""}"
: "${MANUAL:=""}"
: "${REMOVE:=""}"
: "${REBUILD:="N"}"
: "${VERSION:=""}"
: "${COMMAND:=""}"
: "${DETECTED:=""}"
+62
View File
@@ -951,3 +951,65 @@ EOF
return 0
}
extractBootImage() {
local iso="$1"
local dir="$2"
local desc="$3"
local tmp="$TMP/boot-images"
local image="$tmp/eltorito_img1_bios.img"
local max_size=$((32 * 1024 * 1024))
ETFS="boot.img"
[ -f "$dir/$ETFS" ] && [ -s "$dir/$ETFS" ] && return 0
rm -f "$dir/$ETFS" || return 1
rm -rf "$tmp" || return 1
LC_ALL=C xorriso \
-no_rc \
-osirrox on \
-indev "$iso" \
-extract_boot_images "$tmp" >/dev/null 2>&1 || {
local rc=$?
rm -rf "$tmp" || true
(( rc > 128 )) && exit "$rc"
error "Failed to extract boot image from $desc ISO!"
return 1
}
if [ ! -s "$image" ]; then
rm -rf "$tmp" || true
error "Failed to locate BIOS boot image in $desc ISO!"
return 1
fi
local size
if ! size=$(stat -c%s "$image"); then
rm -rf "$tmp" || true
error "Failed to determine BIOS boot image size in $desc ISO!"
return 1
fi
if (( size > max_size )); then
rm -rf "$tmp" || true
error "The BIOS boot image in $desc ISO exceeds 32 MB!"
return 1
fi
if ! mv -f "$image" "$dir/$ETFS"; then
rm -rf "$tmp" || true
error "Failed to save boot image from $desc ISO!"
return 1
fi
rm -rf "$tmp" || return 1
return 0
}
return 0
+15 -7
View File
@@ -769,10 +769,19 @@ prepareImage() {
desc=$(printVariant "$DETECTED" "$DETECTED")
# Adjust QEMU machine configuration for legacy versions
setMachine "$DETECTED" "$iso" "$dir" "$desc" || return 1
disabled "$REBUILD" && return 0
skipVersion "$DETECTED" && return 0
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
extractBootImage "$iso" "$dir" "$desc" && return 0
error "Failed to extract boot image from ISO image \"${iso}\"!"
return 1
fi
[ -f "$dir/$ETFS" ] && [ -s "$dir/$ETFS" ] &&
[ -f "$dir/$EFISYS" ] && [ -s "$dir/$EFISYS" ] && return 0
@@ -784,12 +793,6 @@ prepareImage() {
error "Failed to locate file \"${missing,,}\" in ISO image!"
return 1
fi
legacyPrepare "$iso" "$dir" "$desc" && return 0
error "Failed to extract boot image from ISO image!"
return 1
}
addFolder() {
@@ -962,6 +965,11 @@ updateImage() {
local dat="${xml//.xml/.dat}"
local desc path src wim name info
if disabled "$REBUILD"; then
info "Skipping modifications to the installation image..."
return 1
fi
skipVersion "${DETECTED,,}" && return 0
if [ ! -s "$asset" ] || [ ! -f "$asset" ]; then