@@ -6,19 +6,102 @@ FROM ghcr.io/cubecoders/amp:debian
66LABEL org.opencontainers.image.licenses=MIT
77
88ARG DEBIAN_FRONTEND=noninteractive
9+ ARG TARGETARCH
10+
11+ ARG WINE_LINK="https://dl.winehq.org/wine-builds/debian/pool/main/w/wine/"
12+ ARG WINE_BRANCH=stable
13+ ARG WINE_DIST=bookworm
14+ ARG WINE_TARGET=10
915
1016# Install required packages and Wine 10 stable
1117RUN set -eux; \
1218 apt-get update; \
1319 apt-get install -y --no-install-recommends cabextract winbind wine-binfmt python3; \
14- install -d -m 0755 /etc/apt/keyrings; \
15- wget -qO- https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -; \
16- wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources; \
17- apt-get update; \
18- apt-get install -y --install-recommends \
19- wine-stable-i386=10.0.0.0~bookworm-1 \
20- wine-stable-amd64=10.0.0.0~bookworm-1 \
21- wine-stable=10.0.0.0~bookworm-1 \
22- winehq-stable=10.0.0.0~bookworm-1; \
20+ WINE_VERSION="$(curl -fsSL " ${WINE_LINK}" \
21+ | grep -oE " wine-${WINE_BRANCH}-amd64_[0-9][0-9.]*~${WINE_DIST}-[0-9]+_amd64\. deb" \
22+ | sed -E " s/^wine-${WINE_BRANCH}-amd64_([0-9.]+)~${WINE_DIST}-[0-9]+_amd64\. deb$/\1 /" \
23+ | grep -E " ^${WINE_TARGET}(\. |$)" \
24+ | sort -V | tail -1)" ; \
25+ case "$TARGETARCH" in \
26+ amd64) \
27+ install -d -m 0755 /etc/apt/keyrings; \
28+ wget -qO- https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -; \
29+ wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/${WINE_DIST}/winehq-${WINE_DIST}.sources; \
30+ apt-get update; \
31+ apt-get install -y --install-recommends \
32+ wine-${WINE_BRANCH}-i386=${WINE_VERSION}~${WINE_DIST}-1 \
33+ wine-${WINE_BRANCH}-amd64=${WINE_VERSION}~${WINE_DIST}-1 \
34+ wine-${WINE_BRANCH}=${WINE_VERSION}~${WINE_DIST}-1 \
35+ winehq-${WINE_BRANCH}=${WINE_VERSION}~${WINE_DIST}-1; \
36+ ;; \
37+ arm64) \
38+ DEB_A1="wine-${WINE_BRANCH}-amd64_${WINE_VERSION}~${WINE_DIST}-1_amd64.deb" ; \
39+ DEB_A2="wine-${WINE_BRANCH}_${WINE_VERSION}~${WINE_DIST}-1_amd64.deb" ; \
40+ DEB_A3="winehq-${WINE_BRANCH}_${WINE_VERSION}~${WINE_DIST}-1_amd64.deb" ; \
41+ DEB_B1="wine-${WINE_BRANCH}-i386_${WINE_VERSION}~${WINE_DIST}-1_i386.deb" ; \
42+ wget -q ${WINE_LINK}${DEB_A1}; \
43+ wget -q ${WINE_LINK}${DEB_A2}; \
44+ wget -q ${WINE_LINK}${DEB_A3}; \
45+ wget -q ${WINE_LINK}${DEB_B1}; \
46+ for deb in *.deb; do dpkg-deb -x "$deb" /wine-installer; done; \
47+ : >/tmp/wine-reqs.amd64; : >/tmp/wine-reqs.i386; \
48+ # Collect dependencies
49+ for deb in ${DEB_A1} ${DEB_A2} ${DEB_A3}; do \
50+ { dpkg-deb -I "$deb" \
51+ | awk -F': ' '/^( Depends| Recommends):/{print $2}' \
52+ | tr ',' '\n ' \
53+ | sed -E 's/\( .*\) //; s/^[[:space:]]+|[[:space:]]+$//g' \
54+ | grep -E '.' \
55+ | grep -Ev '^(wine|winehq)[[:alnum:]-]*$' ; } >> /tmp/wine-reqs.amd64 || :; \
56+ done; \
57+ { dpkg-deb -I "${DEB_B1}" \
58+ | awk -F': ' '/^( Depends| Recommends):/{print $2}' \
59+ | tr ',' '\n ' \
60+ | sed -E 's/\( .*\) //; s/^[[:space:]]+|[[:space:]]+$//g' \
61+ | grep -E '.' \
62+ | grep -Ev '^(wine|winehq)[[:alnum:]-]*$' ; } >> /tmp/wine-reqs.i386 || :; \
63+ # Pick first available alternative
64+ pick_first_available() { \
65+ line="$1" ; \
66+ printf '%s' "$line" \
67+ | awk 'BEGIN{RS="\\ |"}{gsub(/^[[:space:]]+|[[:space:]]+$/,""); if(length) print}' \
68+ | 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; \
72+ fi; \
73+ done; \
74+ return 1; \
75+ }; \
76+ # Resolve separate lists
77+ : >/tmp/wine-deps.amd64; \
78+ while IFS= read -r line; do \
79+ sel="$(pick_first_available " $line")" || true; \
80+ [ -n "$sel" ] && printf '%s\n ' "$sel" >> /tmp/wine-deps.amd64; \
81+ done < /tmp/wine-reqs.amd64; \
82+ : >/tmp/wine-deps.armhf; \
83+ 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; \
86+ done < /tmp/wine-reqs.i386; \
87+ # Generate final dependency list
88+ sort -u /tmp/wine-deps.amd64 /tmp/wine-deps.armhf > /tmp/wine-deps.txt; \
89+ echo "Wine dependencies:" ; cat /tmp/wine-deps.txt || :; \
90+ mv wine-installer/opt/wine* /opt/wine-${WINE_DIST}; \
91+ rm -rf wine-installer *.deb; \
92+ xargs -ra "/tmp/wine-deps.txt" apt-get install -y --no-install-recommends; \
93+ if [ -f /opt/wine-stable/bin/wine64 ]; then \
94+ ln -sf /opt/wine-${WINE_DIST}/bin/wine64 /usr/bin/wine; \
95+ ln -sf /opt/wine-${WINE_DIST}/bin/wine /usr/bin/wine32; \
96+ else \
97+ ln -sf /opt/wine-${WINE_DIST}/bin/wine /usr/bin/wine; \
98+ fi; \
99+ ln -sf /opt/wine-${WINE_DIST}/bin/wineboot /usr/bin/wineboot; \
100+ ln -sf /opt/wine-${WINE_DIST}/bin/winecfg /usr/bin/winecfg; \
101+ ln -sf /opt/wine-${WINE_DIST}/bin/wineserver /usr/bin/wineserver; \
102+ chmod +x /usr/bin/wine /usr/bin/wineboot /usr/bin/winecfg /usr/bin/wineserver; \
103+ if [ -f /usr/bin/wine32 ]; then chmod +x /usr/bin/wine32; fi; \
104+ ;; \
105+ esac; \
23106 apt-get clean; \
24107 rm -rf /var/lib/apt/lists/*
0 commit comments