summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorStelios Tsampas2024-02-26 02:25:35 +0200
committerStelios Tsampas2024-02-26 02:25:35 +0200
commite47859aa6b2aa9e8a5f7c09db9a9324fd8ef1170 (patch)
treee7293b608a20772118b9a75f9741fb6097860c80
parent9e58a3e8a00d5e7d9a3cbae721eaa54a6310c77f (diff)
downloadaur-e47859aa6b2aa9e8a5f7c09db9a9324fd8ef1170.tar.gz
[dxvk-mingw] Update setup script
-rwxr-xr-x[-rw-r--r--]setup_dxvk.sh104
1 files changed, 72 insertions, 32 deletions
diff --git a/setup_dxvk.sh b/setup_dxvk.sh
index a45002f3c611..287a27244f58 100644..100755
--- a/setup_dxvk.sh
+++ b/setup_dxvk.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+set -x
+
# default directories
dxvk_lib32=${dxvk_lib32:-"x32"}
dxvk_lib64=${dxvk_lib64:-"x64"}
@@ -52,25 +54,60 @@ export WINEDEBUG=-all
# wine gecko and mono
export WINEDLLOVERRIDES="mscoree,mshtml="
+wineserver="wineserver"
wine="wine"
wine64="wine64"
wineboot="wineboot"
# $PATH is the way for user to control where wine is located (including custom Wine versions).
-# Pure 64-bit Wine (non Wow64) requries skipping 32-bit steps.
+# Pure 64-bit Wine (non Wow64) requires skipping 32-bit steps.
# In such case, wine64 and winebooot will be present, but wine binary will be missing,
# however it can be present in other PATHs, so it shouldn't be used, to avoid versions mixing.
-wine_path=$(dirname "$(which $wineboot)")
-wow64=true
-if ! [ -f "$wine_path/$wine" ]; then
- wine=$wine64
- wow64=false
+wine_path=$(dirname "$(which $wineserver)")
+
+# Thank you winetricks!
+get_file_arch()
+{
+ _W_file="$1"
+ # Assume ELF binaries for everything else
+ _W_ob_output="$(od -An -t x1 -j 0x12 -N 1 "${_W_file}" | tr -d "[:space:]")"
+ case "${_W_ob_output}" in
+ "3e") _W_file_arch="x86_64" ;;
+ "03"|"06") _W_file_arch="i386" ;;
+ "b7") _W_file_arch="aarch64" ;;
+ "28") _W_file_arch="aarch32" ;;
+ *) _W_file_arch="" ;;
+ esac
+
+ echo "${_W_file_arch}"
+}
+
+if [ -z "$WINEARCH" ]; then
+ wine_arch=$(get_file_arch "$wine_path/$wine")
+ wine64_arch=$(get_file_arch "$wine_path/$wine64")
+ if [ "$wine_arch" == "i386" ] && [ "$wine64_arch" == "x86_64" ]; then
+ arch=win64
+ elif [ "$wine_arch" == "x86_64" ]; then
+ arch=win64
+ elif [ "$wine_arch" == "i386" ] && [ "$wine64_arch" == "" ]; then
+ arch=win32
+ fi
+else
+ arch="$WINEARCH"
+fi
+
+if ! [ -f "$wine_path/$wine64" ]; then
+ wine64="$wine_path/$wine"
+fi
+
+if [ "$arch" == "win32" ]; then
+ wine64="$wine"
fi
# resolve 32-bit and 64-bit system32 path
-winever="$($wine --version | grep wine)"
+winever="$($wineserver --version 2>&1 >/dev/null | grep Wine)"
if [ -z "$winever" ]; then
- echo "$wine:"' Not a wine executable. Check your $wine.' >&2
+ echo "$wineserver:"' Not a wine executable. Check your $wine.' >&2
exit 1
fi
@@ -78,25 +115,19 @@ fi
# if they are missing
$wineboot -u
-win64_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
-win64_sys_path="${win64_sys_path/$'\r'/}"
-win32_sys_path=$($wine winepath -u 'C:\windows\syswow64' 2> /dev/null)
-win32_sys_path="${win32_sys_path/$'\r'/}"
-
-# if syswow64 for the prefix doesn't exist, treat it as a win32 prefix
-if ! [ -d "$win32_sys_path" ]; then
- win32_sys_path="$win64_sys_path"
-fi
+system32_path=$($wine64 winepath.exe -u 'C:\windows\system32' 2> /dev/null)
+system32_path="${system32_path/$'\r'/}"
+syswow64_path=$($wine64 winepath.exe -u 'C:\windows\syswow64' 2> /dev/null)
+syswow64_path="${syswow64_path/$'\r'/}"
-if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_path" ]; then
+if [ -z "$syswow64_path" ] && [ -z "$system32_path" ]; then
echo 'Failed to resolve C:\windows\system32.' >&2
exit 1
fi
# create native dll override
overrideDll() {
- $wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /d native /f >/dev/null 2>&1
- if [ $? -ne 0 ]; then
+ if ! $wine64 reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /d native /f >/dev/null 2>&1; then
echo -e "Failed to add override for $1"
exit 1
fi
@@ -104,8 +135,7 @@ overrideDll() {
# remove dll override
restoreDll() {
- $wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /f > /dev/null 2>&1
- if [ $? -ne 0 ]; then
+ if ! $wine64 reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /f > /dev/null 2>&1; then
echo "Failed to remove override for $1"
fi
}
@@ -164,31 +194,41 @@ uninstallFile() {
}
install() {
- installFile "$win64_sys_path" "$dxvk_lib64" "$1"
- inst64_ret="$?"
+ if [ "$arch" == "win32" ]; then
+ installFile "$system32_path" "$dxvk_lib32" "$1"
+ inst64_ret="$?"
+ else
+ installFile "$system32_path" "$dxvk_lib64" "$1"
+ inst64_ret="$?"
+ fi
inst32_ret=-1
- if $wow64; then
- installFile "$win32_sys_path" "$dxvk_lib32" "$1"
+ if [ -d "$syswow64_path" ]; then
+ installFile "$syswow64_path" "$dxvk_lib32" "$1"
inst32_ret="$?"
fi
- if (( ($inst32_ret == 0) || ($inst64_ret == 0) )); then
+ if (( (inst32_ret == 0) || (inst64_ret == 0) )); then
overrideDll "$1"
fi
}
uninstall() {
- uninstallFile "$win64_sys_path" "$dxvk_lib64" "$1"
- uninst64_ret="$?"
+ if [ "$arch" == "win32" ]; then
+ uninstallFile "$system32_path" "$dxvk_lib32" "$1"
+ uninst64_ret="$?"
+ else
+ uninstallFile "$system32_path" "$dxvk_lib64" "$1"
+ inst64_ret="$?"
+ fi
uninst32_ret=-1
- if $wow64; then
- uninstallFile "$win32_sys_path" "$dxvk_lib32" "$1"
+ if [ -d "$syswow64_path" ]; then
+ uninstallFile "$syswow64_path" "$dxvk_lib32" "$1"
uninst32_ret="$?"
fi
- if (( ($uninst32_ret == 0) || ($uninst64_ret == 0) )); then
+ if (( (uninst32_ret == 0) || (uninst64_ret == 0) )); then
restoreDll "$1"
fi
}