Skip to content

Commit

Permalink
#345 better splitting of installation scripts and independant contain…
Browse files Browse the repository at this point in the history
…er (i.e. --containall option)
  • Loading branch information
sapetnioc committed May 16, 2023
1 parent 809def0 commit e4fe437
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 163 deletions.
16 changes: 16 additions & 0 deletions conda/apptainer.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Bootstrap: docker
From: ubuntu:22.04

%environment
export HOME=/casa/home

%post
mkdir /casa
apt update

%runscript
echo "Start casa container"
export PATH=/casa/conda/bin:$PATH
export LD_LIBRARY_PATH=/casa/conda/lib:$LD_LIBRARY_PATH

exec "$@"
149 changes: 26 additions & 123 deletions conda/setup_conda
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
set -x

casaconda="$1"
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

if [ -z "$casaconda" ]; then
echo "Missing destination directory"
Expand All @@ -14,141 +15,43 @@ if [ ! -e "$casaconda" ]; then
mkdir "$casaconda"
fi

if [ ! -e "$casaconda/home" ]; then
mkdir "$casaconda/home"
for f in .gitconfig .git-credentials; do
if [ -e "$HOME/$f" ]; then
cp "$HOME/$f" "$casaconda/home"
fi
done
fi

system_image="$casaconda/system"
if [ ! -e "$system_image" ]; then
apptainer build --sandbox --disable-cache "$casaconda/system" docker://ubuntu:22.04
apptainer run --fakeroot --writable "$system_image" mkdir /conda
apptainer run --fakeroot --writable "$system_image" apt update
apptainer build --sandbox "$casaconda/system" "$script_dir/apptainer.def"
fi

if [ ! -e "$casaconda/Miniforge3-Linux-x86_64.sh" ]; then
wget -O "$casaconda/Miniforge3-Linux-x86_64.sh" https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
fi

apptainer="apptainer run -B $casaconda/conda:/conda $system_image"
conda="$apptainer /conda/bin/conda"
apptainer="apptainer run --containall $mounts-B $casaconda:/casa -B /tmp $system_image"
root_apptainer="apptainer run --writable --fakeroot --containall -B $casaconda:/casa -B /tmp $system_image"

conda="$apptainer /casa/conda/bin/conda"
if [ ! -e "$casaconda/conda" ]; then
mkdir "$casaconda/conda"
cd "$casaconda"
apptainer run -B "$casaconda/conda:/conda" "$system_image" sh "./Miniforge3-Linux-x86_64.sh" -u -b -p "/conda"
$apptainer sh "/casa/Miniforge3-Linux-x86_64.sh" -u -b -p "/casa/conda"
$conda update conda -y
fi

script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cp -a "$script_dir/setup_run_apt" "$casaconda/conda/"
apptainer run --fakeroot --writable -B $casaconda/conda:/conda "$system_image" /conda/setup_run_apt

cp -a "$script_dir/setup_run_conda" "$casaconda/conda/"
$apptainer /conda/setup_run_conda
for script in setup_run_apt setup_run_conda setup_run_compiled; do
cp -a "$script_dir/$script" "$casaconda"
$root_apptainer /casa/$script
done

#
# Dev environment
#

# Source version control
version_control_packages=(
git
git-lfs
#! git-man
#! subversion still necessary ?
)

# Configure/build toolchain
toolchain_packages=(
automake
clang
cmake
#! cmake-curses-gui
gxx
gcc
gfortran
#! libc-dev
make
pkg-config
#! pyqt5-dev
#! pyqt5-dev-tools
#! python3-sip-dev
#! qtchooser
)

# Development tools and convenience utilities
development_tools=(
ack-grep
bash-completion
emacs-nox
flake8
gdb
gdbserver
valgrind
gedit
git-man
gitg
gitk
kate
kdiff3
kompare
kwrite
locate
meld
nano
python2 # only for flake8 tests of casa-distro
python3-autopep8
python3-objgraph
python3-venv
spyder
strace
tox
vim
xterm
xdot
)

# Documentation building
documentation_building_packages=(
doxygen
ghostscript
graphviz
nbconvert #? was jupyter-nbconvert
pandoc
sphinx
sphinx-gallery
#! texlive-latex-base
#! texlive-latex-extra # needed by doxygen to render LaTeX formulas
#! texlive-fonts-recommended
wkhtmltopdf
)

brainvisa_standard_dev_dependencies=(
#! libasound2-dev
libblitz #? was libblitz0-dev
boost-cpp #? was libboost-dev
#! libboost-filesystem-dev
#! libboost-system-dev
dcmtk #? was libdcmtk-dev
libexpat #? was libexpat1-dev
#! libgl1-mesa-dev
libglib #? was libglib2.0-dev
libglu #? was libglu1-mesa-dev
libjpeg-turbo #? was libjpeg-dev
#! libminc-dev
netcdf4 #? was libnetcdf-dev
#! libomp-dev # OpenMP with the clang compiler
#! libopenjp2-7-dev
libpng #? was libpng-dev
#! libqt5x11extras5-dev
#! libqwt-qt5-dev
libsigcpp #? was libsigc++-2.0-dev
#! libspnav-dev
libsvm #? was libsvm-dev
libtiff #? was libtiff-dev
#! libvtk9-dev
#! libvtk9-qt-dev
libxml2 #? was libxml2-dev
#! qttools5-dev
#! qtmultimedia5-dev
#! qttools5-dev-tools
#! zlib1g-dev
)
if [ ! -e "$casaconda/src" ]; then
$apptainer git clone https://github.com/sapetnioc/brainvisa-submodules /casa/src
$apptainer git -C /casa/src submodule update --init --recursive
fi

"$conda" install -y ${version_control_packages[@]} ${toolchain_packages[@]} ${documentation_building_packages[@]} ${brainvisa_standard_dev_dependencies[@]}
# Update all sources
$apptainer git -C /casa/src submodule foreach ls
124 changes: 124 additions & 0 deletions conda/setup_dev_conda
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#! /bin/bash

#
# Setup dev dependencies with conda
#

set -x
set -e

conda=/casa/conda/bin/conda

if [ -e /casa/conda/bin/nano ]; then
# if nano is installed, we assume that this script has already been
# executed.
echo "setup_dev_conda already executed => execution canceled"
exit 0
fi

# Source version control
version_control_packages=(
git
git-lfs
#! git-man
#! subversion still necessary ?
)

# Configure/build toolchain
toolchain_packages=(
automake
clang
cmake
#! cmake-curses-gui
gxx
gcc
gfortran
#! libc-dev
make
pkg-config
#! pyqt5-dev
#! pyqt5-dev-tools
#! python3-sip-dev
#! qtchooser
)

# Development tools and convenience utilities
development_tools=(
ack-grep
bash-completion
emacs-nox
flake8
gdb
gdbserver
valgrind
gedit
git-man
gitg
gitk
kate
kdiff3
kompare
kwrite
locate
meld
nano
python2 # only for flake8 tests of casa-distro
python3-autopep8
python3-objgraph
python3-venv
spyder
strace
tox
vim
xterm
xdot
)

# Documentation building
documentation_building_packages=(
doxygen
ghostscript
graphviz
nbconvert #? was jupyter-nbconvert
pandoc
sphinx
sphinx-gallery
#! texlive-latex-base
#! texlive-latex-extra # needed by doxygen to render LaTeX formulas
#! texlive-fonts-recommended
wkhtmltopdf
)

brainvisa_standard_dev_dependencies=(
#! libasound2-dev
libblitz #? was libblitz0-dev
boost-cpp #? was libboost-dev
#! libboost-filesystem-dev
#! libboost-system-dev
dcmtk #? was libdcmtk-dev
libexpat #? was libexpat1-dev
#! libgl1-mesa-dev
libglib #? was libglib2.0-dev
libglu #? was libglu1-mesa-dev
libjpeg-turbo #? was libjpeg-dev
#! libminc-dev
netcdf4 #? was libnetcdf-dev
#! libomp-dev # OpenMP with the clang compiler
#! libopenjp2-7-dev
libpng #? was libpng-dev
#! libqt5x11extras5-dev
#! libqwt-qt5-dev
libsigcpp #? was libsigc++-2.0-dev
#! libspnav-dev
libsvm #? was libsvm-dev
libtiff #? was libtiff-dev
#! libvtk9-dev
#! libvtk9-qt-dev
libxml2 #? was libxml2-dev
#! qttools5-dev
#! qtmultimedia5-dev
#! qttools5-dev-tools
#! zlib1g-dev
)

$conda install -y ${version_control_packages[@]} ${toolchain_packages[@]} ${documentation_building_packages[@]} ${brainvisa_standard_dev_dependencies[@]}
51 changes: 51 additions & 0 deletions conda/setup_run_compiled
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /bin/bash

#
# Setup run dependencies requiring software compilation
#

set -x
set -e

if [ -e /casa/conda/lib/pkgconfig/libopenjp2.pc ]; then
# if libopenjp2.pc is installed, we assume that this script has already been
# executed.
echo "setup_run_compiled already executed => execution canceled"
exit 0
fi

# MIRCen's fork of openslide with support for CZI format
#
tmp=$(mktemp -d)

cd "$tmp"
wget https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.5.0.tar.gz
tar xf v2.5.0.tar.gz
cd openjpeg-2.5.0
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=/casa/conda"
make
make install
cp libopenjp2.pc /casa/conda/lib/pkgconfig/

cd "$tmp"
git clone --depth=1 https://github.com/MIRCen/openslide.git
cd openslide
autoreconf --install
./configure --prefix="/casa/conda"
make -j$(nproc)
make install

# reinstall libminc 4.0.0 because newer versions can't properly read freesurfer
# .mgz files
cd "$tmp"
git clone https://github.com/BIC-MNI/libminc.git --single-branch --branch libminc-2-3-00
cd libminc
cmake . -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DLIBMINC_BUILD_SHARED_LIBS=ON -DLIBMINC_MINC1_SUPPORT=ON "-DCMAKE_INSTALL_PREFIX=/casa/conda"
make -j$(nproc)
make install
cd ..
rm -rf libminc

rm -Rf "$tmp"
Loading

0 comments on commit e4fe437

Please sign in to comment.