SIGN IN SIGN UP

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.

0 0 154 C++
2016-02-18 17:07:43 +01:00
#!/bin/bash
2016-12-14 16:23:39 +01:00
set -e
set -o pipefail
2016-02-18 17:07:43 +01:00
# trap any script errors and exit
2016-02-18 17:42:27 +01:00
trap "trapError" ERR
age () {
if [ -f $1 ]; then
stat=$(stat -c %Z $1);
current=$(date +%s);
diff=$(expr $current - $stat);
days=$(expr $diff / 86400);
echo $days
else
echo 1000
fi
}
hostArch=`uname`
isRunning(){
if [$hostArch== “Linux” ]; then
if [ -d /proc/$1 ]; then
return 0
else
return 1
fi
else
number=$(ps aux | sed -E "s/[^ ]* +([^ ]*).*/\1/g" | grep ^$1$ | wc -l)
if [ $number -gt 0 ]; then
return 0;
else
return 1;
fi
fi
}
echoDots(){
sleep 0.1 # Waiting for a brief period first, allowing jobs returning immediatly to finish
while isRunning $1; do
for i in $(seq 1 10); do
echo -ne .
if ! isRunning $1; then
printf "\r"
return;
fi
sleep 5
done
printf "\r "
printf "\r"
done
}
2016-02-18 17:07:43 +01:00
SUDO=
2017-07-07 12:31:39 +02:00
export ROOT=$( cd "$(dirname "$0")" ; pwd -P )
2016-03-06 13:36:29 +01:00
2016-02-18 17:07:43 +01:00
trapError() {
echo
echo " ^ Received error ^"
exit 1
}
createArchImg(){
2016-03-06 12:57:41 +01:00
#sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libasound2-dev
2017-07-07 11:20:08 +02:00
#sudo apt-get -y update
#sudo apt-get -f -y --force-yes dist-upgrade
#sudo apt-get install -y libgssapi-krb5-2 libkrb5-3 libidn11
#sudo ./arch-bootstrap.sh archlinux
download=0
if [ ! -d ~/archlinux ]; then
download=1
elif [ -f ~/archlinux/timestamp ]; then
if [ $(age ~/archlinux/timestamp) -gt 7 ]; then
rm -rf ~/archlinux
download=1
fi
fi
2017-07-07 11:20:08 +02:00
if [ "$download" = "1" ]; then
echo "Downloading archlinux image"
#$ROOT/arch-bootstrap_downloadonly.sh -a armv7h -r "http://eu.mirror.archlinuxarm.org/" ~/archlinux
2018-01-26 16:06:54 +01:00
cd ~
wget -v http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
# download=$!
# echoDots $download
# wait $download
mkdir ~/archlinux
junest -- << EOF
tar xzf ~/ArchLinuxARM-rpi-2-latest.tar.gz --no-same-owner -C ~/archlinux/ 2>&1 >/dev/null | grep -v "tar: Ignoring unknown extended header keyword"
sed -i s_/etc/pacman_$HOME/archlinux/etc/pacman_g ~/archlinux/etc/pacman.conf
sed -i "s/Required DatabaseOptional/Never/g" ~/archlinux/etc/pacman.conf
sudo pacman --noconfirm -S archlinux-keyring
sudo pacman --noconfirm -S ccache
sudo pacman --noconfirm --needed -r ~/archlinux/ --config ~/archlinux/etc/pacman.conf --arch=armv7h -Syu
sudo pacman --noconfirm --needed -r ~/archlinux/ --config ~/archlinux/etc/pacman.conf --arch=armv7h -S \
make \
pkg-config \
gcc \
raspberrypi-firmware \
openal \
glew \
freeglut \
freeimage \
freetype2 \
cairo \
poco \
gstreamer \
gst-plugins-base \
gst-plugins-good \
assimp \
boost \
libxcursor \
opencv \
assimp \
glfw-x11 \
uriparser \
curl \
2018-01-08 12:25:43 +01:00
pugixml
EOF
2018-01-26 16:06:54 +01:00
touch ~/archlinux/timestamp
else
echo "Using cached archlinux image"
fi
2016-02-18 17:07:43 +01:00
}
downloadToolchain(){
2018-01-26 21:39:23 +01:00
if [ -d ~/x-tools7h ]; then
2016-03-06 22:01:19 +01:00
echo "Using cached RPI2 toolchain"
else
echo "Downloading RPI2 toolchain"
2017-07-07 11:46:32 +02:00
#xz -dc x-tools7h.tar.xz | tar x -C ~/;
if [ -f ~/x-tools7h.tar.xz ]; then
rm ~/x-tools7h.tar.xz
2017-07-07 12:41:05 +02:00
fi
cd ~
2018-01-26 21:50:12 +01:00
wget --quiet http://archlinuxarm.org/builder/xtools/x-tools7h.tar.xz
junest -- << EOF
tar -x --delay-directory-restore --no-same-owner -f ~/x-tools7h.tar.xz -C ~/
rm ~/x-tools7h.tar.xz
EOF
2017-07-07 11:20:08 +02:00
#wget http://ci.openframeworks.cc/rpi2_toolchain.tar.bz2
#tar xjf rpi2_toolchain.tar.bz2 -C ~/
#rm rpi2_toolchain.tar.bz2
fi
2016-02-18 17:07:43 +01:00
}
downloadFirmware(){
cd ~
wget https://github.com/raspberrypi/firmware/archive/master.zip -O firmware.zip
unzip firmware.zip
cp -r ~/firmware-master/opt archlinux/
2016-02-18 17:07:43 +01:00
}
relativeSoftLinks(){
rel_link=$1
escaped_rel_link=$2
2017-07-07 11:20:08 +02:00
for link in $(ls -la | grep "\-> /" | sed "s/.* \([^ ]*\) \-> \/\(.*\)/\1->\/\2/g"); do
lib=$(echo $link | sed "s/\(.*\)\->\(.*\)/\1/g");
link=$(echo $link | sed "s/\(.*\)\->\(.*\)/\2/g");
2016-03-06 13:36:29 +01:00
${SUDO} rm $lib
2017-07-07 11:20:08 +02:00
${SUDO} ln -s ${rel_link}/${link} $lib
2016-02-18 17:07:43 +01:00
done
2017-07-07 11:20:08 +02:00
for f in *; do
error_lib=$(grep " \/lib/" $f > /dev/null 2>&1; echo $?)
error_usr=$(grep " \/usr/" $f > /dev/null 2>&1; echo $?)
if [ $error_lib -eq 0 ] || [ $error_usr -eq 0 ]; then
2016-03-06 13:36:29 +01:00
${SUDO} sed -i "s/ \/lib/ $escaped_rel_link\/lib/g" $f
${SUDO} sed -i "s/ \/usr/ $escaped_rel_link\/usr/g" $f
2016-02-18 17:07:43 +01:00
fi
done
}
installRtAudio(){
#cd $ROOT
#wget http://www.music.mcgill.ca/~gary/rtaudio/release/rtaudio-4.1.1.tar.gz
#tar xzf rtaudio-4.1.1.tar.gz
#cd rtaudio-4.1.1
#./configure --host=${GCC_PREFIX}
2017-07-07 11:20:08 +02:00
#sed -i "s|CFLAGS[ ]*=\(.*\)|CFLAGS = ${CFLAGS} \1|g" Makefile
#perl -p -i -e 's|\$\(CC\) (?!\$\(CFLAGS\))|\$(CC) \$(CFLAGS) |g' Makefile
2016-02-18 17:07:43 +01:00
#make
#cp RtAudio.h ${RPI_ROOT}/usr/local/include/
#cp *.a ${RPI_ROOT}/usr/local/lib/
#cd $ROOT
#rm rtaudio-4.1.1.tar.gz
#rm -r rtaudio-4.1.1
cd ~/archlinux
wget http://ci.openframeworks.cc/rtaudio-armv7hf.tar.bz2
tar xjf rtaudio-armv7hf.tar.bz2
rm rtaudio-armv7hf.tar.bz2
}
2016-02-18 17:07:43 +01:00
2017-07-07 11:20:08 +02:00
installJunest(){
if [ ! -d ~/.local/share/junest ]; then
git clone git://github.com/fsquillace/junest ~/.local/share/junest
fi
2017-07-07 11:20:08 +02:00
export PATH=~/.local/share/junest/bin:$PATH
junest setup
junest -- << EOF
2019-04-18 16:46:17 +02:00
echo updating keys
sudo pacman -Syy gnupg --noconfirm --needed
sudo pacman-key --populate archlinux
sudo pacman-key --refresh-keys
sudo pacman -Syyu --noconfirm
sudo pacman -S --noconfirm --needed git flex grep gcc pkg-config make wget sed
2017-07-07 11:32:48 +02:00
EOF
2018-01-26 21:39:23 +01:00
echo "Done installing junest"
2017-07-07 11:20:08 +02:00
}
2016-02-18 17:07:43 +01:00
echo $ROOT
2018-01-09 15:31:15 +01:00
sudo su -c 'echo 1 > /proc/sys/kernel/unprivileged_userns_clone'
2017-07-07 12:16:59 +02:00
installJunest
2016-02-18 17:07:43 +01:00
createArchImg
downloadToolchain
downloadFirmware
2016-12-14 15:28:33 +01:00
installRtAudio
2016-02-18 17:07:43 +01:00
2016-12-14 14:41:44 +01:00
cd ~/archlinux/usr/lib
2016-02-18 17:07:43 +01:00
relativeSoftLinks "../.." "..\/.."
#cd $ROOT/archlinux/usr/lib/arm-unknown-linux-gnueabihf
#relativeSoftLinks "../../.." "..\/..\/.."
#cd $ROOT/raspbian/usr/lib/gcc/arm-unknown-linux-gnueabihf/5.3
#relativeSoftLinks "../../../.." "..\/..\/..\/.."