Skip to content

Commit

Permalink
Try fix for basilisk install workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
konmenel committed Feb 14, 2024
1 parent 3b05923 commit 31f3ada
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/basilisk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
run: chmod a+x install_basilisk.sh

- name: run install script
run: ./install_basilisk.sh
run: echo "y" | ./install_basilisk.sh

- name: testing
env:
TESTING : yes
BASILISK: ${{ github.workspace }}/basilisk/src
run: ./install_basilisk.sh
run: echo "y\ny\ny\ny\ny" | ./install_basilisk.sh

graphics:
# The type of runner that the job will run on
Expand Down
149 changes: 108 additions & 41 deletions install_basilisk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
JOBS=$(nproc)
# Where the basilisk will be installed
INSTALL_PREFIX=${INSTALL_PREFIX:-$HOME}
# Where the dependecies (osmesa, glu, ffmpeg) will be installed
DEPS_PREFIX=${DEPS_PREFIX:-"$HOME/local"}

if [[ ! -z $TESTING ]]; then
source $HOME/.bashrc
Expand All @@ -9,7 +13,7 @@ if [[ ! -z $TESTING ]]; then
fi

# clean up old folders
rm -rf basilisk* ffmpeg* bin* "local*" mesa* glu*
rm -rf $INSTALL_PREFIX/basilisk* $DEPS_PREFIX/ffmpeg* $DEPS_PREFIX/mesa* $DEPS_PREFIX/glu*
# Install packages
if [[ ! -z $LOCAL_INSTALL ]]; then
echo "Local installation with access to sudo for installing"
Expand All @@ -24,7 +28,8 @@ if [[ ! -z $LOCAL_INSTALL ]]; then
else
echo "Installation with no access to sudo"
wget http://basilisk.fr/basilisk/basilisk.tar.gz
tar xzf basilisk.tar.gz >/dev/null
tar xzf basilisk.tar.gz -C $INSTALL_PREFIX >/dev/null
rm basilisk.tar.gz
fi

# if on a cluster with module, check if the following can be loaded
Expand All @@ -33,7 +38,7 @@ if which module; then
fi

echo "Building Basilisk..."
cd basilisk/src
cd $INSTALL_PREFIX/basilisk/src
ln -s config.gcc config
make -k -j "$JOBS" >/dev/null
make # incase of any failures from previous command
Expand All @@ -45,103 +50,165 @@ else
fi

if ! grep -q 'BASILISK' $shellrc; then
echo "Export environment variables to shell config"
echo -e '\n#Basilisk Env' >> "$shellrc"
echo "export BASILISK=$PWD" >> "$shellrc"
echo 'export PATH=$PATH:$BASILISK' >> "$shellrc" # single quotes to not expand $PATH
# Ask user to modify PATH
while true; do
msg="Add basilisk to PATH in $shellrc (y/n)? "
read -p "$msg" yn
case $yn in
[Yy] | [Yy]es )
echo "Export environment variables to shell config"
echo -e '\n#Basilisk Env' >> "$shellrc"
echo "export BASILISK=$PWD" >> "$shellrc"
echo 'export PATH=$PATH:$BASILISK' >> "$shellrc" # single quotes to not expand $PATH
break;;
[Nn] | [Nn]o ) break;;
* ) echo "Please answer y or n.";;
esac
done
fi

if [[ ! -z $BUILD_GRAPHICS ]]; then
echo "Graphics building enabled..."

if ! which ffmpeg; then
mkdir $HOME/ffmpeg_sources
mkdir $DEPS_PREFIX/ffmpeg_sources

if ! which nasm; then # Install asm compiler
echo "---------------- Asm"
cd $HOME/ffmpeg_sources
cd $DEPS_PREFIX/ffmpeg_sources
wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2 >/dev/null
tar xjvf nasm-2.15.05.tar.bz2 >/dev/null
cd nasm-2.15.05
./autogen.sh >/dev/null
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" >/dev/null
PATH="$DEPS_PREFIX/bin:$PATH" ./configure --prefix="$DEPS_PREFIX/ffmpeg_build" --bindir="$DEPS_PREFIX/bin" >/dev/null
make -j "$JOBS" >/dev/null || { echo 'nasm build failed' && exit 1; }
make install >/dev/null || { echo 'nasm install failed' && exit 1; }
fi

if ! which x264; then # Install support for x264 video encoding
echo "---------------- x264"
cd $HOME/ffmpeg_sources && \
cd $DEPS_PREFIX/ffmpeg_sources && \
git clone --depth 1 https://code.videolan.org/videolan/x264.git >/dev/null
cd x264 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --enable-pic >/dev/null
PATH="$HOME/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'x264 build failed' && exit 1; }
PATH="$DEPS_PREFIX/bin:$PATH" PKG_CONFIG_PATH="$DEPS_PREFIX/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$DEPS_PREFIX/ffmpeg_build" --bindir="$DEPS_PREFIX/bin" --enable-static --enable-pic >/dev/null
PATH="$DEPS_PREFIX/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'x264 build failed' && exit 1; }
make install >/dev/null || { echo 'x264 install failed' && exit 1; }
fi

if ! which x265; then # Install support for x265 video encoding
echo "---------------- x265"
cd $HOME/ffmpeg_sources && \
cd $DEPS_PREFIX/ffmpeg_sources && \
wget -O x265.tar.bz2 https://bitbucket.org/multicoreware/x265_git/get/master.tar.bz2 >/dev/null
tar xjvf x265.tar.bz2 >/dev/null
cd multicoreware*/build/linux && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off ../../source >/dev/null
PATH="$HOME/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'x265 build failed' && exit 1; }
PATH="$DEPS_PREFIX/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX/ffmpeg_build" -DENABLE_SHARED=off ../../source >/dev/null
PATH="$DEPS_PREFIX/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'x265 build failed' && exit 1; }
make install >/dev/null || { echo 'x265 install failed' && exit 1; }
fi

echo "---------------- FFMPEG"
cd $HOME/ffmpeg_sources && \
cd $DEPS_PREFIX/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 >/dev/null
tar xjvf ffmpeg-snapshot.tar.bz2 >/dev/null
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
PATH="$DEPS_PREFIX/bin:$PATH" PKG_CONFIG_PATH="$DEPS_PREFIX/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$DEPS_PREFIX/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-cflags="-I$DEPS_PREFIX/ffmpeg_build/include" \
--extra-ldflags="-L$DEPS_PREFIX/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--bindir="$HOME/bin" \
--bindir="$DEPS_PREFIX/bin" \
--enable-gpl \
--enable-libx264 \
--enable-libx265 >/dev/null
PATH="$HOME/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'ffmpeg build failed' && exit 1; }
PATH="$DEPS_PREFIX/bin:$PATH" make -j "$JOBS" >/dev/null || { echo 'ffmpeg build failed' && exit 1; }
make install >/dev/null || { echo 'ffmpeg install failed' && exit 1; }
fi

cd $HOME
echo "---------------- OSMESA"
wget http://basilisk.fr/src/gl/mesa-17.2.4.tar.gz >/dev/null
tar xzvf mesa-17.2.4.tar.gz >/dev/null
cd mesa-17.2.4
./configure --prefix=$HOME/local --enable-osmesa \
--with-gallium-drivers=swrast \
--disable-driglx-direct --disable-dri --disable-gbm --disable-egl >/dev/null
make -j "$JOBS" >/dev/null || (echo 'osmesa build failed' && exit 1)
make install >/dev/null || (echo 'osmesa install failed' && exit 1)

cd $HOME
if ! /sbin/ldconfig -N -v $(sed 's/:/ /g' <<< $LD_LIBRARY_PATH)| grep libOSMesa.so; then
cd $DEPS_PREFIX
echo "---------------- OSMESA"
wget http://basilisk.fr/src/gl/mesa-17.2.4.tar.gz >/dev/null
tar xzvf mesa-17.2.4.tar.gz >/dev/null
cd mesa-17.2.4
./configure --prefix=$DEPS_PREFIX --enable-osmesa \
--with-gallium-drivers=swrast \
--disable-driglx-direct --disable-dri --disable-gbm --disable-egl >/dev/null
make -j "$JOBS" >/dev/null || (echo 'osmesa build failed' && exit 1)
make install >/dev/null || (echo 'osmesa install failed' && exit 1)
fi

# I guess always install GLU
cd $DEPS_PREFIX
echo "---------------- GLU"
wget http://basilisk.fr/src/gl/glu-9.0.0.tar.gz >/dev/null
tar xzvf glu-9.0.0.tar.gz >/dev/null
cd glu-9.0.0
./configure --prefix=$HOME/local >/dev/null
export CFLAGS="-I$DEPS_PREFIX/include"
export LDFLAGS="-L$DEPS_PREFIX/lib"
./configure --prefix=$DEPS_PREFIX >/dev/null
make -j "$JOBS" >/dev/null || { echo 'glu build failed' && exit 1; }
make install >/dev/null || { echo 'glu install failed' && exit 1; }
cd ..

echo "export CFLAGS=-I$HOME/local/include" >> "$shellrc"
echo "export LDFLAGS=-L$HOME/local/lib" >> "$shellrc"
# Ask user to add dependencies to different paths.
while true; do
msg="Add $DEPS_PREFIX/bin to PATH in $shellrc (y/n)? "
read -p "$msg" yn
case $yn in
[Yy] | [Yy]es )
echo "export PATH=\$PATH:$DEPS_PREFIX/bin" >> "$shellrc"
echo "Done"
break;;
[Nn] | [Nn]o ) break;;
* ) echo "Please answer y or n.";;
esac
done
while true; do
msg="Add $DEPS_PREFIX/lib to LIBRARY_PATH in $shellrc (y/n)? "
read -p "$msg" yn
case $yn in
[Yy] | [Yy]es )
echo "export LIBRARY_PATH=$DEPS_PREFIX/lib\${LIBRARY_PATH:+:\$LIBRARY_PATH}" >> "$shellrc"
echo "Done"
break;;
[Nn] | [Nn]o ) break;;
* ) echo "Please answer y or n.";;
esac
done
while true; do
msg="Add $DEPS_PREFIX/lib to LD_LIBRARY_PATH in $shellrc (y/n)? "
read -p "$msg" yn
case $yn in
[Yy] | [Yy]es )
echo "export LD_LIBRARY_PATH=$DEPS_PREFIX/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}" >> "$shellrc"
break;;
[Nn] | [Nn]o ) break;;
* ) echo "Please answer y or n.";;
esac
done
while true; do
msg="Add $DEPS_PREFIX/include to C_INCLUDE_PATH in $shellrc (y/n)? "
read -p "$msg" yn
case $yn in
[Yy] | [Yy]es )
echo "export C_INCLUDE_PATH=$DEPS_PREFIX/lib\${C_INCLUDE_PATH:+:\$C_INCLUDE_PATH}" >> "$shellrc"
echo "Done"
break;;
[Nn] | [Nn]o ) break;;
* ) echo "Please answer y or n.";;
esac
done

echo "Cleaning up..."
cd $HOME && rm -rf *.tar.gz ffmpeg_sources
cd $DEPS_PREFIX && rm -rf *.tar.gz ffmpeg_sources
else
echo "Graphics build disabled..."
fi

CFLAGS="-I$HOME/local/include -std=gnu99"
LDFLAGS="-L$HOME/local/lib"
CFLAGS="-I$DEPS_PREFIX/include -std=gnu99"
LDFLAGS="-L$DEPS_PREFIX/lib"
cd $HOME/basilisk/src/ppr
make && cd ../gl
make libglutils.a libfb_osmesa.a || { echo "failed building src/gl" && exit 1; }
Expand Down

0 comments on commit 31f3ada

Please sign in to comment.