mirror of
https://github.com/dockur/windows.git
synced 2026-08-04 04:57:13 +01:00
feat: Added option to prevent rebuild of the image (#1970)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user