feat: Move image edition selection policy (#2118)

This commit is contained in:
Kroese
2026-08-08 17:39:43 +02:00
committed by GitHub
parent 43be9024e9
commit 133c3d3bc3
2 changed files with 128 additions and 95 deletions
+120 -32
View File
@@ -638,6 +638,38 @@ fromName() {
return 0
}
getVersion() {
local name="$1"
local arch="$2"
local id edition
local evaluation=""
id=$(fromName "$name" "$arch")
[[ "${name,,}" == *"evaluation"* ]] && evaluation="-eval"
case "${id,,}" in
"winvista"* | "win7"* | "win8"* | "win10"* | "win11"* )
if edition=$(getEditionID "$name" "$id"); then
[ -n "$edition" ] && id+="-$edition"
[ -n "$evaluation" ] && id+="$evaluation"
fi
;;
"win20"* )
if [[ "${name,,}" == *"hyper-v server"* ]]; then
id+="-hv"
elif edition=$(getServerEditionID "$name" "$id"); then
[ -n "$edition" ] && id+="-$edition"
[ -n "$evaluation" ] && id+="$evaluation"
fi
;;
esac
echo "$id"
return 0
}
isClientEdition() {
case "${1,,}" in
@@ -651,6 +683,94 @@ isClientEdition() {
return 1
}
getEditionRank() {
local id="${1,,}"
local base="${id%%-*}"
local edition
id="${id%-eval}"
edition="${id#"$base"}"
edition="${edition#-}"
case "$base" in
"win20"* )
case "$edition" in
"" ) echo 0 ;;
"datacenter-azure-core" | "datacenter-azure-core-"* | \
"datacenter-core" | "datacenter-core-"* ) echo 7 ;;
"enterprise-core" | "enterprise-core-"* ) echo 8 ;;
"web-core" | "web-core-"* ) echo 9 ;;
"standard-core" | "standard-core-"* ) echo 6 ;;
"datacenter" | "datacenter-"* ) echo 1 ;;
"enterprise" | "enterprise-"* ) echo 2 ;;
"web" | "web-"* ) echo 3 ;;
"foundation" | "foundation-"* ) echo 4 ;;
"essentials" | "essentials-"* ) echo 5 ;;
"hv" | "hv-"* ) echo 10 ;;
* ) echo 99 ;;
esac
;;
* )
case "$edition" in
"enterprise-iot" | "enterprise-iot-"* | "iot" | "iot-"* ) echo 3 ;;
"enterprise-ltsc" | "enterprise-ltsc-"* | "ltsc" | "ltsc-"* ) echo 4 ;;
"pro-education" | "pro-education-"* | "education" | "education-"* ) echo 5 ;;
"enterprise" | "enterprise-"* ) echo 0 ;;
"ultimate" | "ultimate-"* ) echo 1 ;;
"" | "n" | "pro" | "pro-"* | "professional" | "professional-"* | \
"business" | "business-"* ) echo 2 ;;
"home" | "home-"* ) echo 6 ;;
"starter" | "starter-"* ) echo 7 ;;
* ) echo 99 ;;
esac
;;
esac
return 0
}
getEditionPolicy() {
local base="${1,,}"
case "$base" in
"win20"* )
printf '%s\n' \
"normalizeServerEditionID" \
"" \
"-datacenter" \
"-datacenter-azure" \
"-enterprise" \
"-web" \
"-foundation" \
"-essentials" \
"-standard-core" \
"-datacenter-core" \
"-datacenter-azure-core" \
"-enterprise-core" \
"-web-core" \
"-hv"
;;
* )
printf '%s\n' \
"normalizeEditionID" \
"-enterprise" \
"-ultimate" \
"" \
"-iot" \
"-ltsc" \
"-education" \
"-home" \
"-home-premium" \
"-home-basic" \
"-starter"
;;
esac
return 0
}
normalizeEdition() {
local source="${1,,}"
@@ -819,38 +939,6 @@ getServerEditionID() {
return 0
}
getVersion() {
local name="$1"
local arch="$2"
local id edition
local evaluation=""
id=$(fromName "$name" "$arch")
[[ "${name,,}" == *"evaluation"* ]] && evaluation="-eval"
case "${id,,}" in
"winvista"* | "win7"* | "win8"* | "win10"* | "win11"* )
if edition=$(getEditionID "$name" "$id"); then
[ -n "$edition" ] && id+="-$edition"
[ -n "$evaluation" ] && id+="$evaluation"
fi
;;
"win20"* )
if [[ "${name,,}" == *"hyper-v server"* ]]; then
id+="-hv"
elif edition=$(getServerEditionID "$name" "$id"); then
[ -n "$edition" ] && id+="-$edition"
[ -n "$evaluation" ] && id+="$evaluation"
fi
;;
esac
echo "$id"
return 0
}
getRequiredMemory() {
local id="${1,,}"