Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Verify boot image exists #137

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/define.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ parseVersion() {
"ltsc11" | "11ltsc" | "win11-ltsc" | "win11arm64-ltsc" | "win11arm64-enterprise-ltsc-eval" )
VERSION="win11arm64-enterprise-ltsc-eval"
[ -z "$DETECTED" ] && DETECTED="win11arm64-ltsc"
;;
;;
"10" | "10p" | "win10" | "win10p" | "windows10" | "windows 10" )
VERSION="win10arm64"
;;
Expand Down Expand Up @@ -537,7 +537,7 @@ getLink1() {
[[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0
size=4430471168
sum="d265df49b30a1477d010c79185a7bc88591a1be4b3eb690c994bed828ea17c00"
url="en-us_windows_10_iot_enterprise_ltsc_2021_arm64_dvd_e8d4fc46.iso"
url="en-us_windows_10_iot_enterprise_ltsc_2021_arm64_dvd_e8d4fc46.iso"
;;
esac

Expand Down Expand Up @@ -575,12 +575,12 @@ getLink2() {
size=4821989376
sum="e8f1431c4e6289b3997c20eadbb2576670300bb6e1cf8948b5d7af179010a962"
url="11/26100.1.240331-1435.ge_release_CLIENT_ENTERPRISES_OEM_A64FRE_en-us.iso"
;;
;;
"win10arm64" | "win10arm64-enterprise" | "win10arm64-enterprise-eval" )
size=4846794752
sum="6d2688f95fa1d359d68ed0c38c3f38de7b3713c893410e15be9d1e706a4a58c7"
url="10/en-us_windows_10_22h2_arm64.iso"
;;
;;
"win10arm64-ltsc" | "win10arm64-enterprise-ltsc-eval" )
size=4430471168
sum="d265df49b30a1477d010c79185a7bc88591a1be4b3eb690c994bed828ea17c00"
Expand Down Expand Up @@ -687,8 +687,16 @@ migrateFiles() {
return 0
}

skipVersion() {
return 1
}

detectLegacy() {
return 1
}

prepareLegacy() {
return 1
}

return 0
54 changes: 26 additions & 28 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,6 @@ setXML() {
return 0
}

skipVersion() {

local version="$1"

case "${version,,}" in
"win2k"* | "winxp"* | "win9"* )
return 0
;;
esac

return 1
}

detectImage() {

local dir="$1"
Expand Down Expand Up @@ -588,36 +575,42 @@ prepareImage() {

local iso="$1"
local dir="$2"
local missing
local desc missing

desc=$(printVersion "$DETECTED" "$DETECTED")

case "${DETECTED,,}" in
"win9"* | "win2k"* )
MACHINE="pc-i440fx-2.4" ;;
"winxp"* | "winvistax86"* | "win7x86"* )
"winvistax86"* | "win7x86"* | "winxp"* | "win2003"* )
MACHINE="pc-q35-2.10" ;;
esac

case "${DETECTED,,}" in
"win9"* | "winxp"* | "win2k"* )
"win9"* | "win2k"* | "winxp"* | "win2003"* )
HV="N"
BOOT_MODE="windows_legacy" ;;
"winvista"* | "win7"* | "win2008"* )
BOOT_MODE="windows_legacy" ;;
esac

case "${DETECTED,,}" in
"winxp"* )
DISK_TYPE="blk"
prepareXP "$iso" "$dir" && return 0
error "Failed to prepare Windows XP ISO!" && return 1 ;;
"win9"* )
DISK_TYPE="auto"
prepare9x "$iso" "$dir" && return 0
error "Failed to prepare Windows 9x ISO!" && return 1 ;;
prepare9x "$iso" "$dir" "$desc" && return 0
error "Failed to prepare $desc ISO!" && return 1 ;;
"win2k"* )
DISK_TYPE="auto"
prepare2k "$iso" "$dir" && return 0
error "Failed to prepare Windows 2000 ISO!" && return 1 ;;
prepare2k "$iso" "$dir" "$desc" && return 0
error "Failed to prepare $desc ISO!" && return 1 ;;
"winxp"* )
DISK_TYPE="blk"
prepareXP "$iso" "$dir" "$desc" && return 0
error "Failed to prepare $desc ISO!" && return 1 ;;
"win2003"* )
DISK_TYPE="blk"
prepare2k3 "$iso" "$dir" "$desc" && return 0
error "Failed to prepare $desc ISO!" && return 1 ;;
esac

if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
Expand All @@ -627,13 +620,13 @@ prepareImage() {
missing=$(basename "$dir/$EFISYS")
[ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS")

error "failed to locate file '${missing,,}' in ISO image!"
error "Failed to locate file \"${missing,,}\" in $desc ISO image!"
return 1
fi

prepareLegacy "$iso" "$dir" && return 0
prepareLegacy "$iso" "$dir" "$desc" && return 0

error "Failed to extract boot image from ISO!"
error "Failed to extract boot image from $desc ISO image!"
return 1
}

Expand Down Expand Up @@ -702,6 +695,7 @@ addDriver() {
"win81x64"* ) folder="w10/amd64" ;;
"win10x64"* ) folder="w10/amd64" ;;
"win11x64"* ) folder="w11/amd64" ;;
"win2025"* ) folder="2k22/amd64" ;;
"win2022"* ) folder="2k22/amd64" ;;
"win2019"* ) folder="2k19/amd64" ;;
"win2016"* ) folder="2k16/amd64" ;;
Expand Down Expand Up @@ -933,6 +927,10 @@ buildImage() {
error "File $BOOT does already exist?!" && return 1
fi

if [ ! -f "$dir/$ETFS" ]; then
error "Failed to locate file \"$ETFS\" in ISO image!" && return 1
fi

base=$(basename "$BOOT")
local out="$TMP/${base%.*}.tmp"
rm -f "$out"
Expand Down Expand Up @@ -961,7 +959,7 @@ buildImage() {
else

case "${DETECTED,,}" in
"win2k"* | "winxp"* )
"win2k"* | "winxp"* | "win2003"* )
! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -c "$cat" -iso-level 2 -J -l -D -N -joliet-long \
-relaxed-filenames -V "${LABEL::30}" -quiet "$dir" 2> "$log" && failed="y" ;;
"win9"* )
Expand Down