mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 19:35:49 +00:00
feat: Pretty print image name
This commit is contained in:
parent
d02fa6cca1
commit
08219f7e0a
1 changed files with 37 additions and 9 deletions
|
|
@ -311,14 +311,14 @@ extractImage() {
|
|||
return 0
|
||||
}
|
||||
|
||||
findVersion() {
|
||||
getVersion() {
|
||||
|
||||
local name="$1"
|
||||
local detected=""
|
||||
|
||||
[[ "${name,,}" == *"windows 11"* ]] && detected="win11x64"
|
||||
[[ "${name,,}" == *"windows 8"* ]] && detected="win81x64"
|
||||
[[ "${name,,}" == *"windows 7"* ]] && detected="win7x64"
|
||||
[[ "${name,,}" == *"windows 8"* ]] && detected="win81x64"
|
||||
[[ "${name,,}" == *"windows 11"* ]] && detected="win11x64"
|
||||
[[ "${name,,}" == *"windows vista"* ]] && detected="winvistax64"
|
||||
[[ "${name,,}" == *"server 2022"* ]] && detected="win2022-eval"
|
||||
[[ "${name,,}" == *"server 2019"* ]] && detected="win2019-eval"
|
||||
|
|
@ -336,6 +336,25 @@ findVersion() {
|
|||
return 0
|
||||
}
|
||||
|
||||
printVersion() {
|
||||
|
||||
local id="$1"
|
||||
local desc=""
|
||||
|
||||
[[ "$id" == "win7"* ]] && desc="Windows 7"
|
||||
[[ "$id" == "win8"* ]] && desc="Windows 8"
|
||||
[[ "$id" == "win10"* ]] && desc="Windows 10"
|
||||
[[ "$id" == "win11"* ]] && desc="Windows 11"
|
||||
[[ "$id" == "winvista"* ]] && desc="Windows Vista"
|
||||
[[ "$id" == "win2022"* ]] && desc="Windows Server 2022"
|
||||
[[ "$id" == "win2019"* ]] && desc="Windows Server 2019"
|
||||
[[ "$id" == "win2016"* ]] && desc="Windows Server 2016"
|
||||
[[ "$id" == "win10x64-ltsc" ]] && desc="Windows 10 LTSC"
|
||||
|
||||
echo "$desc"
|
||||
return 0
|
||||
}
|
||||
|
||||
detectImage() {
|
||||
|
||||
XML=""
|
||||
|
|
@ -349,18 +368,24 @@ detectImage() {
|
|||
fi
|
||||
|
||||
if [ -n "$DETECTED" ]; then
|
||||
|
||||
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||
return 0
|
||||
fi
|
||||
warn "image type is '$DETECTED', but no matching XML file exists!"
|
||||
|
||||
local dsc
|
||||
dsc=$(printVersion "$DETECTED")
|
||||
[ -z "$dsc" ] && dsc="$DETECTED"
|
||||
|
||||
warn "image type is '$dsc', but no matching XML file exists!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
info "Detecting Windows version from ISO image..."
|
||||
|
||||
local dir="$1"
|
||||
local tag result name name2
|
||||
local tag result name name2 desc
|
||||
local loc="$dir/sources/install.wim"
|
||||
[ ! -f "$loc" ] && loc="$dir/sources/install.esd"
|
||||
|
||||
|
|
@ -373,24 +398,27 @@ detectImage() {
|
|||
tag="DISPLAYNAME"
|
||||
result=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
|
||||
name=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result")
|
||||
DETECTED=$(findVersion "$name")
|
||||
DETECTED=$(getVersion "$name")
|
||||
|
||||
if [ -z "$DETECTED" ]; then
|
||||
|
||||
tag="PRODUCTNAME"
|
||||
name2=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result")
|
||||
[ -z "$name" ] && name="$name2"
|
||||
DETECTED=$(findVersion "$name2")
|
||||
DETECTED=$(getVersion "$name2")
|
||||
|
||||
fi
|
||||
|
||||
if [ -n "$DETECTED" ]; then
|
||||
|
||||
desc=$(printVersion "$DETECTED")
|
||||
[ -z "$desc" ] && desc="$DETECTED"
|
||||
|
||||
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||
info "Detected image of type: '$DETECTED'"
|
||||
info "Detected image of type: '$desc'"
|
||||
else
|
||||
warn "detected image of type '$DETECTED', but no matching XML file exists, $FB."
|
||||
warn "detected image of type '$desc', but no matching XML file exists, $FB."
|
||||
fi
|
||||
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue