-
Notifications
You must be signed in to change notification settings - Fork 1
/
mosaic_installer.sh
executable file
·451 lines (397 loc) · 15.4 KB
/
mosaic_installer.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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#!/bin/bash
###############################################################################
# ----------------------------------------------------------
# Mosaic | OF Visual Patching Developer Platform
#
# Copyright (c) 2020 Emanuele Mazza aka n3m3da
#
# Mosaic is distributed under the MIT License. This gives everyone the
# freedoms to use Mosaic in any context: commercial or non-commercial,
# public or private, open or closed source.
#
# See https://github.com/d3cod3/Mosaic for documentation
# ----------------------------------------------------------
#
#
# Mosaic auto compile/install script for multi linux boxes
#
# Supported for now: Ubuntu, Ubuntu Studio, Linux Mint, Debian, Arch Linux, Fedora
#
###############################################################################
# exit when any command fails
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo "\"${last_command}\" command failed with exit code $?."
start_message() {
echo ""
echo ""
echo " __ __ ______ ______ ______ __ ______ "
echo "/\ '-./ \ /\ __ \ /\ ___\ /\ __ \ /\ \ /\ ___\ "
echo "\ \ \-./\ \ \ \ \/\ \ \ \___ \ \ \ __ \ \ \ \ \ \ \____ "
echo " \ \_\ \ \_\ \ \_____\ \/\_____\ \ \_\ \_\ \ \_\ \ \_____\ "
echo " \/_/ \/_/ \/_____/ \/_____/ \/_/\/_/ \/_/ \/_____/"
echo ""
echo ""
echo " __ __ __ ______ ______ ______ __ __ ______ ______ "
echo "/\ \ /\ '-.\ \ /\ ___\ /\__ _\ /\ __ \ /\ \ /\ \ /\ ___\ /\ == \ "
echo "\ \ \ \ \ \-. \ \ \___ \ \/_/\ \/ \ \ __ \ \ \ \____ \ \ \____ \ \ __\ \ \ __< "
echo " \ \_\ \ \_\\''\_\ \/\_____\ \ \_\ \ \_\ \_\ \ \_____\ \ \_____\ \ \_____\ \ \_\ \_\ "
echo " \/_/ \/_/ \/_/ \/_____/ \/_/ \/_/\/_/ \/_____/ \/_____/ \/_____/ \/_/ /_/ "
echo ""
echo ""
}
###############################################################################
# Check if running with sudo
if [ $(id -u) != 0 ]; then
echo -e "\nMosaic installer script must be run with super-user privileges."
echo -e "\nUsage:\nsudo "$0"\n"
exit $exit_code
exit 1
fi
###############################################################################
# VARS
USERHOME="$( echo ~ )"
MOSAICDESKTOPFILE=Mosaic.desktop
LOCALUSERNAME="$( who | awk '{print $1}' )"
INSTALLFOLDER=/opt
OFFOLDERNAME=openFrameworks
# HARDCODED OPENFRAMEWORKS RELEASE, using 0.11.0
OFRELURL=https://openframeworks.cc/versions/v0.11.0/of_v0.11.0_linux64gcc6_release.tar.gz
OFRELFILENAME=of_v0.11.0_linux64gcc6_release.tar.gz
OFRELORIGINALNAME=of_v0.11.0_linux64gcc6_release
NPROC="$( nproc )"
NUMPU="1"
if [ $NPROC -gt "1" ]; then
NUMPU="$( expr $NPROC / 2 )"
else
NUMPU="1"
fi
LINUX_DISTRO=""
###############################################################################
# 0 - print installer start_message
start_message
# 1 - Get linux distro
echo "Select your linux distro ************"
echo ""
echo " 1)Ubuntu"
echo " 2)Linux Mint"
echo " 3)Debian"
echo " 4)Arch Linux"
echo " 5)Fedora"
echo ""
echo "[1/2/3/4/5]: "
read n
case $n in
1) LINUX_DISTRO="Ubuntu";;
2) LINUX_DISTRO="Linux Mint";;
3) LINUX_DISTRO="Debian";;
4) LINUX_DISTRO="Arch Linux";;
5) LINUX_DISTRO="Fedora";;
*) echo "Invalid option. Try another one.";;
esac
if [ "$LINUX_DISTRO" == "" ]; then
exit 0
fi
echo -e "\nInstalling Mosaic for "$LINUX_DISTRO"\n"
# 2 - Install dependencies
if [ "$LINUX_DISTRO" == "Ubuntu" ]; then
apt update
apt install git curl ffmpeg wget libpython3.8-dev libsnappy-dev libswresample-dev libavcodec-dev libavformat-dev libdispatch-dev
elif [ "$LINUX_DISTRO" == "Linux Mint" ]; then
apt update
apt install git curl ffmpeg wget libpython3.8-dev libsnappy-dev libswresample-dev libavcodec-dev libavformat-dev libdispatch-dev
elif [ "$LINUX_DISTRO" == "Debian" ]; then
apt update
apt install git curl ffmpeg wget libpython3.8-dev rsync libsnappy-dev libswresample-dev libavcodec-dev libavformat-dev libdispatch-dev
elif [ "$LINUX_DISTRO" == "Arch Linux" ]; then
pacman -Syu
pacman -Syu base-devel python python2 git curl ffmpeg wget rsync snappy nano
elif [ "$LINUX_DISTRO" == "Fedora" ]; then
dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf update
dnf install nano make git curl ffmpeg wget python3-libs python3-devel
fi
MOSAICVERSION="$( curl https://raw.githubusercontent.com/d3cod3/Mosaic/master/bin/data/release.txt )"
# 3 - Download and Install openFrameworks
cd $INSTALLFOLDER
if [ ! -d $OFFOLDERNAME ]; then
# download OF
echo -e "\nDownloading openFrameworks version: "$OFRELORIGINALNAME
wget $OFRELURL
tar -xvzf $OFRELFILENAME
mv $OFRELORIGINALNAME/ $OFFOLDERNAME/
rm -f $OFRELFILENAME
# install OF dependencies
echo -e "\nInstalling openFrameworks dependencies"
if [ "$LINUX_DISTRO" == "Ubuntu" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/ubuntu
elif [ "$LINUX_DISTRO" == "Linux Mint" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/ubuntu
elif [ "$LINUX_DISTRO" == "Debian" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/debian
DEBIAN_VERSION="$( cat /etc/debian_version | cut -d . -f 1 )"
if [ $DEBIAN_VERSION == "10" ]; then
sed -i 's/libgles1-mesa-dev/libglvnd-dev/' install_dependencies.sh
fi
elif [ "$LINUX_DISTRO" == "Arch Linux" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/archlinux
sed -e 's.$ROOT/..g' -i install_dependencies.sh
elif [ "$LINUX_DISTRO" == "Fedora" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/fedora
fi
./install_dependencies.sh -y
./install_codecs.sh
# small compile fixes
cd $INSTALLFOLDER/$OFFOLDERNAME/libs/openFrameworks/utils
sed -e '/GL\/glext.h/ s/^#*/\/\//' -i ofConstants.h
if [ "$LINUX_DISTRO" == "Arch Linux" ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/libs/openFrameworks/sound
wget -O openal_fix.patch https://aur.archlinux.org/cgit/aur.git/plain/openal_fix.patch?h=openframeworks
patch ofOpenALSoundPlayer.h < openal_fix.patch
rm -f openal_fix.patch
cd $INSTALLFOLDER/$OFFOLDERNAME/libs/openFrameworksCompiled/project/makefileCommon
wget -O make_4.3_error_fix.patch https://aur.archlinux.org/cgit/aur.git/plain/make_4.3_error_fix.patch?h=openframeworks
patch config.addons.mk < make_4.3_error_fix.patch
rm make_4.3_error_fix.patch
fi
# compile OF
echo -e "\nCompiling openFrameworks..."
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux
./compileOF.sh -j$NUMPU
fi
# 4 - Fix python symbolic link for compiling
if [ "$LINUX_DISTRO" == "Fedora" ]; then
if [ ! -e /usr/lib64/pkgconfig/python3.pc ]; then
ln -s /usr/lib64/pkgconfig/python-3.8.pc /usr/lib64/pkgconfig/python3.pc
fi
else
if [ ! -e /usr/lib/x86_64-linux-gnu/pkgconfig/python3.pc ]; then
ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/python-3.8.pc /usr/lib/x86_64-linux-gnu/pkgconfig/python3.pc
fi
fi
# 5 - Install ofxaddons dependencies
cd $INSTALLFOLDER/$OFFOLDERNAME/addons
if [ -d ofxAudioAnalyzer ]; then
echo -e "\nUpdating ofxAudioAnalyzer addon..."
cd ofxAudioAnalyzer && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxAudioAnalyzer addon..."
git clone --branch=master https://github.com/d3cod3/ofxAudioAnalyzer
fi
if [ -d ofxAudioFile ]; then
echo -e "\nUpdating ofxAudioFile addon..."
cd ofxAudioFile && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxAudioFile addon..."
git clone --branch=master https://github.com/npisanti/ofxAudioFile
fi
if [ -d ofxBTrack ]; then
echo -e "\nUpdating ofxBTrack addon..."
cd ofxBTrack && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxBTrack addon..."
git clone --branch=master https://github.com/d3cod3/ofxBTrack
fi
if [ -d ofxChromaKeyShader ]; then
echo -e "\nUpdating ofxChromaKeyShader addon..."
cd ofxChromaKeyShader && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxChromaKeyShader addon..."
git clone --branch=master https://github.com/d3cod3/ofxChromaKeyShader
fi
if [ -d ofxCv ]; then
echo -e "\nUpdating ofxCv addon..."
cd ofxCv && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxCv addon..."
git clone --branch=master https://github.com/kylemcdonald/ofxCv
fi
if [ -d ofxEasing ]; then
echo -e "\nUpdating ofxEasing addon..."
cd ofxEasing && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxEasing addon..."
git clone --branch=master https://github.com/arturoc/ofxEasing
fi
if [ -d ofxFFmpegRecorder ]; then
echo -e "\nUpdating ofxFFmpegRecorder addon..."
cd ofxFFmpegRecorder && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxFFmpegRecorder addon..."
git clone --branch=master https://github.com/d3cod3/ofxFFmpegRecorder
fi
if [ -d ofxFontStash ]; then
echo -e "\nUpdating ofxFontStash addon..."
cd ofxFontStash && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxFontStash addon..."
git clone --branch=master https://github.com/d3cod3/ofxFontStash
fi
if [ -d ofxGLEditor ]; then
echo -e "\nUpdating ofxGLEditor addon..."
cd ofxGLEditor && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxGLEditor addon..."
git clone --branch=master https://github.com/Akira-Hayasaka/ofxGLEditor
fi
if [ -d ofxJSON ]; then
echo -e "\nUpdating ofxJSON addon..."
cd ofxJSON && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxJSON addon..."
git clone --branch=master https://github.com/jeffcrouse/ofxJSON
fi
if [ -d ofxImGui ]; then
echo -e "\nUpdating ofxImGui addon..."
cd ofxImGui && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxImGui addon..."
git clone --branch=master https://github.com/d3cod3/ofxImGui
fi
if [ -d ofxInfiniteCanvas ]; then
echo -e "\nUpdating ofxInfiniteCanvas addon..."
cd ofxInfiniteCanvas && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxInfiniteCanvas addon..."
git clone --branch=master https://github.com/d3cod3/ofxInfiniteCanvas
fi
if [ -d ofxLua ]; then
echo -e "\nUpdating ofxLua addon..."
cd ofxLua && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxLua addon..."
git clone --branch=of-0.10.0 https://github.com/d3cod3/ofxLua
fi
if [ -d ofxMidi ]; then
echo -e "\nUpdating ofxMidi addon..."
cd ofxMidi && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxMidi addon..."
git clone --branch=master https://github.com/danomatika/ofxMidi
fi
if [ -d ofxMtlMapping2D ]; then
echo -e "\nUpdating ofxMtlMapping2D addon..."
cd ofxMtlMapping2D && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxMtlMapping2D addon..."
git clone --branch=master https://github.com/d3cod3/ofxMtlMapping2D
fi
if [ -d ofxNDI ]; then
echo -e "\nUpdating ofxNDI addon..."
cd ofxNDI && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxNDI addon..."
git clone --branch=master https://github.com/d3cod3/ofxNDI
fi
if [ -d ofxPd ]; then
echo -e "\nUpdating ofxPd addon..."
cd ofxPd && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxAudofxPdioAnalyzer addon..."
git clone --branch=master https://github.com/danomatika/ofxPd
fi
if [ -d ofxPdExternals ]; then
echo -e "\nUpdating ofxPdExternals addon..."
cd ofxPdExternals && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxPdExternals addon..."
git clone --branch=master https://github.com/d3cod3/ofxPdExternals
fi
if [ -d ofxPDSP ]; then
echo -e "\nUpdating ofxPDSP addon..."
cd ofxPDSP && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxPDSP addon..."
git clone --branch=master https://github.com/npisanti/ofxPDSP
fi
if [ -d ofxPython ]; then
echo -e "\nUpdating ofxPython addon..."
cd ofxPython && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxPython addon..."
git clone --branch=master https://github.com/d3cod3/ofxPython
fi
if [ -d ofxTimeline ]; then
echo -e "\nUpdating ofxTimeline addon..."
cd ofxTimeline && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxTimeline addon..."
git clone --branch=master https://github.com/d3cod3/ofxTimeline
fi
if [ -d ofxVisualProgramming ]; then
echo -e "\nUpdating ofxVisualProgramming addon..."
cd ofxVisualProgramming && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxVisualProgramming addon..."
git clone --branch=master https://github.com/d3cod3/ofxVisualProgramming
fi
if [ -d ofxWarp ]; then
echo -e "\nUpdating ofxWarp addon..."
cd ofxWarp && git checkout -- . && git pull && cd ..
else
echo -e "\nCloning ofxWarp addon..."
git clone --branch=master https://github.com/d3cod3/ofxWarp
fi
# 6 - Compile fftw3.3.2 library from source and install
if [ ! -e $INSTALLFOLDER/$OFFOLDERNAME/addons/ofxAudioAnalyzer/libs/fftw3f/lib/linux64/libfftw3f.a ]; then
cd $INSTALLFOLDER
git clone --branch=master https://github.com/d3cod3/fftw3.3.2-source
cd fftw3.3.2-source
./configure --prefix=`pwd` --enable-float --enable-sse2 --with-incoming-stack-boundary=2 --with-our-malloc16 --disable-shared --enable-static
make MAKEINFO=true -j$NUMPU
cd .libs
mkdir $INSTALLFOLDER/$OFFOLDERNAME/addons/ofxAudioAnalyzer/libs/fftw3f/lib/linux64
cp libfftw3f.a $INSTALLFOLDER/$OFFOLDERNAME/addons/ofxAudioAnalyzer/libs/fftw3f/lib/linux64/
cd $INSTALLFOLDER
rm -rf fftw3.3.2-source/
fi
# 7 - Copy libndi
if [ ! -e /usr/lib/libndi.so.3.7.1 ]; then
echo -e "\nCopying libndi to /usr/lib"
cd $INSTALLFOLDER
cp $OFFOLDERNAME/addons/ofxNDI/libs/libndi/lib/x86_64-linux-gnu/libndi.so.3.7.1 /usr/lib
ln -s /usr/lib/libndi.so.3.7.1 /usr/lib/libndi.so.3
fi
# 8 - Clone and compile Mosaic
cd $INSTALLFOLDER
cd $OFFOLDERNAME/apps
if [ -d d3cod3 ]; then
cd d3cod3
rm -rf Mosaic
git clone --recursive --branch=master https://github.com/d3cod3/Mosaic
cd Mosaic
make -j$NUMPU Release
else
mkdir d3cod3
cd d3cod3
git clone --recursive --branch=master https://github.com/d3cod3/Mosaic
cd Mosaic
make -j$NUMPU Release
fi
# 9 - Create a Mosaic.desktop file for desktop launchers
if [ ! -e /usr/share/applications/$MOSAICDESKTOPFILE ]; then
cd $INSTALLFOLDER/$OFFOLDERNAME/apps/d3cod3/Mosaic/bin
echo "[Desktop Entry]" > $MOSAICDESKTOPFILE
echo "Encoding=UTF-8" >> $MOSAICDESKTOPFILE
echo "Version="$MOSAICVERSION >> $MOSAICDESKTOPFILE
echo "Name=Mosaic" >> $MOSAICDESKTOPFILE
echo "Type=Application" >> $MOSAICDESKTOPFILE
echo "Terminal=false" >> $MOSAICDESKTOPFILE
echo "Exec=$INSTALLFOLDER/$OFFOLDERNAME/apps/d3cod3/Mosaic/bin/Mosaic" >> $MOSAICDESKTOPFILE
echo "Icon=$INSTALLFOLDER/$OFFOLDERNAME/apps/d3cod3/Mosaic/bin/data/images/logo_128.png" >> $MOSAICDESKTOPFILE
echo "Categories=AudioVideo;Audio;Development" >> $MOSAICDESKTOPFILE
echo "Comment=Live Visual Patching Creative-Coding Platform" >> $MOSAICDESKTOPFILE
cp $MOSAICDESKTOPFILE /usr/share/applications
fi
# 10 - Change the ownership of the entire openFrameworks folder to local user
cd $INSTALLFOLDER
chown $LOCALUSERNAME:$LOCALUSERNAME -R $OFFOLDERNAME/
# 11 - Create Mosaic Example folder in ~/Documents
mkdir -p $USERHOME/Documents/Mosaic
cp -R $INSTALLFOLDER/$OFFOLDERNAME/apps/d3cod3/Mosaic/bin/examples $USERHOME/Documents/Mosaic
# 12 - Mosaic installed message
echo -e "\nMosaic $MOSAICVERSION installed and ready to use."
echo -e "\nYou will find it in your applications menu."
exit 0