From 4e2f6d046a673f7d22106c505b116e5dc2cb7de5 Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Tue, 20 Dec 2022 10:23:17 +0100 Subject: [PATCH 1/6] Move bash utils to new scripts dir, add new dir to tarball creation --- .github/workflows/tests_scripts.yml | 4 +-- EESSI-pilot-install-software.sh | 2 +- ...tarball.sh => create_directory_tarballs.sh | 33 ++++++++++--------- utils.sh => scripts/utils.sh | 0 update_lmod_cache.sh | 2 +- 5 files changed, 22 insertions(+), 19 deletions(-) rename create_init_tarball.sh => create_directory_tarballs.sh (52%) rename utils.sh => scripts/utils.sh (100%) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 18fcd7b255..d224034c2a 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -6,7 +6,7 @@ on: - build_container.sh - install_software_layer.sh - run_in_compat_layer_env.sh - - utils.sh + - scripts/utils.sh - update_lmod_cache.sh pull_request: @@ -16,7 +16,7 @@ on: - build_container.sh - install_software_layer.sh - run_in_compat_layer_env.sh - - utils.sh + - scripts/utils.sh - update_lmod_cache.sh permissions: contents: read # to fetch code (actions/checkout) diff --git a/EESSI-pilot-install-software.sh b/EESSI-pilot-install-software.sh index 10311b7a15..4ca553dbe7 100755 --- a/EESSI-pilot-install-software.sh +++ b/EESSI-pilot-install-software.sh @@ -50,7 +50,7 @@ set -- "${POSITIONAL_ARGS[@]}" TOPDIR=$(dirname $(realpath $0)) -source $TOPDIR/utils.sh +source $TOPDIR/scripts/utils.sh # honor $TMPDIR if it is already defined, use /tmp otherwise if [ -z $TMPDIR ]; then diff --git a/create_init_tarball.sh b/create_directory_tarballs.sh similarity index 52% rename from create_init_tarball.sh rename to create_directory_tarballs.sh index 3393285a33..c254c2c229 100755 --- a/create_init_tarball.sh +++ b/create_directory_tarballs.sh @@ -4,19 +4,6 @@ SOFTWARE_LAYER_TARBALL_URL=https://github.com/EESSI/software-layer/tarball/main set -eo pipefail -function echo_green() { - echo -e "\e[32m$1\e[0m" -} - -function echo_red() { - echo -e "\e[31m$1\e[0m" -} - -function error() { - echo_red "ERROR: $1" >&2 - exit 1 -} - if [ $# -ne 1 ]; then echo "Usage: $0 " >&2 exit 1 @@ -24,13 +11,18 @@ fi version=$1 +TOPDIR=$(dirname $(realpath $0)) + +source $TOPDIR/scripts/utils.sh + # Check if the EESSI version number encoded in the filename # is valid, i.e. matches the format YYYY.DD if ! echo "${version}" | egrep -q '^20[0-9][0-9]\.(0[0-9]|1[0-2])$' then - error "${version} is not a valid EESSI version." + fatal_error "${version} is not a valid EESSI version." fi +# Create tarball of init directory tartmp=$(mktemp -t -d init.XXXXX) mkdir "${tartmp}/${version}" tarname="eessi-${version}-init-$(date +%s).tar.gz" @@ -38,9 +30,20 @@ curl -Ls ${SOFTWARE_LAYER_TARBALL_URL} | tar xzf - -C "${tartmp}/${version}" --s source "${tartmp}/${version}/init/minimal_eessi_env" if [ "${EESSI_PILOT_VERSION}" != "${version}" ] then - error "Specified version ${version} does not match version ${EESSI_PILOT_VERSION} in the init files!" + fatal_error "Specified version ${version} does not match version ${EESSI_PILOT_VERSION} in the init files!" fi tar czf "${tarname}" -C "${tartmp}" "${version}" rm -rf "${tartmp}" echo_green "Done! Created tarball ${tarname}." + +# Create tarball of scripts directory +# Version check has already been performed and would have caused script to exit at this point in case of problems +tartmp=$(mktemp -t -d scripts.XXXXX) +mkdir "${tartmp}/${version}" +tarname="eessi-${version}-scripts-$(date +%s).tar.gz" +curl -Ls ${SOFTWARE_LAYER_TARBALL_URL} | tar xzf - -C "${tartmp}/${version}" --strip-components=1 --wildcards */scripts/ +tar czf "${tarname}" -C "${tartmp}" "${version}" +rm -rf "${tartmp}" + +echo_green "Done! Created tarball ${tarname}." diff --git a/utils.sh b/scripts/utils.sh similarity index 100% rename from utils.sh rename to scripts/utils.sh diff --git a/update_lmod_cache.sh b/update_lmod_cache.sh index 89e2ecbeee..814bb2dae0 100755 --- a/update_lmod_cache.sh +++ b/update_lmod_cache.sh @@ -5,7 +5,7 @@ TOPDIR=$(dirname $(realpath $0)) -source $TOPDIR/utils.sh +source $TOPDIR/scripts/utils.sh if [ $# -ne 2 ]; then echo "Usage: $0 " >&2 From 8cac3dfeb43a59f841f33baa62330bb38fe29f01 Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Wed, 25 Jan 2023 14:37:33 +0100 Subject: [PATCH 2/6] Update of where utils.sh is located when sourcing --- check_missing_installations.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_missing_installations.sh b/check_missing_installations.sh index 30f9cc6ff7..e4c75aebd8 100755 --- a/check_missing_installations.sh +++ b/check_missing_installations.sh @@ -16,7 +16,7 @@ fi LOCAL_TMPDIR=$(mktemp -d) -source $TOPDIR/utils.sh +source $TOPDIR/scripts/utils.sh source $TOPDIR/configure_easybuild From 3390a2d56ab5c28200ff487e124c74e87945679c Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Wed, 25 Jan 2023 14:40:06 +0100 Subject: [PATCH 3/6] Add create_directory_tarballs.sh to github CI --- .github/workflows/tests_scripts.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index dbf8933555..53f4bd13be 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -8,6 +8,7 @@ on: - run_in_compat_layer_env.sh - scripts/utils.sh - update_lmod_cache.sh + - create_directory_tarballs.sh pull_request: branches: @@ -18,6 +19,7 @@ on: - run_in_compat_layer_env.sh - scripts/utils.sh - update_lmod_cache.sh + - create_directory_tarballs.sh permissions: contents: read # to fetch code (actions/checkout) jobs: From f513b120b7264c0a4af1479feac533d86b95b24f Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Thu, 2 Feb 2023 15:35:42 +0100 Subject: [PATCH 4/6] Add CI test for the create_directory_tarballs.sh script --- .github/workflows/tests_scripts.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 53f4bd13be..a78c71dc9a 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -51,3 +51,13 @@ jobs: # force using x86_64/generic, to avoid triggering an installation from scratch sed -i "s@./EESSI-pilot-install-software.sh@\"export EESSI_SOFTWARE_SUBDIR_OVERRIDE='x86_64/generic'; ./EESSI-pilot-install-software.sh\"@g" install_software_layer.sh ./build_container.sh run /tmp/$USER/EESSI /tmp/install_software_layer.sh + + - name: test create_directory_tarballs.sh script + run: | + # scripts need to be copied to /tmp, + # since create_directory_tarballs.sh must be accessible from within build container + cp -a * /tmp/ + cd /tmp + ./build_container.sh run /tmp/$USER/EESSI /tmp/create_directory_tarballs.sh + # check if tarballs have been produced + ls -l *.tar.gz From e4702ee06c71fba563e9d4f362fdf3aac41d394f Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Thu, 2 Feb 2023 17:47:24 +0100 Subject: [PATCH 5/6] Need to specify the EESSI version to test create_directory_tarballs --- .github/workflows/tests_scripts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index a78c71dc9a..23bb36a7e8 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -58,6 +58,6 @@ jobs: # since create_directory_tarballs.sh must be accessible from within build container cp -a * /tmp/ cd /tmp - ./build_container.sh run /tmp/$USER/EESSI /tmp/create_directory_tarballs.sh + ./build_container.sh run /tmp/$USER/EESSI /tmp/create_directory_tarballs.sh 2021.12 # check if tarballs have been produced ls -l *.tar.gz From c4b9cf5e2a4dcd75fca54e9fc9da2c6b69011d9e Mon Sep 17 00:00:00 2001 From: Michael Huebner Date: Thu, 2 Feb 2023 18:15:34 +0100 Subject: [PATCH 6/6] Fix wildcard usage when building tarball of the scripts dir --- create_directory_tarballs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_directory_tarballs.sh b/create_directory_tarballs.sh index c254c2c229..be282463eb 100755 --- a/create_directory_tarballs.sh +++ b/create_directory_tarballs.sh @@ -42,7 +42,7 @@ echo_green "Done! Created tarball ${tarname}." tartmp=$(mktemp -t -d scripts.XXXXX) mkdir "${tartmp}/${version}" tarname="eessi-${version}-scripts-$(date +%s).tar.gz" -curl -Ls ${SOFTWARE_LAYER_TARBALL_URL} | tar xzf - -C "${tartmp}/${version}" --strip-components=1 --wildcards */scripts/ +curl -Ls ${SOFTWARE_LAYER_TARBALL_URL} | tar xzf - -C "${tartmp}/${version}" --strip-components=1 --wildcards '*/scripts/' tar czf "${tarname}" -C "${tartmp}" "${version}" rm -rf "${tartmp}"