Skip to content

Commit

Permalink
winetricks_get_file_arch: try workaround for scripts if arch is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
jre-wine committed Feb 23, 2024
1 parent a36b242 commit 8c1811c
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/winetricks
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ w_expand_env()
winetricks_early_wine_arch cmd.exe /c echo "%$1%"
}

# Determine what architecture a binary file is built for
# Determine what architecture a binary file is built for, emits "try-script" in case of failure
winetricks_get_file_arch()
{
_W_file="$1"
Expand All @@ -1075,7 +1075,7 @@ winetricks_get_file_arch()
"arm64") _W_file_arch="arm64" ;;
"i386") _W_file_arch="i386" ;;
"x86_64") _W_file_arch="x86_64" ;;
*) w_die "Unknown file arch: ${_W_lipo_output}" ;;
*) _W_file_arch="try-script" ;;
esac
else
# Assume ELF binaries for everything else
Expand All @@ -1085,7 +1085,7 @@ winetricks_get_file_arch()
"03"|"06") _W_file_arch="i386" ;;
"b7") _W_file_arch="aarch64" ;;
"28") _W_file_arch="aarch32" ;;
*) w_die "Unknown file arch: ${_W_ob_output}";;
*) _W_file_arch="try-script" ;;
esac
fi

Expand Down Expand Up @@ -5077,8 +5077,39 @@ winetricks_set_wineprefix()
WINEBOOT_BIN="$(dirname "${WINESERVER_BIN}")/$(basename "${WINESERVER_BIN}"|sed 's,wineserver,wineboot,')"

_W_wineserver_binary_arch="$(winetricks_get_file_arch "${WINESERVER_BIN}")"
if [ "${_W_wineserver_binary_arch}" = "try-script" ]; then
# wineserver might be a script calling a binary in Wine's bindir.
if [ -z "${WINE_BINDIR}" ] && [ -x "${WINEBOOT_BIN}" ]; then
WINE_BINDIR="$(dirname "$(${READLINK_F} "${WINEBOOT_BIN}" 2>/dev/null)" 2>/dev/null)"
fi
# wineserver in Wine's bindir might be a script calling wineserver64 preferably over wineserver32 (Debian).
# Try these before testing wineserver itself
if [ -x "${WINE_BINDIR}/wineserver64" ]; then
_W_wineserver_binary_arch="$(winetricks_get_file_arch "${WINE_BINDIR}/wineserver64")"
elif [ -x "${WINE_BINDIR}/wineserver32" ]; then
_W_wineserver_binary_arch="$(winetricks_get_file_arch "${WINE_BINDIR}/wineserver32")"
elif [ -x "${WINE_BINDIR}/wineserver" ]; then
_W_wineserver_binary_arch="$(winetricks_get_file_arch "${WINE_BINDIR}/wineserver")"
fi
fi
if [ "${_W_wineserver_binary_arch}" = "try-script" ]; then
w_die "Unknown file arch of ${WINESERVER_BIN}."
fi

WINE_BIN="$(which "${WINE}")"
_W_wine_binary_arch="$(winetricks_get_file_arch "${WINE_BIN}")"
if [ "${_W_wine_binary_arch}" = "try-script" ]; then
# wine might be a script calling a binary in Wine's bindir.
if [ -z "${WINE_BINDIR}" ] && [ -x "${WINEBOOT_BIN}" ]; then
WINE_BINDIR="$(dirname "$(${READLINK_F} "${WINEBOOT_BIN}" 2>/dev/null)" 2>/dev/null)"
fi
if [ -x "${WINE_BINDIR}/wine" ]; then
_W_wine_binary_arch="$(winetricks_get_file_arch "${WINE_BINDIR}/wine")"
fi
fi
if [ "${_W_wine_binary_arch}" = "try-script" ]; then
w_die "Unknown file arch of ${WINE_BIN}."
fi

# determine wow64 type (new/old)
# FIXME: check what upstream is calling them
Expand Down

0 comments on commit 8c1811c

Please sign in to comment.