[pkg-wine-party] Bug#769234: Automatically detect wine32 and wine64.

Jens Reyer jre.winesim at gmail.com
Fri Dec 11 21:52:01 UTC 2015


please see below for another patch. IMO it is clean, simple and
matches the logic of the wine-script perfectly.

It tries to detect the correct wine version using the following

1. WINEARCH - can't be misinterpreted and was also used
2. WINEPREFIX - if it is set and system.reg exists, we have a
   clean indicator if it is a 32-bit or 64-bit installation,
   and therefore which wine to use.
3. WINELOADER - if it is set to a known loader, use this for
   deciding which wine to use.
   The 32-bit loaders seem to work with both wine32 and wine64,
   but I see no point in doing this here. Instead it is easier
   to choose the correct 32-bit or 64-bit wineprefix later if
   wine loader and binary match.
   Note that I'm not really familiar with the preloader.
4. Test with "file" if $1 is a 64-bit application. Note that some
   64-bit applications have PE32 installers, or install single
   PE32 executables. But those also seem to work with wine64 as
   long as wine32 is installed. Therefore only testing for PE32+.

Additionally to the posted patch, we'd need to depend on "file".

It seems to work perfectly, except for one case which can't be solved

64-bit applications with PE32 installers still require manual
intervention (e.g. export WINEARCH=win64) to install correctly. Then
they will work automatically afterwards.
Without manual intervention they are installed in a 32-bit prefix.
Desktop launchers are broken then. Starting a 64-bit app directly will
work, but will be running in a 64-bit prefix despite of being installed
in a 32-bit prefix.
Without these changes they will be installed in a 32-bit prefix, but
then fail to work.
So this patch may obfuscate the need for manual intervention.

However one may use WoW64 (#762058) together with this patch.

What do you think?


diff --git a/debian/scripts/wine b/debian/scripts/wine
index eb929a9..a1463c9 100755
--- a/debian/scripts/wine
+++ b/debian/scripts/wine
@@ -6,6 +6,32 @@ bindir=/usr/lib/$name
+if test -n "$WINEARCH"; then
+    true
+elif [ -n "$WINEPREFIX" ] &&
+         [ -e "${WINEPREFIX}/system.reg" ] &&
+         grep -q "^\#arch=win32" "${WINEPREFIX}/system.reg"; then
+    echo "Setting WINEARCH=win32 because $WINEPREFIX is a 32-bit installation."
+    WINEARCH=win32
+elif [ -n "$WINEPREFIX" ] &&
+         [ -e "${WINEPREFIX}/system.reg" ] &&
+         grep -q "^\#arch=win64" "${WINEPREFIX}/system.reg"; then
+    echo "Setting WINEARCH=win64 because $WINEPREFIX is a 64-bit installation."
+    WINEARCH=win64
+elif [ -n "$WINELOADER" ] &&
+         [ "$(echo $WINELOADER|sed "s|-preloader||;s|wine32|wine|")" = "/usr/lib/$name/wine" ]; then
+    echo "Setting WINEARCH=win32 because of WINELOADER $WINELOADER."
+    WINEARCH=win32
+elif [ -n "$WINELOADER" ] &&
+         [ "$(echo $WINELOADER|sed "s|-preloader||")" = "/usr/lib/$name/wine64" ]; then
+    echo "Setting WINEARCH=win64 because of WINELOADER $WINELOADER."
+    WINEARCH=win64
+elif [ -f "$1" ] &&
+         file -bL "$1"|grep -Eq "PE32+ executable.*x86-64"; then
+    echo "Setting WINEARCH=win64 because $1 is a PE32+ executable."
+    WINEARCH=win64
 if test -x $wine32 -a "$WINEARCH" != "win64"; then
 elif test -x $wine64; then

More information about the pkg-wine-party mailing list