-
Notifications
You must be signed in to change notification settings - Fork 21
/
setup
executable file
·296 lines (267 loc) · 12.7 KB
/
setup
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
#!/bin/sh
# --- Stops the script if errors are encountered. ---
set -e
# ---
#
if [ -f "./setup" ] && [ -z "${IN_NIX_SHELL++}" ]; then
echo "You are running a hosted copy of the script. Please *delete the local file 'setup'* and run"
echo ""
echo "sh -c \"\$(curl -Ls https://github.com/FasterMelee/FasterMelee-installer/raw/master/setup)"
echo ""
echo "to ensure you have the latest version!"
exit
fi
# --- Attempts to determine the number of cores in the CPU. ---
# Source: https://gist.github.com/jj1bdx/5746298
# Linux and similar...
CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
# FreeBSD and similar...
[ -z "$CPUS" ] && CPUS=$(getconf NPROCESSORS_ONLN)
# Solaris and similar...
[ -z "$CPUS" ] && CPUS=$(ksh93 -c 'getconf NPROCESSORS_ONLN')
# Give up...
[ -z "$CPUS" ] && CPUS=1
# ---
# --- define custom config links here!
FMVERSION="" # name of FM version, used in folder name
COMMITHASH="" # full commit hash
GITCLONELINK="" # Version of Ishiiruka
CONFIGLINK="" # Packed configs, can be found under config/ or config/legacy/
# ---
# --- delete all "FasterMelee" folders filled with incomplete installations
echo ""
echo "Attempting to delete incomplete installations of FM..."
for f in FasterMelee*; do
if [ -d "${f}" ] && [ ! -d "$f/bin" ]; then
echo "Found incomplete installation at $f/, deleting."
rm -rf "$f" # is incomplete if bin/ doesn't exist
fi
done
# ---
# --- ask if you want to delete all remaining FM* folders
echo ""
echo "Would you like to overwrite ALL of your previous installations? (y/N)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ]; then
echo "Are you sure? This action is not reversible! (y/N)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ] ; then
rm -rf FasterMelee*/
echo "Deleted all FM folders!"
fi
else
echo "No changes made!"
fi
# ---
# --- if custom links aren't defined, prompt to choose a version
if [ -z "$FMVERSION" ] || [ -z "$COMMITHASH" ] || [ -z "$GITCLONELINK" ] || [ -z "$CONFIGLINK" ]; then #ORs used to ensure everything filled out
echo ""
echo "Which version of Faster Melee would you like to install? (default: 1)"
echo "1.) 5.9 (Latest version)"
echo "2.) 5.8.7 (Latest PM version)"
read -r RESP
if [ "$RESP" -eq 2 ] 2> /dev/null; then
FMVERSION="5.8.7"
COMMITHASH="98ebbc166beee649bd23066ce91ba1d88e73861c"
CONFIGLINK="https://github.com/FasterMelee/FasterMelee-installer/raw/master/config/legacy/$FMVERSION-fmconfig.tar.gz"
else
FMVERSION="5.9"
COMMITHASH="4ecca10c2dc2f4cd33c5cfaed3cbb5a63142a709"
CONFIGLINK="https://github.com/FasterMelee/FasterMelee-installer/raw/master/config/$FMVERSION-fmconfig.tar.gz"
fi
GITCLONELINK="https://github.com/FasterMelee/Ishiiruka"
echo "Installing version $FMVERSION!"
else
echo ""
echo "Attempting to install version $FMVERSION!"
fi
# ---
# --- check for previously installed version, ask if overwrite is wanted
FOLDERNAME="FasterMelee-${FMVERSION}"
if [ -d "$FOLDERNAME" ]; then
echo "
FM Folder with same version found! Would you like to overwrite? (y/N)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ]; then
echo "Are you sure? This action is not reversible! (y/N)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ] ; then
rm -r "$FOLDERNAME"
echo "Deleted!"
else
echo "Quitting!"
exit
fi
else
echo "Quitting!"
exit
fi
fi
# ---
# --- prompt to install adapter support
echo "
Would you like to install udev rules for your Wii U adapter? (y/N) (Necessary for reduced-lag direct adapter connection)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ]; then
if [ ! -z "${IN_NIX_SHELL++}" ]; then
echo "please add services.udev.extraRules = ''"
echo 'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0337", MODE="0666";'
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2300", SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1", ENV{ID_MM_CANDIDATE}:="0";'
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2301", SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1", ENV{ID_MM_CANDIDATE}:="0";'
echo "'';"
else
sudo rm -f /etc/udev/rules.d/51-gcadapter.rules # remove even if doesn't exist
echo 'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0337", MODE="0666"' | sudo tee /etc/udev/rules.d/51-gcadapter.rules > /dev/null # pipe to write-protected file, remove STDOUT
sudo udevadm control --reload-rules
echo "Rules added!"
fi
else
echo "No changes made!"
fi
# ---
# --- prompt to queue shortcut creation for later
echo "
Would you like to make a desktop shortcut? (Y/n)"
read -r RESP
if [ ! "$RESP" = "n" ] && [ ! "$RESP" = "N" ]; then
SHORTCUTBOOL=1
echo "Desktop shortcut queued!"
else
SHORTCUTBOOL=0
echo "No changes made!"
fi
# ---
# --- prompt for -j flag (# of cores utilized)
echo ""
echo "CPU Threads detected: $CPUS"
echo "How many threads would you like to use to compile? (passed to make as -j flag, default: 1, range: 1 - $(( CPUS + 1 )))"
read -r RESP
if [ "$RESP" -ge 1 ] 2> /dev/null && [ "$RESP" -le $((CPUS + 1)) ] 2> /dev/null; then
CPUS=$RESP
else
CPUS=1
fi
echo "Using $CPUS thread(s)!"
# ---
# --- enter folder, download and extract needed files
echo ""
mkdir "$FOLDERNAME" && cd "$FOLDERNAME"
echo "Downloading config files..."
curl -LO# $CONFIGLINK
echo "Extracting config files..."
tar -xzf "$FMVERSION-fmconfig.tar.gz" --checkpoint-action='exec=printf "%d/410 records extracted.\r" $TAR_CHECKPOINT' --totals
rm "$FMVERSION-fmconfig.tar.gz"
echo ""
echo "Downloading tarball..."
curl -LO# "$GITCLONELINK/archive/$COMMITHASH.tar.gz"
echo "Extracting tarball..."
tar -xzf "$COMMITHASH.tar.gz" --checkpoint-action='exec=printf "%d/12130 records extracted.\r" $TAR_CHECKPOINT' --totals
rm "$COMMITHASH.tar.gz"
echo "" #spacing
mv "Ishiiruka-$COMMITHASH" Ishiiruka
cd Ishiiruka
# ---
# --- Dirty patch for https://bugs.dolphin-emu.org/issues/11047
echo "Patching xgetbv function..."
sed -i "s|#include <cstring>|#include <cstring>\n#define _XSAVEINTRIN_H_INCLUDED|g" Source/Core/Common/x64CPUDetect.cpp # issue 1
# sed -i "s|check_and_add_flag(CXX17 -std=c++17)|#check_and_add_flag(CXX17 -std=c++17)" # issue 2 not present
# ---
# --- Patch for https://github.com/FasterMelee/Ishiiruka/pull/4/commits/8d161226ab915be09c951957505da61c217b1b1b
echo "Patching FileUtil.cpp..."
sed -i "s|#include <fcntl.h>|#include <fcntl.h>\n#include <fstream>|g" Source/Core/Common/FileUtil.cpp # add in include
sed -i '/\/\/ copies file srcFilename to destFilename, returns true on success/d' Source/Core/Common/FileUtil.cpp # update variable names
sed -i "s|bool Copy(const std::string& srcFilename, const std::string& destFilename)|\/\/ copies file source_path to destination_path, returns true on success\nbool Copy(const std::string\& source_path, const std::string\& destination_path)|g" Source/Core/Common/FileUtil.cpp # update variable names
sed -i 's|INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str());|INFO_LOG(COMMON, "Copy: %s --> %s", source_path.c_str(), destination_path.c_str());|g' Source/Core/Common/FileUtil.cpp # update variable names
sed -i "s|if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE))|if (CopyFile(UTF8ToTStr(source_path).c_str(), UTF8ToTStr(destination_path).c_str(), FALSE))|g" Source/Core/Common/FileUtil.cpp # update variable names
sed -i 's|ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(),|ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", source_path.c_str(), destination_path.c_str(),|g' Source/Core/Common/FileUtil.cpp # update variable names
sed -i "315,361d" Source/Core/Common/FileUtil.cpp # remove old copy method
sed -i "314istd::ifstream source{source_path, std::ios::binary};\nstd::ofstream destination{destination_path, std::ios::binary};\ndestination << source.rdbuf();\nreturn source.good() && destination.good();" Source/Core/Common/FileUtil.cpp # add new copy method
# ---
# --- Patch WxUtils regarding https://github.com/FasterMelee/FasterMelee-installer/issues/58
echo "Patching WxUtils.cpp..."
sed -i "s|screen_geometry = wxDisplay(0).GetClientArea();|screen_geometry = wxDisplay((unsigned int) 0).GetClientArea();|g" Source/Core/DolphinWX/WxUtils.cpp # avoid ambiguous overloaded function call
sed -i 's|default_size.SetDefaults(wxDisplay(0).GetClientArea().GetSize() / 2);|default_size.SetDefaults(wxDisplay((unsigned int) 0).GetClientArea().GetSize() / 2);|g' Source/Core/DolphinWX/WxUtils.cpp # avoid ambiguous overloaded function call
# ---
if [ "$FMVERSION" = "5.8.7" ]; then
# --- Temporary patch for updated glibc
echo "Patching xlocale.h requirement..."
sed -i "s|#define wxUSE_XLOCALE 1|#define wxUSE_XLOCALE 0|g" Externals/wxWidgets3/wx/wxcocoa.h
sed -i "s|#define wxUSE_XLOCALE 1|#define wxUSE_XLOCALE 0|g" Externals/wxWidgets3/wx/wxgtk.h
# ---
# --- Patch for https://github.com/dolphin-emu/dolphin/pull/6603/files
echo "Patching AVIDump.cpp..."
sed -i "s|CODEC_FLAG_GLOBAL_HEADER|AV_CODEC_FLAG_GLOBAL_HEADER|g" Source/Core/VideoCommon/AVIDump.cpp # replace existing objects first
sed -i "s|#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1)|#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1)\n#define AV_CODEC_FLAG_GLOBAL_HEADER CODEC_FLAG_GLOBAL_HEADER|g" Source/Core/VideoCommon/AVIDump.cpp # add in define
# ---
# --- Patch tarball to display correct hash to other netplay clients
echo "Patching tarball..."
sed -i "s|\${GIT_EXECUTABLE} rev-parse HEAD|echo 6ababb9222fb8bb9723ae137e1263a27196fcd47|g" CMakeLists.txt # --set scm_rev_str everywhere to actual commit hash when downloaded
sed -i "s|\${GIT_EXECUTABLE} describe --always --long --dirty|echo FM v$FMVERSION BETA|g" CMakeLists.txt # ensures compatibility w/ netplay
sed -i "s|\${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD|echo HEAD|g" CMakeLists.txt
# ---
# --- Patch for SoundTouch
echo "Using static soundtouch from Externals..."
sed -i 's|message("Using shared soundtouch")|add_subdirectory(Externals/soundtouch)\n\tinclude_directories(Externals)|g' CMakeLists.txt #uses external soundtouch lib
# ---
else
# --- Patch tarball to display correct hash to other netplay clients
echo "Patching tarball..."
sed -i "s|\${GIT_EXECUTABLE} rev-parse HEAD|echo 4a36badb6ff3ed533c26b3b201e6d3673a2353a8|g" CMakeLists.txt # --set scm_rev_str everywhere to actual commit hash when downloaded
sed -i "s|\${GIT_EXECUTABLE} describe --always --long --dirty|echo FM v$FMVERSION BETA|g" CMakeLists.txt # ensures compatibility w/ netplay
sed -i "s|\${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD|echo HEAD|g" CMakeLists.txt
# ---
fi
# --- move necessary config files into the build folder
echo "Adding FM config files..."
mkdir build && cd build
mv ../../Binaries .
mv ../Data/dolphin-emu.png Binaries/
# ---
# --- cmake and compile
echo "cmaking..."
if [ ! -z "${IN_NIX_SHELL++}" ]; then
cmake .. -DLINUX_LOCAL_DEV=true -DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib}/lib/glib-2.0/include -DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2}/lib/gtk-2.0/include -DGTK2_INCLUDE_DIRS=${gtk2}/lib/gtk-2.0 -DENABLE_LTO=True
else
cmake .. -DLINUX_LOCAL_DEV=true
fi
echo "Compiling..."
make -j $CPUS -s
# ---
# --- Delete created files and old symlinks, isolate Binaries to their own folder
echo "Cleaning up..."
cd ../..
mv Ishiiruka/build/Binaries/ bin/
rm -rf Ishiiruka # -f required to remove git history
rm -f ../launch-faster-melee # -f required if shortcuts do not exist
rm -f ../launch-fm
# ---
# --- create symlink to newly compiled dolphin-emu. if queued, create shortcut.
echo "Creating shortcuts..."
ln -s "$FOLDERNAME/bin/dolphin-emu" ../launch-fm
if [ "$SHORTCUTBOOL" -eq 1 ] && [ -d ~/.local/share/applications ]; then
rm -f ~/.local/share/applications/faster-melee-$FMVERSION.desktop # remove old shortcut
rm -f ~/Desktop/faster-melee-$FMVERSION.desktop
touch ~/.local/share/applications/faster-melee-$FMVERSION.desktop # fixes very rare tee bug?
EXEPATH="$(pwd)/bin"
FMNAME="Faster Melee $FMVERSION"
echo "[Desktop Entry]
Type=Application
GenericName=Wii/GameCube Emulator
Comment=Ishiiruka fork for SSBM
Categories=Emulator;Game;
Icon=$EXEPATH/dolphin-emu.png
Version=$FMVERSION
Name=$FMNAME
Exec=$EXEPATH/dolphin-emu" | tee ~/.local/share/applications/faster-melee-$FMVERSION.desktop > /dev/null
cp ~/.local/share/applications/faster-melee-$FMVERSION.desktop ~/Desktop
chmod +x ~/Desktop/faster-melee-$FMVERSION.desktop
else
echo ".local folder not found, skipping desktop shortcut."
fi
# ---
echo ""
echo "***************************************************************************************************"
echo "Done! Run ./launch-fm to run the latest installed version!"
echo "Alternatively, go to Application > Games or your desktop and select the desired version."
echo "Make sure to unplug and replug your adapter before opening Dolphin if adapter rules were installed!"
echo "***************************************************************************************************"