Skip to content

Commit 02b7dfe

Browse files
committed
fix(wine): fix parsing 32 bit deps
1 parent ef7a61b commit 02b7dfe

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

scripts/wine/find-deps.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,6 @@ if [ -n "${COMPAT}" ]; then
124124
}' | sort -u >"${AVC}"
125125
fi
126126

127-
# Multi-Arch:same (keep as pkg:arch for checks)
128-
MAS="$(mktemp)"; : >"${MAS}"
129-
if [ -n "${COMPAT}" ]; then
130-
xargs -a "${TOKENS}" -r -I{} printf '%s:%s\n' '{}' "${COMPAT}" \
131-
| xargs -r apt-cache show -- 2>/dev/null \
132-
| awk -v arch="${COMPAT}" -F': ' '
133-
NF==0 { if (p && a==arch && tolower(ma)=="same") print p ":" a; p=a=ma=""; next }
134-
$1=="Package" { p=$2 }
135-
$1=="Architecture" { a=$2 }
136-
$1=="Multi-Arch" { ma=$2 }
137-
END { if (p && a==arch && tolower(ma)=="same") print p ":" a }
138-
' | sort -u >"${MAS}"
139-
fi
140-
141127
# Helper: pick first available alternative against given availability cache
142128
pick_alt() { line=$1; avail=$2; suff=${3:-}; OLDIFS=${IFS}; IFS='|'
143129
for t in ${line}; do
@@ -151,6 +137,19 @@ pick_alt() { line=$1; avail=$2; suff=${3:-}; OLDIFS=${IFS}; IFS='|'
151137
IFS=${OLDIFS}; return 1
152138
}
153139

140+
# Helper: return 0 if pkg:arch is Multi-Arch: same, else 1
141+
ma_same_pkg() { # $1=pkg $2=arch
142+
apt-cache show "$1:$2" 2>/dev/null \
143+
| awk -v p="$1" -v a="$2" -F': ' '
144+
# parse stanza-by-stanza
145+
NF==0 { if (pk && ar==a && tolower(ma)=="same") {ok=1} pk=ar=ma=""; next }
146+
$1=="Package" { pk=$2 }
147+
$1=="Architecture" { ar=$2 }
148+
$1=="Multi-Arch" { ma=$2 }
149+
END { if (pk && ar==a && tolower(ma)=="same") ok=1; exit (ok?0:1) }
150+
'
151+
}
152+
154153
# Native → print bare names (stable de-dupe)
155154
NSET="$(mktemp)"; : >"${NSET}"
156155
while IFS= read -r L; do
@@ -166,17 +165,17 @@ if [ -n "${COMPAT}" ]; then
166165

167166
chosen=""
168167
if ! grep -Fxq "${base}" "${NSET}"; then
169-
chosen="${first}"
168+
chosen="${first}"
170169
else
171-
if grep -Fxq "${base}:${COMPAT}" "${MAS}"; then
170+
if ma_same_pkg "${base}" "${COMPAT}"; then
172171
chosen="${first}"
173172
else
174173
OLDIFS=${IFS}; IFS='|'
175174
for t in ${L}; do
176175
p=$(printf '%s' "${t}" | sed -E 's/\(.*\)//; s/:any$//; s/:all$//; s/^[[:space:]]+|[[:space:]]+$//g')
177176
[ -n "${p}" ] || continue
178177
grep -Fxq "${p}" "${AVC}" || continue
179-
if ! grep -Fxq "${p}" "${NSET}" || grep -Fxq "${p}:${COMPAT}" "${MAS}"; then
178+
if ! grep -Fxq "${p}" "${NSET_SORT}" || ma_same_pkg "${p}" "${COMPAT}"; then
180179
chosen="${p}:${COMPAT}"; break
181180
fi
182181
done
@@ -189,4 +188,4 @@ if [ -n "${COMPAT}" ]; then
189188
fi
190189

191190
# cleanup
192-
rm -f "${TOKENS}" "${AVN}" "${AVC}" "${MAS}" "${NSET}" 2>/dev/null || true
191+
rm -f "${TOKENS}" "${AVN}" "${AVC}" "${NSET}" 2>/dev/null || true

0 commit comments

Comments
 (0)