diff --git a/src/winetricks b/src/winetricks index 6f9894c7f..35a654cc8 100755 --- a/src/winetricks +++ b/src/winetricks @@ -5089,10 +5089,31 @@ winetricks_set_wineprefix() elif command -v "${WINE}64" >/dev/null 2>&1; then WINE64="${WINE}64" else - # Handle case where wine binaries (or binary wrappers) have a suffix - WINE64="$(dirname "${WINE}")/" - [ "${WINE64}" = "./" ] && WINE64="" - WINE64="${WINE64}$(basename "${WINE}" | sed 's/^wine/wine64/')" + # wineboot often is a link next to wineserver (whose path we already know) + # pointing to wineapploader in Wine's bindir. So try this to figure out Wine's bindir. + WINEBOOT_BIN="$(echo "${WINESERVER_BIN}"|sed 's,wineserver,wineboot,')" + if [ -x "${WINEBOOT_BIN}" ]; then + if [ -n "${READLINK_F}" ]; then + true + elif [ "$(uname -s)" = "Darwin" ]; then + # readlink exists on MacOS, but does not support "-f" on MacOS < 12.3 + # Use perl instead + READLINK_F="perl -MCwd=abs_path -le 'print abs_path readlink(shift);'" + else + READLINK_F="readlink -f" + fi + WINE_BINDIR="$(dirname "$(${READLINK_F} "${WINEBOOT_BIN}" 2>/dev/null)" 2>/dev/null)" + if [ -x "${WINE_BINDIR}/wine64" ]; then + # Workaround case where wine and related binaries are in path, + # but wine64 is only in Wine's bindir + WINE64="${WINE_BINDIR}/wine64" + fi + else + # Handle case where wine binaries (or binary wrappers) have a suffix + WINE64="$(dirname "${WINE}")/" + [ "${WINE64}" = "./" ] && WINE64="" + WINE64="${WINE64}$(basename "${WINE}" | sed 's/^wine/wine64/')" + fi fi WINE_ARCH="${WINE64}" WINE_MULTI="${WINE}"