feat: Detect platform from ISO
This commit is contained in:
parent
f8886c780c
commit
64b33586d0
1 changed files with 15 additions and 7 deletions
|
|
@ -625,13 +625,13 @@ selectVersion() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
detectVersion() {
|
checkPlatform() {
|
||||||
|
|
||||||
local xml="$1"
|
local xml="$1"
|
||||||
local id arch
|
|
||||||
local tag="ARCH"
|
local tag="ARCH"
|
||||||
local platform="x64"
|
local platform="x64"
|
||||||
local compat="$platform"
|
local compat="$platform"
|
||||||
|
local arch
|
||||||
|
|
||||||
arch=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$xml")
|
arch=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$xml")
|
||||||
|
|
||||||
|
|
@ -641,16 +641,22 @@ detectVersion() {
|
||||||
"12" )platform="arm64"; compat="$platform" ;;
|
"12" )platform="arm64"; compat="$platform" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "${compat,,}" != "${PLATFORM,,}" ]]; then
|
[[ "${compat,,}" == "${PLATFORM,,}" ]] && return 0
|
||||||
|
|
||||||
error "You cannot boot ${platform^^} images on a $PLATFORM cpu!"
|
error "You cannot boot ${platform^^} images on a $PLATFORM cpu!"
|
||||||
exit 67
|
return 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
detectVersion() {
|
||||||
|
|
||||||
|
local xml="$1"
|
||||||
|
local id
|
||||||
|
|
||||||
id=$(selectVersion "DISPLAYNAME" "$xml" "$platform")
|
id=$(selectVersion "DISPLAYNAME" "$xml" "$platform")
|
||||||
[ -z "$id" ] && id=$(selectVersion "PRODUCTNAME" "$xml" "$platform")
|
[ -z "$id" ] && id=$(selectVersion "PRODUCTNAME" "$xml" "$platform")
|
||||||
[ -z "$id" ] && id=$(selectVersion "NAME" "$xml" "$platform")
|
[ -z "$id" ] && id=$(selectVersion "NAME" "$xml" "$platform")
|
||||||
[ -n "$id" ] && [[ "${id,,}" != *"unknown"* ]] && echo "$id" && return 0
|
|
||||||
|
|
||||||
|
echo "$id"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -703,6 +709,8 @@ detectImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
|
info=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
|
||||||
|
! checkPlatform "$info" && exit 67
|
||||||
|
|
||||||
DETECTED=$(detectVersion "$info")
|
DETECTED=$(detectVersion "$info")
|
||||||
|
|
||||||
if [ -z "$DETECTED" ]; then
|
if [ -z "$DETECTED" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue