2019-02-25 15:41:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-12-31 04:48:34 +01:00
|
|
|
# default directories
|
|
|
|
dxvk_lib32=${dxvk_lib32:-"x32"}
|
|
|
|
dxvk_lib64=${dxvk_lib64:-"x64"}
|
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
# figure out where we are
|
2020-01-17 03:00:09 +01:00
|
|
|
basedir=$(dirname "$(readlink -f $0)")
|
2019-02-25 15:41:28 +01:00
|
|
|
|
|
|
|
# figure out which action to perform
|
|
|
|
action="$1"
|
|
|
|
|
|
|
|
case "$action" in
|
|
|
|
install)
|
|
|
|
;;
|
|
|
|
uninstall)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognized action: $action"
|
2020-03-18 21:02:42 +01:00
|
|
|
echo "Usage: $0 [install|uninstall] [--without-dxgi] [--with-d3d10] [--symlink]"
|
2019-02-25 15:41:28 +01:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
# process arguments
|
|
|
|
shift
|
|
|
|
|
2020-01-17 03:00:09 +01:00
|
|
|
with_dxgi=true
|
2020-03-18 21:02:42 +01:00
|
|
|
with_d3d10=false
|
2020-01-17 02:54:32 +01:00
|
|
|
file_cmd="cp -v"
|
2019-02-25 15:41:28 +01:00
|
|
|
|
2020-01-17 03:00:09 +01:00
|
|
|
while (($# > 0)); do
|
2019-02-25 15:41:28 +01:00
|
|
|
case "$1" in
|
|
|
|
"--without-dxgi")
|
2020-01-17 03:00:09 +01:00
|
|
|
with_dxgi=false
|
2019-02-25 15:41:28 +01:00
|
|
|
;;
|
2020-03-18 21:02:42 +01:00
|
|
|
"--with-d3d10")
|
|
|
|
with_d3d10=true
|
|
|
|
;;
|
2019-02-25 15:41:28 +01:00
|
|
|
"--symlink")
|
2020-01-17 02:54:32 +01:00
|
|
|
file_cmd="ln -s -v"
|
2019-02-25 15:41:28 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# check wine prefix before invoking wine, so that we
|
|
|
|
# don't accidentally create one if the user screws up
|
|
|
|
if [ -n "$WINEPREFIX" ] && ! [ -f "$WINEPREFIX/system.reg" ]; then
|
|
|
|
echo "$WINEPREFIX:"' Not a valid wine prefix.' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# find wine executable
|
|
|
|
export WINEDEBUG=-all
|
|
|
|
|
2019-12-31 04:48:34 +01:00
|
|
|
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.
|
|
|
|
# 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
|
2019-02-25 15:41:28 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# resolve 32-bit and 64-bit system32 path
|
2020-01-17 03:00:09 +01:00
|
|
|
winever=$($wine --version | grep wine)
|
2019-02-25 15:41:28 +01:00
|
|
|
if [ -z "$winever" ]; then
|
|
|
|
echo "$wine:"' Not a wine executable. Check your $wine.' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-18 09:02:18 +02:00
|
|
|
# ensure wine placeholder dlls are recreated
|
|
|
|
# if they are missing
|
|
|
|
$wineboot -u
|
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
win64_sys_path=$($wine64 winepath -u 'C:\windows\system32' 2> /dev/null)
|
2020-04-13 20:12:40 +02:00
|
|
|
win64_sys_path="${win64_sys_path/$'\r'/}"
|
2019-12-31 04:48:34 +01:00
|
|
|
if $wow64; then
|
|
|
|
win32_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
|
2020-04-13 20:12:40 +02:00
|
|
|
win32_sys_path="${win32_sys_path/$'\r'/}"
|
2019-12-31 04:48:34 +01:00
|
|
|
fi
|
2019-02-25 15:41:28 +01:00
|
|
|
|
|
|
|
if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_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
|
|
|
|
echo -e "Failed to add override for $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# remove dll override
|
|
|
|
restoreDll() {
|
|
|
|
$wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v $1 /f > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to remove override for $1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# copy or link dxvk dll, back up original file
|
|
|
|
installFile() {
|
|
|
|
dstfile="${1}/${3}.dll"
|
|
|
|
srcfile="${basedir}/${2}/${3}.dll"
|
|
|
|
|
|
|
|
if [ -f "${srcfile}.so" ]; then
|
|
|
|
srcfile="${srcfile}.so"
|
|
|
|
fi
|
2019-05-18 09:02:18 +02:00
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
if ! [ -f "${srcfile}" ]; then
|
2019-05-18 09:02:18 +02:00
|
|
|
echo "${srcfile}: File not found. Skipping." >&2
|
|
|
|
return 1
|
2019-02-25 15:41:28 +01:00
|
|
|
fi
|
2019-05-18 09:02:18 +02:00
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
if [ -n "$1" ]; then
|
2019-05-18 22:19:51 +02:00
|
|
|
if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then
|
2019-02-25 15:41:28 +01:00
|
|
|
if ! [ -f "${dstfile}.old" ]; then
|
2020-01-17 02:54:32 +01:00
|
|
|
mv -v "${dstfile}" "${dstfile}.old"
|
2019-02-25 15:41:28 +01:00
|
|
|
else
|
2020-01-17 02:54:32 +01:00
|
|
|
rm -v "${dstfile}"
|
2019-02-25 15:41:28 +01:00
|
|
|
fi
|
|
|
|
$file_cmd "${srcfile}" "${dstfile}"
|
|
|
|
else
|
|
|
|
echo "${dstfile}: File not found in wine prefix" >&2
|
2019-05-18 09:02:18 +02:00
|
|
|
return 1
|
2019-02-25 15:41:28 +01:00
|
|
|
fi
|
|
|
|
fi
|
2019-05-18 09:02:18 +02:00
|
|
|
return 0
|
2019-02-25 15:41:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# remove dxvk dll, restore original file
|
|
|
|
uninstallFile() {
|
2019-05-18 09:02:18 +02:00
|
|
|
dstfile="${1}/${3}.dll"
|
|
|
|
srcfile="${basedir}/${2}/${3}.dll"
|
|
|
|
|
|
|
|
if [ -f "${srcfile}.so" ]; then
|
|
|
|
srcfile="${srcfile}.so"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -f "${srcfile}" ]; then
|
|
|
|
echo "${srcfile}: File not found. Skipping." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-05-18 22:19:51 +02:00
|
|
|
if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then
|
2019-05-18 09:02:18 +02:00
|
|
|
echo "${dstfile}: File not found. Skipping." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
if [ -f "${dstfile}.old" ]; then
|
2020-01-17 02:54:32 +01:00
|
|
|
rm -v "${dstfile}"
|
|
|
|
mv -v "${dstfile}.old" "${dstfile}"
|
2019-05-18 09:02:18 +02:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
2019-02-25 15:41:28 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
2019-12-31 04:48:34 +01:00
|
|
|
installFile "$win64_sys_path" "$dxvk_lib64" "$1"
|
2019-05-18 09:02:18 +02:00
|
|
|
inst64_ret="$?"
|
2019-12-31 04:48:34 +01:00
|
|
|
|
|
|
|
inst32_ret=-1
|
|
|
|
if $wow64; then
|
|
|
|
installFile "$win32_sys_path" "$dxvk_lib32" "$1"
|
|
|
|
inst32_ret="$?"
|
|
|
|
fi
|
|
|
|
|
2020-01-17 03:00:09 +01:00
|
|
|
if (( ($inst32_ret == 0) || ($inst64_ret == 0) )); then
|
2019-05-18 09:02:18 +02:00
|
|
|
overrideDll "$1"
|
|
|
|
fi
|
2019-02-25 15:41:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uninstall() {
|
2019-12-31 04:48:34 +01:00
|
|
|
uninstallFile "$win64_sys_path" "$dxvk_lib64" "$1"
|
2019-05-18 09:02:18 +02:00
|
|
|
uninst64_ret="$?"
|
2019-12-31 04:48:34 +01:00
|
|
|
|
|
|
|
uninst32_ret=-1
|
|
|
|
if $wow64; then
|
|
|
|
uninstallFile "$win32_sys_path" "$dxvk_lib32" "$1"
|
|
|
|
uninst32_ret="$?"
|
|
|
|
fi
|
|
|
|
|
2020-01-17 03:00:09 +01:00
|
|
|
if (( ($uninst32_ret == 0) || ($uninst64_ret == 0) )); then
|
2019-05-18 09:02:18 +02:00
|
|
|
restoreDll "$1"
|
|
|
|
fi
|
2019-02-25 15:41:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# skip dxgi during install if not explicitly
|
|
|
|
# enabled, but always try to uninstall it
|
2020-01-17 03:00:09 +01:00
|
|
|
if $with_dxgi || [ "$action" == "uninstall" ]; then
|
2019-02-25 15:41:28 +01:00
|
|
|
$action dxgi
|
|
|
|
fi
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
$action d3d9
|
2020-03-18 21:02:42 +01:00
|
|
|
|
|
|
|
if $with_d3d10 || [ "$action" == "uninstall" ]; then
|
|
|
|
$action d3d10
|
|
|
|
$action d3d10_1
|
|
|
|
fi
|
|
|
|
|
2019-02-25 15:41:28 +01:00
|
|
|
$action d3d10core
|
|
|
|
$action d3d11
|