Skip to content

Commit

Permalink
reduce code copying in install-singularity-flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Aug 22, 2024
1 parent 6cfde36 commit 5faedaf
Showing 1 changed file with 18 additions and 35 deletions.
53 changes: 18 additions & 35 deletions ci/install-singularity-flavor
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,49 @@ inf() {
printf "\033[1mINFO: \033[0m%s\n" "$*"
}

# install one of the two available original recipe singularity
# ARGS
# 1 - version, must be 3.8.6 or 3.8.7
singularity() {
if [ ! "${1}" = "3.8.6" ] && [ ! "${1}" = "3.8.7" ]; then
error "Unsupported version number '${1}' for original recipe singularity."
exit 1
fi
install_from_deb() {
# go to temp dir
tmp_dir="$(mktemp -d)"
cd "${tmp_dir}"
wget \
--no-verbose \
-O singularity.deb \
"https://github.com/apptainer/singularity/releases/download/v${1}/singularity-container_${1}_amd64.deb"
-O package.deb \
"${1}"
inf "Downloaded deb build"
sudo apt-get install ./singularity.deb
sudo apt-get install ./package.deb
inf "Installed with apt-get install"
cd
if [ -n "${tmp_dir}" ] && [ -e "${tmp_dir}" ]; then
rm -rf "${tmp_dir}"
fi
}

# install one of the two available original recipe singularity
# ARGS
# 1 - version, must be 3.8.6 or 3.8.7
singularity() {
if [ ! "${1}" = "3.8.6" ] && [ ! "${1}" = "3.8.7" ]; then
error "Unsupported version number '${1}' for original recipe singularity."
exit 1
fi
install_from_deb \
"https://github.com/apptainer/singularity/releases/download/v${1}/singularity-container_${1}_amd64.deb"
}

# install one of the versions of apptainer
# ARGS
# 1 - version string without preceding v
apptainer() {
tmp_dir="$(mktemp -d)"
cd "${tmp_dir}"
wget \
--no-verbose \
-O apptainer.deb \
install_from_deb \
"https://github.com/apptainer/apptainer/releases/download/v${1}/apptainer_${1}_amd64.deb"
inf "Downloaded deb build"
sudo apt-get install ./apptainer.deb
inf "Installed with apt-get install"
cd
if [ -n "${tmp_dir}" ] && [ -e "${tmp_dir}" ]; then
rm -rf "${tmp_dir}"
fi
}

# install one of the versions of sylabs
# ARGS
# 1 - version string without preceding v
sylabs() {
tmp_dir="$(mktemp -d)"
cd "${tmp_dir}"
wget \
--no-verbose \
-O sylabs.deb \
install_from_deb \
"https://github.com/sylabs/singularity/releases/download/v${1}/singularity-ce_${1}-jammy_amd64.deb"
inf "Downloaded deb build"
sudo apt-get install ./sylabs.deb
inf "Installed with apt-get install"
cd
if [ -n "${tmp_dir}" ] && [ -e "${tmp_dir}" ]; then
rm -rf "${tmp_dir}"
fi
}

help() {
Expand Down

0 comments on commit 5faedaf

Please sign in to comment.