Skip to content

Instantly share code, notes, and snippets.

@d3cod3
Last active September 26, 2020 09:01
Show Gist options
  • Save d3cod3/d1a544e0cf21b8733b567a3d87905d23 to your computer and use it in GitHub Desktop.
Save d3cod3/d1a544e0cf21b8733b567a3d87905d23 to your computer and use it in GitHub Desktop.
Linux Mint automatic install for Mosaic (https://github.com/d3cod3/Mosaic)
#!/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 linux mint 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
# Ubuntu derivatives supported: ElementaryOS
# Loads: NAME, VERSION, ID, ID_LIKE, PRETTY_NAME,
# VERSION_ID, HOME_URL, SUPPORT_URL, BUG_REPORT_URL, VERSION_CODENAME, UBUNTU_CODENAME
source /etc/os-release
if [ "$ID" = "elementary" ]; then
# Gets ubuntu base version
RELEASE=$(lsb_release -r -u)
elif [ "$ID" = "linuxmint" ]; then
# Gets ubuntu base version
RELEASE=$(cat /etc/upstream-release/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2)
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 linux mint ${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
cd $INSTALLFOLDER
echo "fixing poco libs"
if [ "$(ls -A $OFFOLDERNAME/addons/ofxPoco/libs/)" ]; then
rm -rf $OFFOLDERNAME/addons/ofxPoco/libs/
fi
cp -R $OFFOLDERNAME/scripts/apothecary/poco/include/Poco /usr/include/
cp $OFFOLDERNAME/scripts/apothecary/poco/lib/linux64/* /usr/lib
# 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
@Daandelange
Copy link

Hello, for the record, I've just installed Mint 20 (Ubuntu 18 based), after some small dirty fixes on specific ofxAddons, Mosaic runs fine.
Compiles on qtCreator 4.6.1 either using clang-10 or gcc-8.

  • ofxPython/addons.make (linux64 section) : ADDON_PKG_CONFIG_LIBRARIES = python replace with ADDON_PKG_CONFIG_LIBRARIES = python-2.7
  • ofxAudioAnalyser/addons.make (linux64 section) Add : ADDON_LDFLAGS = -lfftw3f -L/usr/lib

@d3cod3
Copy link
Author

d3cod3 commented Sep 25, 2020

Thanks Daan, good to know about the fixes!

Strange the need for the first one, as the script include a fix for that ( line 109 ):

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

but maybe the path is not right for Mint...

@Daandelange
Copy link

You are right, I reversed my ofxPython change and it still compiles, I made that change before running your script. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment