From 7289cd540cf02e26750cd0784795266c99e44edc Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 3 Aug 2026 03:21:45 +0200 Subject: [PATCH] Update image.sh --- src/image.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/image.sh b/src/image.sh index 3f9a15c4..6548d8a7 100644 --- a/src/image.sh +++ b/src/image.sh @@ -918,6 +918,58 @@ findIsoImage() { return 1 } +readWimHeader() { + + local iso="$1" + local image="$2" + local result_name="$3" + + local header="$TMP/wim-header.bin" + local size signature + + printf -v "$result_name" '%s' "" + + if ! rm -f -- "$header"; then + return 1 + fi + + if ! udfread range \ + --ignore-case \ + -o "$header" \ + "$iso" \ + "$image" \ + 0 \ + 208 \ + >/dev/null 2>&1; then + + rm -f -- "$header" + return 1 + fi + + if ! size=$(stat -c%s -- "$header"); then + rm -f -- "$header" + return 1 + fi + + if (( size != 208 )); then + rm -f -- "$header" + return 1 + fi + + if ! signature=$(od -An -N8 -tx1 "$header" | tr -d ' \n'); then + rm -f -- "$header" + return 1 + fi + + if [[ "$signature" != "4d5357494d000000" ]]; then + rm -f -- "$header" + return 1 + fi + + printf -v "$result_name" '%s' "$header" + return 0 +} + findImage() { local dir="$1"