-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup
executable file
·330 lines (299 loc) · 11.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/bin/sh
# --- Stops the script if errors are encountered. ---
set -e
# ---
#
# --- Based Off of/Ripped from https://github.com/FasterMelee/FasterMelee-installer/ Thank you Faster Melee Team!
# ---
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/Birdthulu/FPM-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!
FPPVERSION="" # name of FPP 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 "FasterProjectPlus" folders filled with incomplete installations
echo ""
echo "Attempting to delete incomplete installations of FPP..."
for f in FasterProjectPlus*; 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 FPP* 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 FasterProjectPlus*/
echo "Deleted all FPP folders!"
fi
else
echo "No changes made!"
fi
# ---
# --- ask if the user is on Ubuntu 20.04 or a derivative
echo ""
echo "Are you running Ubuntu 20.04 or downstream distribution? This applies a patch allowing the installer to work. (y/N)"
read -r RESP
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ]; then
echo "Applying patch!"
UBPATCH=1
else
echo "Will not apply patch."
UBPATCH=0
fi
# ---
# --- if custom links aren't defined, prompt to choose a version
if [ -z "$FPPVERSION" ] || [ -z "$COMMITHASH" ] || [ -z "$GITCLONELINK" ] || [ -z "$CONFIGLINK" ]; then #ORs used to ensure everything filled out
echo ""
echo "Which version of Faster Project Plus would you like to install? (default: 1)"
echo "1.) 2.2 (Latest version)"
echo "2.) 2.15"
read -r RESP
if [ "$RESP" -eq 2 ] 2> /dev/null; then
FPPVERSION="2.15"
CONFIGNAME="fppconfig"
COMMITHASH="d6800a124dbba118e297188900d07adfea661b87"
CONFIGLINK="https://github.com/Birdthulu/FPM-Installer/raw/master/config/$FPPVERSION-$CONFIGNAME.tar.gz"
GITCLONELINK="https://github.com/Birdthulu/Ishiiruka"
SdCardFileName="ProjectPlusSdCard215.tar.gz"
SdCardDlHash="0anckw4hrxlqn5i"
SdCardLink="http://www.mediafire.com/file/$SdCardDlHash/$SdCardFileName/file"
else
FPPVERSION="2.2"
CONFIGNAME="fppconfig"
COMMITHASH="4aa077433453fcd06d28b66a52f6f939c46254c9"
CONFIGLINK="https://github.com/Birdthulu/FPM-Installer/raw/master/config/$FPPVERSION-$CONFIGNAME.tar.gz"
GITCLONELINK="https://github.com/Birdthulu/Ishiiruka"
SdCardFileName="ProjectPlusSdCard22.tar.gz"
SdCardDlHash="m4lxtm1uu64odl7"
SdCardLink="http://www.mediafire.com/file/$SdCardDlHash/$SdCardFileName/file"
fi
echo "Installing version $FPPVERSION!"
else
echo ""
echo "Attempting to install version $FPPVERSION!"
fi
# Set FOLDERNAME based on FPP version
FOLDERNAME="FasterProjectPlus-${FPPVERSION}"
# --- check for previously installed version, ask if overwrite is wanted
if [ -d "$FOLDERNAME" ]; then
echo "
FPP 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: $CPUS, range: 1 - $(( CPUS )))"
read -r RESP
if [ "$RESP" -ge 1 ] 2> /dev/null && [ "$RESP" -le $((CPUS + 1)) ] 2> /dev/null; then
CPUS=$RESP
else
CPUS=$CPUS
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 "$FPPVERSION-$CONFIGNAME.tar.gz" --checkpoint-action='exec=printf "%d/410 records extracted.\r" $TAR_CHECKPOINT' --totals
rm "$FPPVERSION-$CONFIGNAME.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
# --- Patch tarball to display correct hash to other netplay clients
echo "Patching tarball..."
sed -i "s|\${GIT_EXECUTABLE} rev-parse HEAD|echo ${COMMITHASH}|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$FPPVERSION|g" CMakeLists.txt # ensures compatibility w/ netplay
sed -i "s|\${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD|echo HEAD|g" CMakeLists.txt
# ---
# --- Patch DiscExtractor.h
echo "Patching DiscExtractor.h"
sed -i "s|#include <optional>|#include <optional>\n#include <string>|g" Source/Core/DiscIO/DiscExtractor.h
# ---
# --- Patch wxWidgets3 for Ubuntu 20.04
if [ "$UBPATCH" -eq 1 ]; then
echo "Patching wxWidgets3 for Ubuntu 20.04 based distros"
sed -i "s| OR NOT X11_Xinerama_FOUND||g" Externals/wxWidgets3/CMakeLists.txt
sed -i "s|needs Xinerama and|needs|g" Externals/wxWidgets3/CMakeLists.txt
sed -i "s|\t\t\${X11_Xinerama_LIB}||g" Externals/wxWidgets3/CMakeLists.txt
else
echo "Skipping patch for Ubuntu 20.04 based distros"
fi
# ---
# --- move wx files into source
cp Externals/wxWidgets3/include/wx Source/Core/ -r
cp Externals/wxWidgets3/wx/* Source/Core/wx/
# ---
# --- move necessary config files into the build folder
echo "Adding FPP config files..."
mkdir build && cd build
mv ../../Binaries .
mv ../Data/ishiiruka.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 -DCMAKE_INSTALL_PREFIX=/usr
else
cmake .. -DLINUX_LOCAL_DEV=true -DCMAKE_INSTALL_PREFIX=/usr
fi
echo "Compiling..."
make -j $CPUS -s
# ---
# --- Download the sd card tarball, extract it, move it to proper folder, and delete tarball
# credit to https://superuser.com/a/1517096 superuser.com user Zibri
echo "Downloading sd card"
url=$(curl -Lqs0 "$SdCardLink" | grep "href.*download.*media.*"| grep "$SdCardFileName" | cut -d '"' -f 2)
echo "Attempting with Axel";
if [ -x "$(command -v axel)" ]; then
axel "$url" -a -n $CPUS;
elif [ -x "$(command -v aria2c)" ]; then
echo "Axel command failed, dependency may be missing, attempting with aria2c";
aria2c -x$CPUS "$url"
else
echo "Axel and Aria2c command failed, dependency may be missing, reverting to slowest way possible";
wget "$url"
fi
echo "Extracting sd card"
tar -xzf "$SdCardFileName" --checkpoint-action='exec=printf "%d/12130 records extracted.\r" $TAR_CHECKPOINT' --totals
mv "sd.raw" "Binaries/User/Wii/sd.raw"
rm "$SdCardFileName"
# ---
# --- 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-project-plus # -f required if shortcuts do not exist
rm -f ../launch-fpp
# # ---
# --- Get Main path and Set Up path variables for config/Dolphin.ini
echo "Setting config paths"
MainDir=$(pwd)"/bin"
LauncherDir="$MainDir/Launcher"
GamesDir="$MainDir/Games"
SDPath="$MainDir/User/Wii/sd.raw"
IsoPath="$GamesDir/RSBE01.iso"
ConfigPath="$MainDir/User/Config/Dolphin.ini"
# ---
# --- Set LauncherDir, GamesDir, SdCardPath, and Default ISO path in config/Dolphin.ini
sed -i -e "s|LauncherDir|$LauncherDir|" $ConfigPath
sed -i -e "s|GamesPath|$GamesDir|" $ConfigPath
sed -i -e "s|SDPath|$SDPath|" $ConfigPath
sed -i -e "s|ISODirPath|$IsoPath|" $ConfigPath
# ---
# --- create symlink to newly compiled dolphin-emu. if queued, create shortcut.
echo "Creating shortcuts..."
ln -s "$FOLDERNAME/bin/ishiiruka" ../launch-fpp
if [ "$SHORTCUTBOOL" -eq 1 ] && [ -d ~/.local/share/applications ]; then
rm -f ~/.local/share/applications/faster-project-plus-$FPPVERSION.desktop # remove old shortcut
rm -f ~/Desktop/faster-project-plus-$FPPVERSION.desktop
touch ~/.local/share/applications/faster-project-plus-$FPPVERSION.desktop # fixes very rare tee bug?
EXEPATH="$(pwd)/bin"
FPPNAME="Faster Project Plus $FPPVERSION"
echo "[Desktop Entry]
Type=Application
GenericName=Wii/GameCube Emulator
Comment=Ishiiruka fork for SSBPM
Categories=Emulator;Game;
Icon=$EXEPATH/ishiiruka.png
Keywords=ProjectM;Project M;ProjectPlus;Project Plus;Project+
Version=$FPPVERSION
Name=$FPPNAME
Exec=$EXEPATH/ishiiruka" | tee ~/.local/share/applications/faster-project-plus-$FPPVERSION.desktop > /dev/null
cp ~/.local/share/applications/faster-project-plus-$FPPVERSION.desktop ~/Desktop
chmod +x ~/Desktop/faster-project-plus-$FPPVERSION.desktop
else
echo ".local folder not found, skipping desktop shortcut."
fi
# ---
echo ""
echo "***************************************************************************************************"
echo "Done! Run ./launch-fpp 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 "***************************************************************************************************"
#