From 14a158ae097f369f275ed32f2ff92d0ff11c509a Mon Sep 17 00:00:00 2001 From: Jack Greiner Date: Fri, 25 Oct 2024 22:04:44 -0400 Subject: [PATCH] Squashed commit of the following: commit 7647142dc0988f9e5b478bcff2d233371cd1b712 Author: Jack Greiner Date: Fri Oct 25 22:01:42 2024 -0400 Squashed commit of the following: commit b17e01f282acab711d77020d1df7d904438ab8b2 Author: the Sane. <3657071+the-sane@users.noreply.github.com> Date: Fri Oct 25 21:34:57 2024 -0400 Simplify and move get_file_arch out of subfunction commit 9c23d6d07ccd1939c8f6ec034c60a2149ff795a8 Author: Jack Greiner Date: Fri Oct 25 21:28:12 2024 -0400 lug-helper.sh: Add check for 32-bit only wine installs and fail the preflight check. commit 7781a49a677f9c8a8419fc431af5cd77eeb51a34 Author: the Sane. <3657071+the-sane@users.noreply.github.com> Date: Fri Oct 25 21:04:29 2024 -0400 Remove unnecessary architecture checks commit 71b226598a0654204578a09f81bb15281d9c2bd4 Author: the Sane. <3657071+the-sane@users.noreply.github.com> Date: Fri Oct 25 20:54:49 2024 -0400 Simplify architecture check commit 1afd9af437a8cee95a2a767186c605b4d7ba4216 Author: Jack Greiner Date: Fri Oct 25 20:26:10 2024 -0400 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. --- lug-helper.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index c936662..eccbd76 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -1002,12 +1002,76 @@ wine_check() { system_wine_ok="true" fi - # Check for wow64 wines - if [ ! -x "$(command -v wine-preloader)" ] || [ -L "$(command -v wine64-preloader)" ]; then - system_wine_ok="false" + # If system wine passes the above checks, also check for the new wow64 mode that currently does not work + 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 + 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 + + # Check for the new WOW64, 32bit, or unknown states and then fail the check + if [ "${wineserver_binary_arch}" = "${wine_binary_arch}" ] || [ -z "${wineserver_binary_arch}" ] || [ -z "${wine_binary_arch}" ]; then + system_wine_ok="false" + fi fi } +# Function to determine the architecture of a binary file using 'od' +# Used for wine_check above to check the system wine architecture +get_file_arch() { + case "$(od -An -t x1 -j 0x12 -N 1 "$1" 2>/dev/null | tr -d '[:space:]')" in + "3e") + # x86_64 + echo "64bit" + ;; + "03"|"06") + # i386 + echo "32bit" + ;; + "b7") + # aarch64 + echo "64bit" + ;; + "28") + # aarch32 + echo "32bit" + ;; + *) + # Unknown + echo "" + ;; + esac +} + # Check system memory and swap space memory_check() { # Get totals in bytes