-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathsetup_vkd3d_proton.sh
219 lines (183 loc) · 4.86 KB
/
setup_vkd3d_proton.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/env bash
# default directories
vkd3d_lib32=${vkd3d_lib32:-"x86"}
vkd3d_lib64=${vkd3d_lib64:-"x64"}
# figure out where we are
basedir=$(dirname "$(readlink -f "$0")")
# figure out which action to perform
action="$1"
case "$action" in
install)
;;
uninstall)
;;
*)
echo "Unrecognized action: $action"
echo "Usage: $0 [install|uninstall] [--symlink]"
exit 1
esac
# process arguments
shift
file_cmd="cp -v"
while (($# > 0)); do
case "$1" in
"--symlink")
file_cmd="ln -s -v"
;;
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="${WINEDEBUG:--all}"
# disable mscoree and mshtml to avoid downloading
# wine gecko and mono
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:-}${WINEDLLOVERRIDES:+,}mscoree,mshtml="
wine_path="$(which wine 2>/dev/null)"
wine64_path="$(which wine64 2>/dev/null)"
if [ -n "$wine_path" ] && [ -n "$wine64_path" ] && [ "$(dirname "$wine_path")" != "$(dirname "$wine64_path")" ]; then
echo "Multiple Wine installations detected:"
echo "1) $wine_path"
echo "2) $wine64_path"
while true; do
read -p "Select the Wine binary to use (1 or 2): " choice
case "$choice" in
1) wine="wine"; break ;;
2) wine="wine64"; break ;;
*) echo "Invalid choice. Please enter 1 or 2." ;;
esac
done
else
if [ -n "$wine_path" ]; then
wine="wine"
fi
if [ -n "$wine64_path" ]; then
wine="wine64"
fi
fi
winever=$($wine --version | grep wine)
if [ -z "$winever" ]; then
echo "$wine:"' Not a wine executable. Check your $wine.' >&2
exit 1
fi
echo "Using: $winever"
wineboot="$wine wineboot"
win64=true
win32=true
# ensure wine placeholder dlls are recreated
# if they are missing
$wineboot -u
win64_sys_path="$($wine cmd /c '%SystemRoot%\system32\winepath.exe -u C:\windows\system32' 2>/dev/null)"
win64_sys_path="${win64_sys_path/$'\r'/}"
[ -z "$win64_sys_path" ] && win64=false
if grep --quiet -e '#arch=win32' "${WINEPREFIX:-$HOME/.wine}/system.reg"; then
win32_sys_path=$win64_sys_path
win64=false
win32=true
else
win32_sys_path="$($wine cmd /c '%SystemRoot%\syswow64\winepath.exe -u C:\windows\system32' 2>/dev/null)"
win32_sys_path="${win32_sys_path/$'\r'/}"
[ -z "$win32_sys_path" ] && win32=false
fi
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() {
if ! $wine 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
}
# remove dll override
restoreDll() {
if ! $wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v "$1" /f > /dev/null 2>&1
then
echo "Failed to remove override for $1"
fi
}
# copy or link vkd3d dll, back up original file
installFile() {
dstfile="${1}/${3}.dll"
srcfile="${basedir}/${2}/${3}.dll"
if ! [ -f "${srcfile}" ]; then
echo "${srcfile}: File not found. Skipping." >&2
return 1
fi
if [ -n "$1" ]; then
if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then
if ! [ -f "${dstfile}.old" ]; then
mv -v "${dstfile}" "${dstfile}.old"
else
rm -v "${dstfile}"
fi
else
touch "${dstfile}.old_none"
fi
$file_cmd "${srcfile}" "${dstfile}"
fi
return 0
}
# remove vkd3d dll, restore original file
uninstallFile() {
dstfile="${1}/${3}.dll"
srcfile="${basedir}/${2}/${3}.dll"
if ! [ -f "${srcfile}" ]; then
echo "${srcfile}: File not found. Skipping." >&2
return 1
fi
if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then
echo "${dstfile}: File not found. Skipping." >&2
return 1
fi
if [ -f "${dstfile}.old" ]; then
rm -v "${dstfile}"
mv -v "${dstfile}.old" "${dstfile}"
return 0
elif [ -f "${dstfile}.old_none" ]; then
rm -v "${dstfile}.old_none"
rm -v "${dstfile}"
return 0
else
return 1
fi
}
install() {
inst64_ret=-1
if [ $win64 = "true" ]; then
installFile "$win64_sys_path" "$vkd3d_lib64" "$1"
inst64_ret="$?"
fi
inst32_ret=-1
if [ $win32 = "true" ]; then
installFile "$win32_sys_path" "$vkd3d_lib32" "$1"
inst32_ret="$?"
fi
if (( ($inst32_ret == 0) || ($inst64_ret == 0) )); then
overrideDll "$1"
fi
}
uninstall() {
uninst64_ret=-1
if [ $win64 = "true" ]; then
uninstallFile "$win64_sys_path" "$vkd3d_lib64" "$1"
uninst64_ret="$?"
fi
uninst32_ret=-1
if [ $win32 = "true" ]; then
uninstallFile "$win32_sys_path" "$vkd3d_lib32" "$1"
uninst32_ret="$?"
fi
if (( ($uninst32_ret == 0) || ($uninst64_ret == 0) )); then
restoreDll "$1"
fi
}
$action d3d12
$action d3d12core