From 033a06a3dfe810ef0246425fab994eb822934cb8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 29 Jul 2026 19:29:55 +0200 Subject: [PATCH] feat: Encapsulate edition ordering policy (#2023) --- src/define.sh | 74 +++++++++++++++++++++++++++++++-------------------- src/image.sh | 7 ++--- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/define.sh b/src/define.sh index 64f5c280..e431a654 100644 --- a/src/define.sh +++ b/src/define.sh @@ -38,35 +38,6 @@ USERNAME=$(strip "$USERNAME") DOMAIN_OU=$(strip "$DOMAIN_OU") WORKGROUP=$(strip "$WORKGROUP") -EDITION_ORDER=( - "-enterprise|enterprise|enterprise enterprise-*" - "-ultimate|ultimate|ultimate ultimate-*" - "|default|@default n pro pro-* professional professional-* business business-*" - "-iot|iot|iot iot-* enterprise-iot enterprise-iot-*" - "-ltsc|ltsc|ltsc ltsc-* enterprise-ltsc enterprise-ltsc-*" - "-education|education|education education-* pro-education pro-education-*" - "-home|home|home home-*" - "-home-premium|home|home-premium home-premium-*" - "-home-basic|home|home-basic home-basic-*" - "-starter|starter|starter starter-*" -) - -SERVER_EDITION_ORDER=( - "|default|@default" - "-datacenter|datacenter|datacenter datacenter-*" - "-datacenter-azure|datacenter|datacenter-azure" - "-enterprise|enterprise|enterprise enterprise-*" - "-web|web|web web-*" - "-foundation|foundation|foundation foundation-*" - "-essentials|essentials|essentials essentials-*" - "-standard-core|standard-core|standard-core standard-core-*" - "-datacenter-core|datacenter-core|datacenter-core datacenter-core-*" - "-datacenter-azure-core|datacenter-core|datacenter-azure-core" - "-enterprise-core|enterprise-core|enterprise-core enterprise-core-*" - "-web-core|web-core|web-core web-core-*" - "-hv|hv|hv hv-*" -) - MIRRORS=4 parseVersion() { @@ -928,6 +899,51 @@ getServerEditionID() { return 0 } +getEditionOrder() { + + local id="${1,,}" + local result_name="$2" + local -n result="$result_name" + + result=() + + case "$id" in + "win20"* ) + result=( + "|default|@default" + "-datacenter|datacenter|datacenter datacenter-*" + "-datacenter-azure|datacenter|datacenter-azure" + "-enterprise|enterprise|enterprise enterprise-*" + "-web|web|web web-*" + "-foundation|foundation|foundation foundation-*" + "-essentials|essentials|essentials essentials-*" + "-standard-core|standard-core|standard-core standard-core-*" + "-datacenter-core|datacenter-core|datacenter-core datacenter-core-*" + "-datacenter-azure-core|datacenter-core|datacenter-azure-core" + "-enterprise-core|enterprise-core|enterprise-core enterprise-core-*" + "-web-core|web-core|web-core web-core-*" + "-hv|hv|hv hv-*" + ) + ;; + * ) + result=( + "-enterprise|enterprise|enterprise enterprise-*" + "-ultimate|ultimate|ultimate ultimate-*" + "|default|@default n pro pro-* professional professional-* business business-*" + "-iot|iot|iot iot-* enterprise-iot enterprise-iot-*" + "-ltsc|ltsc|ltsc ltsc-* enterprise-ltsc enterprise-ltsc-*" + "-education|education|education education-* pro-education pro-education-*" + "-home|home|home home-*" + "-home-premium|home|home-premium home-premium-*" + "-home-basic|home|home-basic home-basic-*" + "-starter|starter|starter starter-*" + ) + ;; + esac + + return 0 +} + getVersion() { local id edition diff --git a/src/image.sh b/src/image.sh index a088bdf6..b10a127b 100644 --- a/src/image.sh +++ b/src/image.sh @@ -428,12 +428,12 @@ detectVersion() { local result_name="$3" local index_name="$4" - local order_name="EDITION_ORDER" local normalize_name="normalizeEditionID" local -a bases=() local -a groups=() local -a versions=() + local -a edition_order=() local -A image_indexes=() printf -v "$result_name" '%s' "" @@ -450,11 +450,12 @@ detectVersion() { case "${bases[0],,}" in "win20"* ) - order_name="SERVER_EDITION_ORDER" normalize_name="normalizeServerEditionID" ;; esac + getEditionOrder "${bases[0]}" edition_order || return 1 + selectEdition \ versions \ bases \ @@ -464,7 +465,7 @@ detectVersion() { "$result_name" \ "$index_name" \ "$normalize_name" \ - "$order_name" && return 0 + edition_order && return 0 local result="${versions[0]}" local key="${result,,}"