From 6bfd3f5cf23f88d2003596b9f0f1a0e93b6da40c Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 17:50:53 +0200 Subject: [PATCH 1/7] init/bash: cleanup --- Pmodules/bash | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Pmodules/bash b/Pmodules/bash index 1adbc65..4b826b1 100644 --- a/Pmodules/bash +++ b/Pmodules/bash @@ -29,11 +29,9 @@ fi unset MODULE_VERSION unset MODULE_VERSION_STACK unset MODULESHOME -#unset PMODULES_ENV declare -x PMODULES_DIR="${PMODULES_HOME}" - ############################################################################# # implement module comand as shell function # @@ -44,9 +42,7 @@ module() { export -f module modbuild(){ - ( - "${PMODULES_HOME}/bin/modbuild" "$@" - ) + "${PMODULES_HOME}/bin/modbuild" "$@" } export -f modbuild From 5727cc9ef8affab8d3867c30aac4e7d2428ff043 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 17:52:26 +0200 Subject: [PATCH 2/7] modulecmd: bugfix in sub-cmd use UsedOverlays must be used instead of OverlayInfo --- Pmodules/modulecmd.bash.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 42e9471..4c4a362 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1514,7 +1514,7 @@ subcommand_use() { if [[ ! -v GroupDepths[${arg}] ]]; then # this scan is required if a new group has been # create inside an used overlay - scan_groups "${!OverlayInfo[@]}" + scan_groups "${UsedOverlays[@]}" g_env_must_be_saved='yes' fi if [[ -n ${GroupDepths[${arg}]} ]]; then From aa4838ed2e0017102b9c574994d7d9ddb40c0a76 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 17:54:04 +0200 Subject: [PATCH 3/7] modulecmd: bugfix if a Pmodule module have been loaded after loading a Pmodule module the module was not displayed with 'module list', this has been fixed --- Pmodules/modulecmd.bash.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 4c4a362..133a8b8 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -2757,8 +2757,21 @@ if [[ -n ${PMODULES_ENV} ]]; then eval "$("${base64}" -d <<< "${PMODULES_ENV}" 2>/dev/null)" fi if [[ -z ${Version} ]] || [[ ${Version} != ${PMODULES_VERSION} ]]; then + # this can only happen if the last command was + # module load Pmodules/${PMODULES_VERSION} + # + # the values these two variables must be saved before initialising + declare _tmp_loaded_modules_="${LOADEDMODULES}" + declare _tmp_lmfiles_="${_LMFILES_}" + pmodules_init - #g_env_must_be_saved='yes' + + # restore and export + LOADEDMODULES="${_tmp_loaded_modules_}" + _LMFILES_="${_tmp_lmfiles_}" + export_env \ + LOADEDMODULES \ + _LMFILES_ fi if (( ${#GroupDepths[@]} == 0 )); then From 5dbc1cf9a384846833e2c5ff50daf51967f68af2 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 18:19:28 +0200 Subject: [PATCH 4/7] modbuild: some cleanup --- Pmodules/modbuild.in | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index ace74f8..7ca8915 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -519,16 +519,12 @@ build_modules_yaml(){ local m local pattern="//" for m in "${with_modules[@]}"; do - if [[ -n $(awk "/${m%/*}[\/ ]/" "${fname}") ]]; then - pattern+=" && /${m//\//\\/}/" - fi + pattern+=" && /${m//\//\\/}/" done local -a versions yaml_get_versions versions "${fname}" "${name}/${version}" - echo versions=${versions[@]} for v in "${versions[@]}"; do - echo version=$v local -i n_variants yaml_get_num_variants n_variants "${fname}" "${v}" local -i i From 81a10f5b557d635f18fb70738fc3106d8688dc64 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 18:20:26 +0200 Subject: [PATCH 5/7] modbuild: new keyword 'systems' YAML variants files implemented The new keyword obsoletes the need of having differend variants files for different systems. --- Pmodules/modbuild.in | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index 7ca8915..c392ce9 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -489,6 +489,19 @@ build_modules_yaml(){ _result='base' } + yaml_get_systems(){ + local -n _result="$1" + local fname="$2" + local version="$3" + local idx="$4" + _result=$(yq -Ne e ".\"${version}\"[${idx}].systems" \ + "${fname}" 2>/dev/null) + (( $? == 0 )) && return + _result=$(yq -Ne e ".systems" "${fname}" 2>/dev/null) + (( $? == 0 )) && return + _result='any' + } + yaml_get_dependencies(){ local -n _result="$1" local fname="$2" @@ -544,7 +557,21 @@ build_modules_yaml(){ yaml_get_dependencies deps "${fname}" "${v}" $i ol_inst_root="${OverlayInfo[${ol_name}:inst_root]}" ol_mod_root="${OverlayInfo[${ol_name}:mod_root]}" - + + local systems + yaml_get_systems systems "${fname}" "${v}" $i + # build module if + # - systems is any + # - opt_system is listed in systems + local build_it='no' + if [[ "${systems}" == 'any' ]]; then + build_it='yes' + fi + if [[ ,${systems}, == *,${opt_system},* ]]; then + build_it='yes' + fi + [[ ${build_it} == 'no' ]] && continue + if (( ${#deps[@]} > 0 )); then while read -a with_modules; do pbuild.build_module \ From d9a1771838f8c1da82b2ae1c362c57240be4c9cd Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 18:23:20 +0200 Subject: [PATCH 6/7] modulecmd/libpmodules: bugfixes in scaning group depths --- Pmodules/libpmodules.bash.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Pmodules/libpmodules.bash.in b/Pmodules/libpmodules.bash.in index ea15fbc..f394df5 100644 --- a/Pmodules/libpmodules.bash.in +++ b/Pmodules/libpmodules.bash.in @@ -43,7 +43,7 @@ compute_group_depth () { test -d "${dir}" || return 1 local group=${dir%/*} local group=${group##*/} - local -i result=$(${find} "${dir}" -depth \( -type f -o -type l \) \ + result=$(${find} "${dir}" -depth \( -type f -o -type l \) \ -printf "%d" -quit 2>/dev/null) (( result-=2 )) # if a group doesn't contain a modulefile, depth is negativ @@ -59,12 +59,14 @@ compute_group_depth () { # scan_groups () { local ol + local depth for ol in "$@"; do local mod_root="${OverlayInfo[${ol}:mod_root]}" - local -i depth local dir for dir in ${mod_root}/*/${PMODULES_MODULEFILES_DIR}; do - if [[ -n "${GroupDepths[${group}]}" ]]; then + local group="${dir%/*}" + group="${group##*/}" + if [[ ! -v GroupDepths[${group}] ]]; then compute_group_depth depth "${dir}" GroupDepths[$group]=${depth} fi From 7d9e32f63363d2b8f6e960e0c3967188a0eb7afa Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 30 Jun 2022 18:41:26 +0200 Subject: [PATCH 7/7] modbuild/libpbuild: some code polishing --- Pmodules/libpbuild.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 8b6030b..92b28ce 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -740,9 +740,8 @@ pbuild::make_all() { # set_full_module_name_and_prefix() { do_simple_group(){ - modulefile_dir=$(join_by '/' \ - "${ol_mod_root}/${GROUP}/${PMODULES_MODULEFILES_DIR}" \ - "${module_name}") + modulefile_dir="${ol_mod_root}/${GROUP}/${PMODULES_MODULEFILES_DIR}/" + modulefile_dir+="${module_name}" modulefile_name="${modulefile_dir}/${module_version}" PREFIX="${ol_inst_root}/${GROUP}/${module_name}/${module_version}" } @@ -783,7 +782,9 @@ pbuild::make_all() { fi modulefile_dir=$(join_by '/' \ - "${ol_mod_root}/${GROUP}/${PMODULES_MODULEFILES_DIR}" \ + "${ol_mod_root}" \ + "${GROUP}" \ + "${PMODULES_MODULEFILES_DIR}" \ "${names[@]}" \ "${module_name}") modulefile_name="${modulefile_dir}/${module_version}"