mirror of
https://github.com/dockur/windows.git
synced 2026-08-03 12:37:20 +01:00
fix: Select first matching Windows image index (#1942)
This commit is contained in:
+2
-20
@@ -235,16 +235,12 @@ getImageIndex() {
|
|||||||
local wanted="$2"
|
local wanted="$2"
|
||||||
local platform tag index name id
|
local platform tag index name id
|
||||||
|
|
||||||
local -a matches=()
|
|
||||||
|
|
||||||
[ -z "$wanted" ] && return 1
|
[ -z "$wanted" ] && return 1
|
||||||
|
|
||||||
platform=$(getPlatform "$xml")
|
platform=$(getPlatform "$xml")
|
||||||
|
|
||||||
for tag in DISPLAYNAME PRODUCTNAME NAME; do
|
for tag in DISPLAYNAME PRODUCTNAME NAME; do
|
||||||
|
|
||||||
matches=()
|
|
||||||
|
|
||||||
while IFS=$'\t' read -r index name; do
|
while IFS=$'\t' read -r index name; do
|
||||||
[ -n "$index" ] || continue
|
[ -n "$index" ] || continue
|
||||||
[[ "$name" == *"Operating System"* ]] && continue
|
[[ "$name" == *"Operating System"* ]] && continue
|
||||||
@@ -253,7 +249,8 @@ getImageIndex() {
|
|||||||
id=$(getVersion "$name" "$platform")
|
id=$(getVersion "$name" "$platform")
|
||||||
[[ "${id,,}" == "${wanted,,}" ]] || continue
|
[[ "${id,,}" == "${wanted,,}" ]] || continue
|
||||||
|
|
||||||
matches+=("$index")
|
echo "$index"
|
||||||
|
return 0
|
||||||
done < <(
|
done < <(
|
||||||
awk -v tag="$tag" '
|
awk -v tag="$tag" '
|
||||||
/<IMAGE INDEX="/ {
|
/<IMAGE INDEX="/ {
|
||||||
@@ -275,21 +272,6 @@ getImageIndex() {
|
|||||||
' <<< "$xml"
|
' <<< "$xml"
|
||||||
)
|
)
|
||||||
|
|
||||||
case "${#matches[@]}" in
|
|
||||||
0 )
|
|
||||||
continue
|
|
||||||
;;
|
|
||||||
1 )
|
|
||||||
echo "${matches[0]}"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
# Several WIM entries collapse to the same internal version ID,
|
|
||||||
# so selecting one of their indexes would be arbitrary.
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user