mirror of
https://github.com/dockur/windows.git
synced 2026-08-24 15:48:59 +01:00
feat: Move image edition selection policy (#2118)
This commit is contained in:
+120
-32
@@ -638,6 +638,38 @@ fromName() {
|
|||||||
return 0
|
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() {
|
isClientEdition() {
|
||||||
|
|
||||||
case "${1,,}" in
|
case "${1,,}" in
|
||||||
@@ -651,6 +683,94 @@ isClientEdition() {
|
|||||||
return 1
|
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() {
|
normalizeEdition() {
|
||||||
|
|
||||||
local source="${1,,}"
|
local source="${1,,}"
|
||||||
@@ -819,38 +939,6 @@ getServerEditionID() {
|
|||||||
return 0
|
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() {
|
getRequiredMemory() {
|
||||||
|
|
||||||
local id="${1,,}"
|
local id="${1,,}"
|
||||||
|
|||||||
+8
-63
@@ -130,58 +130,13 @@ getVersions() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
selectVersion() {
|
selectVersion() {
|
||||||
|
|
||||||
local wanted="$1"
|
local wanted="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
local candidate record id index
|
|
||||||
local -a candidates=("$wanted")
|
local -a candidates=("$wanted")
|
||||||
|
local candidate record id index
|
||||||
|
|
||||||
# Normal and Evaluation variants of the same edition are compatible.
|
# Normal and Evaluation variants of the same edition are compatible.
|
||||||
if [[ "${wanted,,}" == *"-eval" ]]; then
|
if [[ "${wanted,,}" == *"-eval" ]]; then
|
||||||
@@ -211,9 +166,8 @@ detectVersion() {
|
|||||||
|
|
||||||
local xml="$1"
|
local xml="$1"
|
||||||
|
|
||||||
local normalize="normalizeEditionID"
|
local -a images=() bases=() order=() preferences=()
|
||||||
local output record id index base edition suffix
|
local normalize output policy record id index base edition suffix
|
||||||
local -a images=() bases=() order=()
|
|
||||||
|
|
||||||
output=$(getVersions "$xml") || return
|
output=$(getVersions "$xml") || return
|
||||||
[ -n "$output" ] && mapfile -t images <<< "$output"
|
[ -n "$output" ] && mapfile -t images <<< "$output"
|
||||||
@@ -228,20 +182,11 @@ detectVersion() {
|
|||||||
bases+=("${id%%-*}")
|
bases+=("${id%%-*}")
|
||||||
done
|
done
|
||||||
|
|
||||||
case "${bases[0],,}" in
|
policy=$(getEditionPolicy "${bases[0]}") || return 1
|
||||||
"win20"* )
|
mapfile -t preferences <<< "$policy"
|
||||||
normalize="normalizeServerEditionID"
|
|
||||||
order=(
|
normalize="${preferences[0]}"
|
||||||
"" "-datacenter" "-datacenter-azure" "-enterprise" "-web"
|
order=("${preferences[@]:1}")
|
||||||
"-foundation" "-essentials" "-standard-core" "-datacenter-core"
|
|
||||||
"-datacenter-azure-core" "-enterprise-core" "-web-core" "-hv"
|
|
||||||
) ;;
|
|
||||||
* )
|
|
||||||
order=(
|
|
||||||
"-enterprise" "-ultimate" "" "-iot" "-ltsc" "-education"
|
|
||||||
"-home" "-home-premium" "-home-basic" "-starter"
|
|
||||||
) ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# An explicit EDITION always gets first choice.
|
# An explicit EDITION always gets first choice.
|
||||||
if [ -n "$EDITION" ]; then
|
if [ -n "$EDITION" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user