@@ -60,29 +60,38 @@ RUN set -eux; \
6060 | sed -E 's/\( .*\) //; s/^[[:space:]]+|[[:space:]]+$//g' \
6161 | grep -E '.' \
6262 | grep -Ev '^(wine|winehq)[[:alnum:]-]*$' ; } >> /tmp/wine-reqs.i386 || :; \
63- # Pick first available alternative
64- pick_first_available () { \
65- line="$1" ; \
63+ # Pick first available and non-conflicting alternative
64+ resolve_alt () { \
65+ line="$1" ; mode= "$2" ; \
6666 printf '%s' "$line" \
6767 | awk 'BEGIN{RS="\\ |"}{gsub(/^[[:space:]]+|[[:space:]]+$/,""); if(length) print}' \
6868 | while IFS= read -r cand; do \
69- candver="$(apt-cache policy " $cand" 2>/dev/null | awk " /Candidate:/ {print \$ 2}")" ; \
70- if [ -n "$candver" ] && [ "$candver" != "(none)" ] && [ "$candver" != "none" ]; then \
71- printf '%s\n ' "$cand" ; exit 0; \
69+ # For i386-mode, prefer armhf if candidate exists AND MA:same; else try native. For amd64-mode, native only. \
70+ if [ "$mode" = "i386" ]; then \
71+ arm_cand="$(apt-cache policy " ${cand}:armhf" 2>/dev/null | awk " /Candidate:/ {print \$ 2}")" ; \
72+ if [ -n "$arm_cand" ] && [ "$arm_cand" != "(none)" ] && [ "$arm_cand" != "none" ]; then \
73+ ma="$(apt-cache show " ${cand}:armhf" 2>/dev/null | awk -F': ' " /^Multi-Arch:/{print \$ 2; exit}")" ; \
74+ if [ "$ma" = "same" ]; then printf '%s:armhf\n ' "$cand" ; exit 0; fi; \
75+ fi; \
76+ nat_cand="$(apt-cache policy " $cand" 2>/dev/null | awk " /Candidate:/ {print \$ 2}")" ; \
77+ if [ -n "$nat_cand" ] && [ "$nat_cand" != "(none)" ] && [ "$nat_cand" != "none" ]; then printf '%s\n ' "$cand" ; exit 0; fi; \
78+ else \
79+ nat_cand="$(apt-cache policy " $cand" 2>/dev/null | awk " /Candidate:/ {print \$ 2}")" ; \
80+ if [ -n "$nat_cand" ] && [ "$nat_cand" != "(none)" ] && [ "$nat_cand" != "none" ]; then printf '%s\n ' "$cand" ; exit 0; fi; \
7281 fi; \
73- done; \
82+ done; \
7483 return 1; \
7584 }; \
7685 # Resolve separate lists
7786 : >/tmp/wine-deps.amd64; \
7887 while IFS= read -r line; do \
79- sel="$(pick_first_available " $line")" || true; \
88+ sel="$(resolve_alt " $line" amd64 )" || true; \
8089 [ -n "$sel" ] && printf '%s\n ' "$sel" >> /tmp/wine-deps.amd64; \
8190 done < /tmp/wine-reqs.amd64; \
8291 : >/tmp/wine-deps.armhf; \
8392 while IFS= read -r line; do \
84- sel="$(pick_first_available " $line")" || true; \
85- [ -n "$sel" ] && printf '%s:armhf \n ' "$sel" >> /tmp/wine-deps.armhf; \
93+ sel="$(resolve_alt " $line" i386 )" || true; \
94+ [ -n "$sel" ] && printf '%s\n ' "$sel" >> /tmp/wine-deps.armhf; \
8695 done < /tmp/wine-reqs.i386; \
8796 # Generate final dependency list
8897 sort -u /tmp/wine-deps.amd64 /tmp/wine-deps.armhf > /tmp/wine-deps.txt; \
0 commit comments