forked from end-4/CirnOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrocksmith-patch-nixos.sh
executable file
·320 lines (262 loc) · 8.49 KB
/
rocksmith-patch-nixos.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env bash
set -e
######################### VARS ###############################
USER=$(whoami)
# Constants (these shouldn't change!)
WINEASIOPATH="/lib/wine"
WINEASIODLLS=(
"/i386-unix/wineasio32.dll.so"
"/i386-windows/wineasio32.dll"
"/x86_64-unix/wineasio64.dll.so"
"/x86_64-windows/wineasio64.dll"
)
STEAMPATH="/home/${USER}/.steam/steam"
WINEPREFIX="${STEAMPATH}/steamapps/compatdata/221680/pfx/"
LAUNCH_OPTIONS="LD_PRELOAD=/lib/libjack.so PIPEWIRE_LATENCY=256/48000 %command%"
# Defaults
RSASIOVER="0.7.1"
PROTONVER="Proton - Experimental"
FILES_OR_DIST="files"
PROTONPATH="${STEAMPATH}/steamapps/common/${PROTONVER}"
WINE="${PROTONPATH}/${FILES_OR_DIST}/bin/wine"
WINE64="${PROTONPATH}/${FILES_OR_DIST}/bin/wine64"
#############################################################
print_color() {
local COLOR=$1
local NC='\033[0m'
echo -e "${COLOR}$2${NC}"
}
print_blue() {
local BLUE='\033[0;34m'
print_color $BLUE "$1"
}
print_green() {
local GREEN='\033[0;32m'
print_color $GREEN "$1"
}
print_red() {
local RED='\033[0;31m'
print_color $RED "$1"
}
print_orange() {
local ORANGE='\033[38;5;214m'
print_color $ORANGE "$1"
}
validate_proton_input() {
if [[ -z $1 || $1 =~ ^[0-2]$ ]]; then
return 0
else
return 1
fi
}
choose_proton() {
echo "Please choose your proton version that you use to run Rocksmith:"
print_orange "0) Proton - Experimental [Default]"
echo "1) Proton 9.0 (Beta)"
echo "2) Proton 8.0"
read -p "Choose your Proton Version (0-2): " USERPROTONVER
if validate_proton_input "$USERPROTONVER"; then
case $USERPROTONVER in
0)
PROTONVER="Proton - Experimental"
FILES_OR_DIST="files"
;;
1)
PROTONVER="Proton 9.0 (Beta)"
FILES_OR_DIST="files"
;;
2)
PROTONVER="Proton 8.0"
FILES_OR_DIST="dist"
;;
esac
PROTONPATH="${STEAMPATH}/steamapps/common/${PROTONVER}"
WINE="${PROTONPATH}/${FILES_OR_DIST}/bin/wine"
WINE64="${PROTONPATH}/${FILES_OR_DIST}/bin/wine64"
print_blue "Using $PROTONVER"
else
print_red "You need to select a value between 0 and 2, please try again"
choose_proton
fi
}
validate_rsasio_input() {
if [[ -z $1 || $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
return 0
else
return 1
fi
}
choose_rsasio() {
read -p "Override RS_ASIO Version [$(print_orange ${RSASIOVER})]: " USER_RSASIOVER
if validate_rsasio_input "$USER_RSASIOVER"; then
RSASIOVER=${USER_RSASIOVER:-$RSASIOVER}
print_blue "Using $RSASIOVER"
else
print_red "The value is not in the correct format: x.y.z"
choose_rsasio
fi
}
greet() {
print_blue "======== Rocksmith 2014 - Wineasio patcher for NixOS ========"
choose_proton
choose_rsasio
}
print_system_info() {
print_blue "======== System Info "========
echo "NixOS $(nixos-version) [$(getconf LONG_BIT)-bit]"
echo "Kernel $(uname -r)"
echo "Wine $("${WINE}" --version)"
echo "Wine64 $("${WINE64}" --version)"
echo "RS_ASIO (Desired) ${RSASIOVER}"
echo "Proton (Desired) ${PROTONVER}"
}
check_installed() {
if which $1 >/dev/null 2>&1; then
echo "$1 $(print_green present)"
else
print_red "Required $1 is not installed!"
exit 1
fi
}
check_and_prepare() {
print_blue "======== Check and prepare "========
check_passed=true
CHECKPATHS=(
"$WINEPREFIX"
"$WINEASIOPATH"
"$STEAMPATH"
"$PROTONPATH"
"/lib/wine"
"${STEAMPATH}/steamapps/compatdata/221680"
"${STEAMPATH}/steamapps/compatdata/221680/pfx/"
)
CHECKFILES=(
"$WINE"
"$WINE64"
"/lib/libjack.so"
)
CHECKPROGRAMS=(
"steam"
"steam-run"
"pipewire"
)
echo "=== Paths ==="
for path in "${CHECKPATHS[@]}"; do
if [ ! -d "${path}" ]; then
echo "Directory ${path} ... $(print_red "NOT found!")"
check_passed=false
else
echo "Directory ${path} ... $(print_green OK)"
fi
done
echo "=== Files ==="
for file in "${CHECKFILES[@]}"; do
if [ ! -f "${file}" ]; then
echo "File ${file} ... $(print_red "NOT found!")"
check_passed=false
else
echo "File ${file} ... $(print_green OK)"
fi
done
for dll in "${WINEASIODLLS[@]}"; do
if [ ! -f "${WINEASIOPATH}${dll}" ]; then
echo "File ${dll} ... $(print_red NOT found!)"
check_passed=false
else
echo "File ${dll} ... $(print_green OK)"
fi
done
for program in "${CHECKPROGRAMS[@]}"; do
check_installed $program
done
if [ "$check_passed" = false ]; then
print_red "A check failed. Exiting the program."
exit 1
fi
read -p "This script will add wineasio to proton and Rocksmith, register it and install RS_ASIO. Do you want to continue? (Y/N): " user_input
user_input=$(echo "$user_input" | tr '[:lower:]' '[:upper:]')
if [ "$user_input" != "Y" ]; then
print_red "Exiting..."
exit 0
fi
}
register_dll() {
echo "[Wineasio] Registering ${1}"
"${2}" regsvr32 "${1}" > /dev/null 2>&1
}
safe_copy() {
echo "[COPY FILE] $1 -> $2"
rm -rf "$2"
cp "$1" "$2"
}
patch_wineasio_32bit() {
echo "[Wineasio] Applying Patch for 32-bit"
safe_copy "${WINEASIOPATH}${1}" "${PROTONPATH}/${FILES_OR_DIST}/lib/wine${1}"
if [[ $1 == *.so ]]; then
local wineasio_dll=$(echo ${WINEASIOPATH}${1} | sed -e 's|/i386-unix/wineasio32.dll.so|/i386-windows/wineasio32.dll|g')
if [ -e "${WINEASIOPATH}${1}" ] && [ -e "${wineasio_dll}" ]; then
echo "[Wineasio 32-bit] Copying ${wineasio_dll} in ${WINEPREFIX}/drive_c/windows/syswow64/wineasio32.dll"
safe_copy "${wineasio_dll}" "${WINEPREFIX}/drive_c/windows/syswow64/wineasio32.dll"
register_dll "$wineasio_dll" "$WINE"
fi
fi
}
patch_wineasio_64bit() {
echo "[Wineasio] Applying Patch for 64-bit"
safe_copy "${WINEASIOPATH}${1}" "${PROTONPATH}/${FILES_OR_DIST}/lib64/wine${1}"
if [[ $1 == *.so ]]; then
if [ ! -d "${WINEPREFIX}/drive_c/windows/syswow64" ]; then
echo "[Wineasio] Skipping $1 because ${WINEPREFIX} is not a 64-bit system"
continue
fi
local wineasio_dll=$(echo ${WINEASIOPATH}${1} | sed -e 's|/x86_64-unix/wineasio64.dll.so|/x86_64-windows/wineasio64.dll|g')
if [ -e "${WINEASIOPATH}${1}" ] && [ -e "${wineasio_dll}" ]; then
echo "[Wineasio 64-bit] Copying ${wineasio_dll} in ${WINEPREFIX}/drive_c/windows/system32/wineasio64.dll"
safe_copy "${wineasio_dll}" "${WINEPREFIX}/drive_c/windows/system32/wineasio64.dll"
register_dll "$wineasio_dll" "$WINE64"
fi
fi
}
patch_wineasio() {
print_blue "======== Wineasio ========"
echo "[Wineasio] Install Wineasio"
for dll in "${WINEASIODLLS[@]}"; do
if echo "$dll" | grep -q "32"; then
patch_wineasio_32bit "$dll"
elif echo "$dll" | grep -q "64"; then
patch_wineasio_64bit "$dll"
else
echo "$dll doesn't contain 32 or 64 in its name. Can't choose if 32 or 64 bit."
fi
done
}
patch_rs_asio() {
print_blue "======== RS_ASIO ========"
echo "[RS_ASIO] Dowload RS_ASIO"
if [ ! -f "release-${RSASIOVER}.zip" ]; then
wget https://github.com/mdias/rs_asio/releases/download/v${RSASIOVER}/release-${RSASIOVER}.zip > /dev/null 2>&1
fi
echo "[RS_ASIO] Unzip"
unzip release-${RSASIOVER}.zip -d RS_ASIO
sed -i 's/Driver=[^ ]*/Driver=wineasio-rsasio/g' "RS_ASIO/RS_ASIO.ini"
echo "[RS_ASIO] Copying RS_ASIO to Rocksmith installation"
cp -a "RS_ASIO/"* "${STEAMPATH}/steamapps/common/Rocksmith2014/"
}
finalise() {
print_blue "======== DONE ========"
echo "Patch applied, you can now configure Rocksmith"
echo "First, check that the RS_ASIO.ini file is correct"
echo
echo "Finally, add the following launch option to Rocksmith on steam"
echo
echo "================================================================"
echo $LAUNCH_OPTIONS
echo "================================================================"
}
################### Execute ###################
greet
print_system_info
check_and_prepare
patch_wineasio
patch_rs_asio
finalise