From 08cc282e4ba00d5d327aaf8c611f531074185a70 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Fri, 4 Feb 2022 17:11:36 +0100 Subject: [PATCH 1/3] flesh out script to update Lmod cache --- EESSI-pilot-install-software.sh | 40 ++------------------------------- update_lmod_cache.sh | 35 +++++++++++++++++++++++++++++ utils.sh | 28 +++++++++++++++++++++++ 3 files changed, 65 insertions(+), 38 deletions(-) create mode 100755 update_lmod_cache.sh create mode 100644 utils.sh diff --git a/EESSI-pilot-install-software.sh b/EESSI-pilot-install-software.sh index a25c3f1d9e..717f473a7b 100755 --- a/EESSI-pilot-install-software.sh +++ b/EESSI-pilot-install-software.sh @@ -5,34 +5,7 @@ TOPDIR=$(dirname $(realpath $0)) -function echo_green() { - echo -e "\e[32m$1\e[0m" -} - -function echo_red() { - echo -e "\e[31m$1\e[0m" -} - -function echo_yellow() { - echo -e "\e[33m$1\e[0m" -} - -function fatal_error() { - echo_red "ERROR: $1" >&2 - exit 1 -} - -function check_exit_code { - ec=$1 - ok_msg=$2 - fail_msg=$3 - - if [[ $ec -eq 0 ]]; then - echo_green "${ok_msg}" - else - fatal_error "${fail_msg}" - fi -} +source utils.sh # honor $TMPDIR if it is already defined, use /tmp otherwise if [ -z $TMPDIR ]; then @@ -339,16 +312,7 @@ if [ ! -f $LMOD_RC ]; then check_exit_code $? "$LMOD_RC created" "Failed to create $LMOD_RC" fi -# we need to specify the path to the Lmod cache dir + timestamp file to ensure -# that update_lmod_system_cache_files updates correct Lmod cache -lmod_cache_dir=${EASYBUILD_INSTALLPATH}/.lmod/cache -lmod_cache_timestamp_file=${EASYBUILD_INSTALLPATH}/.lmod/cache/timestamp -modpath=${EASYBUILD_INSTALLPATH}/modules/all - -${LMOD_DIR}/update_lmod_system_cache_files -d ${lmod_cache_dir} -t ${lmod_cache_timestamp_file} ${modpath} -check_exit_code $? "Lmod cache updated" "Lmod cache update failed!" - -ls -lrt ${EASYBUILD_INSTALLPATH}/.lmod/cache +./update_lmod_cache.sh ${EPREFIX} ${EASYBUILD_INSTALLPATH} echo ">> Checking for missing installations..." ok_msg="No missing installations, party time!" diff --git a/update_lmod_cache.sh b/update_lmod_cache.sh new file mode 100755 index 0000000000..3b4797798a --- /dev/null +++ b/update_lmod_cache.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Script to update Lmod cache in EESSI +# + +source utils.sh + +if [ $# -ne 2 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi +EPREFIX=$1 +EASYBUILD_INSTALLPATH=$2 + +if [ ! -d $EPREFIX ]; then + echo "\$EPREFIX does not exist!" >&2 + exit 2 +fi +if [ ! -d $EASYBUILD_INSTALLPATH ]; then + echo "\$EASYBUILD_INSTALLPATH does not exist!" >&2 + exit 2 +fi + +source $EPREFIX/usr/share/Lmod/init/bash + +# we need to specify the path to the Lmod cache dir + timestamp file to ensure +# that update_lmod_system_cache_files updates correct Lmod cache +lmod_cache_dir=${EASYBUILD_INSTALLPATH}/.lmod/cache +lmod_cache_timestamp_file=${EASYBUILD_INSTALLPATH}/.lmod/cache/timestamp +modpath=${EASYBUILD_INSTALLPATH}/modules/all + +${LMOD_DIR}/update_lmod_system_cache_files -d ${lmod_cache_dir} -t ${lmod_cache_timestamp_file} ${modpath} +check_exit_code $? "Lmod cache updated" "Lmod cache update failed!" + +ls -lrt ${EASYBUILD_INSTALLPATH}/.lmod/cache diff --git a/utils.sh b/utils.sh new file mode 100644 index 0000000000..0c98c86ec4 --- /dev/null +++ b/utils.sh @@ -0,0 +1,28 @@ +function echo_green() { + echo -e "\e[32m$1\e[0m" +} + +function echo_red() { + echo -e "\e[31m$1\e[0m" +} + +function echo_yellow() { + echo -e "\e[33m$1\e[0m" +} + +function fatal_error() { + echo_red "ERROR: $1" >&2 + exit 1 +} + +function check_exit_code { + ec=$1 + ok_msg=$2 + fail_msg=$3 + + if [[ $ec -eq 0 ]]; then + echo_green "${ok_msg}" + else + fatal_error "${fail_msg}" + fi +} From 568357e6d9a1789b3885c115739a5012791b6dcc Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Fri, 4 Feb 2022 21:55:55 +0100 Subject: [PATCH 2/3] also run CI for scripts when utils.sh or update_lmod_cache.sh are touched --- .github/workflows/tests_scripts.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 50382048d8..d6d2713e47 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -6,6 +6,8 @@ on: - build_container.sh - install_software_layer.sh - run_in_compat_layer_env.sh + - utils.sh + - update_lmod_cache.sh pull_request: branches: @@ -14,6 +16,8 @@ on: - build_container.sh - install_software_layer.sh - run_in_compat_layer_env.sh + - utils.sh + - update_lmod_cache.sh jobs: build: runs-on: ubuntu-20.04 From 1d7e282cfc6c14d19f555c682bbffa707abea69a Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 1 Jun 2022 14:11:36 +0200 Subject: [PATCH 3/3] use $TOPDIR rather than relative paths --- EESSI-pilot-install-software.sh | 4 ++-- update_lmod_cache.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/EESSI-pilot-install-software.sh b/EESSI-pilot-install-software.sh index 717f473a7b..0c832fdee9 100755 --- a/EESSI-pilot-install-software.sh +++ b/EESSI-pilot-install-software.sh @@ -5,7 +5,7 @@ TOPDIR=$(dirname $(realpath $0)) -source utils.sh +source $TOPDIR/utils.sh # honor $TMPDIR if it is already defined, use /tmp otherwise if [ -z $TMPDIR ]; then @@ -312,7 +312,7 @@ if [ ! -f $LMOD_RC ]; then check_exit_code $? "$LMOD_RC created" "Failed to create $LMOD_RC" fi -./update_lmod_cache.sh ${EPREFIX} ${EASYBUILD_INSTALLPATH} +$TOPDIR/update_lmod_cache.sh ${EPREFIX} ${EASYBUILD_INSTALLPATH} echo ">> Checking for missing installations..." ok_msg="No missing installations, party time!" diff --git a/update_lmod_cache.sh b/update_lmod_cache.sh index 3b4797798a..89e2ecbeee 100755 --- a/update_lmod_cache.sh +++ b/update_lmod_cache.sh @@ -3,7 +3,9 @@ # Script to update Lmod cache in EESSI # -source utils.sh +TOPDIR=$(dirname $(realpath $0)) + +source $TOPDIR/utils.sh if [ $# -ne 2 ]; then echo "Usage: $0 " >&2