lug-helper.sh: Add detection for new WOW64 mode system Wine installs

This allows us to fail the preflight if a user has a system Wine but that Wine uses the experimental WOW64 mode, which EAC does not yet support.
This commit is contained in:
Jack Greiner 2024-10-25 20:26:10 -04:00
parent 1e1793bcac
commit 1afd9af437
No known key found for this signature in database
GPG Key ID: F34343A8F6B33E1E

View File

@ -985,8 +985,6 @@ wine_check() {
if [ ! -x "$(command -v wine)" ]; then
preflight_fail+=("Wine does not appear to be installed.\nPlease refer to our Quick Start Guide:\n$lug_wiki")
return 1
else
preflight_pass+=("Wine is installed on your system.")
fi
# Get the current wine version
@ -1002,8 +1000,85 @@ wine_check() {
system_wine_ok="true"
fi
# Check for wow64 wines
if [ ! -x "$(command -v wine-preloader)" ] || [ -L "$(command -v wine64-preloader)" ]; then
# Function to determine the architecture of a binary file using 'od'
get_file_arch() {
local file_path="$1"
local ob_output
ob_output="$(od -An -t x1 -j 0x12 -N 1 "$file_path" 2>/dev/null | tr -d '[:space:]')"
case "$ob_output" in
"3e") echo "x86_64" ;;
"03"|"06") echo "i386" ;;
"b7") echo "aarch64" ;;
"28") echo "aarch32" ;;
*) echo "" ;;
esac
}
# Proceed only if the Wine version is acceptable
if [ "$system_wine_ok" = "true" ]; then
# Get paths to wine and wineserver binaries
wine_bin="$(command -v wine)"
wineserver_bin="$(command -v wineserver)"
wineboot_bin="$(command -v wineboot)"
# Determine the architecture of wine binary
wine_binary_arch="$(get_file_arch "${wine_bin}")"
# If unable to determine architecture, attempt alternative methods
if [ -z "${wine_binary_arch}" ]; then
wineboot_bin="$(command -v wineboot)"
if [ -x "${wineboot_bin}" ]; then
wine_bin_dir="$(dirname "$(readlink -f "${wineboot_bin}" 2>/dev/null)" 2>/dev/null)"
if [ -x "${wine_bin_dir}/wine" ]; then
wine_binary_arch="$(get_file_arch "${wine_bin_dir}/wine")"
fi
fi
fi
# Determine the architecture of wineserver binary
wineserver_binary_arch="$(get_file_arch "${wineserver_bin}")"
if [ -z "${wineserver_binary_arch}" ]; then
if [ -x "${wineboot_bin}" ]; then
wine_bin_dir="$(dirname "$(readlink -f "${wineboot_bin}" 2>/dev/null)" 2>/dev/null)"
if [ -x "${wine_bin_dir}/wineserver64" ]; then
wineserver_binary_arch="$(get_file_arch "${wine_bin_dir}/wineserver64")"
elif [ -x "${wine_bin_dir}/wineserver32" ]; then
wineserver_binary_arch="$(get_file_arch "${wine_bin_dir}/wineserver32")"
elif [ -x "${wine_bin_dir}/wineserver" ]; then
wineserver_binary_arch="$(get_file_arch "${wine_bin_dir}/wineserver")"
fi
fi
fi
# Determine WOW64 type
if [ "${wineserver_binary_arch}" = "${wine_binary_arch}" ]; then
wow64_style="new"
elif [ -n "${wineserver_binary_arch}" ] && [ -n "${wine_binary_arch}" ]; then
wow64_style="classic"
else
wow64_style="unknown"
system_wine_ok="false"
fi
# If WOW64 support is present, check if it's "new" or "classic WOW64
# If it is set system_wine_ok to false
if [ "${wow64_style}" = "new" ]; then
preflight_fail+=("Wine is installed but uses the experimental WOW64 mode, which is not supported.")
system_wine_ok="false"
elif [ "${wow64_style}" = "classic" ]; then
preflight_pass+=("Wine is installed on your system.")
system_wine_ok="true"
elif [ "${wow64_style}" = "unknown" ]; then
preflight_fail+=("Failed to determine if Wine has experimental WOW64 support.")
system_wine_ok="false"
else
# Wine is installed and does not have WOW64 support
preflight_fail+=("Wine is installed but does not have WOW64 support. Please install 64bit Wine")
system_wine_ok="false"
fi
else
preflight_fail+=("Wine version $wine_current does not meet the required version $wine_required.")
system_wine_ok="false"
fi
}