Last active
September 14, 2020 10:08
-
-
Save d3cod3/81b8971ebf5fc9a6d288ca93fc3c3dad to your computer and use it in GitHub Desktop.
Ubuntu automatic install for Mosaic (https://github.com/d3cod3/Mosaic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
# ---------------------------------------------------------- | |
# Mosaic | OF Visual Patching Developer Platform | |
# | |
# Copyright (c) 2019 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 ubuntu boxes | |
# | |
############################################################################### | |
# 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 an error message before exiting | |
trap 'echo "\"${last_command}\" command failed with exit code $?."' EXIT | |
# 0 - Check if running with sudo | |
if [ $(id -u) != 0 ]; then | |
echo "this script must be run using sudo" | |
echo "" | |
echo "usage:" | |
echo "sudo "$0 | |
exit $exit_code | |
exit 1 | |
fi | |
# 0/2 - init some vars | |
apt update | |
apt install git curl ffmpeg wget libpython2.7-dev libpython3.8-dev libsnappy-dev libswresample-dev libavcodec-dev libavformat-dev libdispatch-dev | |
#HAVEFFMPEG="$( which ffmpeg )" | |
#if [ -z "$HAVEFFMPEG" ]; then | |
# apt install ffmpeg | |
#fi | |
USERHOME="$( echo ~ )" | |
MOSAICDESKTOPFILE=Mosaic.desktop | |
MOSAICVERSION="$( curl https://raw.githubusercontent.com/d3cod3/Mosaic/master/bin/data/release.txt )" | |
LOCALUSERNAME="$( who | awk '{print $1}' )" | |
INSTALLFOLDER=/opt | |
OFFOLDERNAME=openFrameworks | |
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 | |
source /etc/os-release | |
if [ "$ID" = "elementary" ]; then | |
# Gets ubuntu base version | |
RELEASE=$(lsb_release -r -u) | |
else | |
RELEASE=$(lsb_release -r) | |
fi | |
MAJOR_VERSION=$(echo $RELEASE | cut -f2 -d: | cut -f1 -d. | sed "s/\t//g" | cut -c2-3) | |
MINOR_VERSION=$(echo $RELEASE | cut -f2 -d: | cut -f2 -d.) | |
echo "Running on ubuntu ${MAJOR_VERSION}.${MINOR_VERSION}" | |
# 1 - Install openFrameworks | |
cd $INSTALLFOLDER | |
if [ ! -d $OFFOLDERNAME ]; then | |
# download OF | |
wget $OFRELURL | |
tar -xvzf $OFRELFILENAME | |
mv $OFRELORIGINALNAME/ $OFFOLDERNAME/ | |
rm -f $OFRELFILENAME | |
# install OF dependencies | |
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux/ubuntu | |
./install_dependencies.sh -y | |
./install_codecs.sh | |
# small compile fixes, still needed? | |
cd $INSTALLFOLDER/$OFFOLDERNAME/libs/openFrameworks/utils | |
sed -e '/GL\/glext.h/ s/^#*/\/\//' -i ofConstants.h | |
# compile OF | |
cd $INSTALLFOLDER/$OFFOLDERNAME/scripts/linux | |
./compileOF.sh -j$NUMPU | |
fi | |
if [ ! -e /usr/lib/x86_64-linux-gnu/pkgconfig/python.pc ]; then | |
ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/python-2.7.pc /usr/lib/x86_64-linux-gnu/pkgconfig/python.pc | |
fi | |
# 2 - Install ofxaddons dependencies | |
cd $INSTALLFOLDER/$OFFOLDERNAME/addons | |
if [ -d ofxAudioAnalyzer ]; then | |
cd ofxAudioAnalyzer && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxAudioAnalyzer | |
fi | |
if [ -d ofxAudioFile ]; then | |
cd ofxAudioFile && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/npisanti/ofxAudioFile | |
fi | |
if [ -d ofxBTrack ]; then | |
cd ofxBTrack && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxBTrack | |
fi | |
if [ -d ofxChromaKeyShader ]; then | |
cd ofxChromaKeyShader && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxChromaKeyShader | |
fi | |
if [ -d ofxCv ]; then | |
cd ofxCv && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/kylemcdonald/ofxCv | |
fi | |
if [ -d ofxEasing ]; then | |
cd ofxEasing && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/arturoc/ofxEasing | |
fi | |
if [ -d ofxFFmpegRecorder ]; then | |
cd ofxFFmpegRecorder && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxFFmpegRecorder | |
fi | |
if [ -d ofxFontStash ]; then | |
cd ofxFontStash && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxFontStash | |
fi | |
if [ -d ofxGLEditor ]; then | |
cd ofxGLEditor && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxGLEditor | |
fi | |
if [ -d ofxJSON ]; then | |
cd ofxJSON && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/jeffcrouse/ofxJSON | |
fi | |
if [ -d ofxImGui ]; then | |
cd ofxImGui && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxImGui | |
fi | |
if [ -d ofxInfiniteCanvas ]; then | |
cd ofxInfiniteCanvas && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxInfiniteCanvas | |
fi | |
if [ -d ofxLua ]; then | |
cd ofxLua && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=of-0.10.0 https://github.com/d3cod3/ofxLua | |
fi | |
if [ -d ofxMidi ]; then | |
cd ofxMidi && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxMidi | |
fi | |
if [ -d ofxMtlMapping2D ]; then | |
cd ofxMtlMapping2D && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxMtlMapping2D | |
fi | |
if [ -d ofxNDI ]; then | |
cd ofxNDI && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxNDI | |
fi | |
if [ -d ofxPd ]; then | |
cd ofxPd && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/danomatika/ofxPd | |
fi | |
if [ -d ofxPdExternals ]; then | |
cd ofxPdExternals && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxPdExternals | |
fi | |
if [ -d ofxPDSP ]; then | |
cd ofxPDSP && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/npisanti/ofxPDSP | |
fi | |
if [ -d ofxPython ]; then | |
cd ofxPython && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=OF0.9.8 https://github.com/d3cod3/ofxPython | |
fi | |
if [ -d ofxTimeline ]; then | |
cd ofxTimeline && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxTimeline | |
fi | |
if [ -d ofxVisualProgramming ]; then | |
cd ofxVisualProgramming && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxVisualProgramming | |
fi | |
if [ -d ofxWarp ]; then | |
cd ofxWarp && git checkout -- . && git pull && cd .. | |
else | |
git clone --branch=master https://github.com/d3cod3/ofxWarp | |
fi | |
# 3 - 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 -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 | |
# 4 - Fix Poco issues on ubuntu >= 18.04 | |
if [[ $MAJOR_VERSION -gt 18 || $MAJOR_VERSION -eq 18 ]]; then | |
cd $INSTALLFOLDER | |
echo "detected ubuntu 18.04 or greater" | |
echo "fixing poco libs" | |
if [ "$(ls -A $OFFOLDERNAME/addons/ofxPoco/libs/poco/lib/linux64/)" ]; then | |
rm $OFFOLDERNAME/addons/ofxPoco/libs/poco/lib/linux64/* | |
fi | |
rm -rf $OFFOLDERNAME/addons/ofxPoco/libs/poco/include/Poco | |
cp -R /usr/include/Poco/ $OFFOLDERNAME/addons/ofxPoco/libs/poco/include/ | |
fi | |
# 4.1 - Copy libndi | |
if [ ! -e /usr/lib/libndi.so.3.7.1 ]; then | |
echo "copying 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 | |
# 5 - Compile/Install 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 | |
# 6 - 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 | |
# 7 - Change the ownership of the entire openFrameworks folder to local user | |
cd $INSTALLFOLDER | |
chown $LOCALUSERNAME:$LOCALUSERNAME -R $OFFOLDERNAME/ | |
# 8 - Create Mosaic Example folder in ~/Documents | |
mkdir -p $USERHOME/Documents/Mosaic | |
cp -R $INSTALLFOLDER/$OFFOLDERNAME/apps/d3cod3/Mosaic/bin/examples $USERHOME/Documents/Mosaic | |
# 9 - Mosaic installed message | |
echo "Mosaic $MOSAICVERSION installed and ready to use." | |
echo "You will find it in your applications menu." | |
exit 0 |
Hello! Do some one have experience with installing Mosaic in Ubuntu Mate on a Raspberry Pi 4 , any advice? Thank you
Sorry, but Mosaic is actually impossible to compile on ARM6 or ARM7 processors
Hi dabulina, just fixed the errors and updated the gist (this one), please delete the previous install:
sudo rm -rf /opt/openFrameworks/
download the last version of this gist and re-run the script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then, when installing OF dependencies, on some OS releases you could be asked:
installing OF dependencies with -hwe-18.04 packages, confirm Y/N ? Answer NO
That's it!