From 5faedaf1ccf22d8620229a73675f429420d34dae Mon Sep 17 00:00:00 2001 From: tomeichlersmith Date: Wed, 21 Aug 2024 15:40:17 -0500 Subject: [PATCH] reduce code copying in install-singularity-flavor --- ci/install-singularity-flavor | 53 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/ci/install-singularity-flavor b/ci/install-singularity-flavor index 17e40f6..93e8a39 100755 --- a/ci/install-singularity-flavor +++ b/ci/install-singularity-flavor @@ -18,23 +18,16 @@ 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 @@ -42,42 +35,32 @@ singularity() { 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() {