From 2518eca26ad7005775a5af0f6d3f033a4220aefa Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 4 Jul 2023 17:08:12 +0200 Subject: [PATCH 1/3] collections in overlays implemented --- Pmodules/modulecmd.bash.in | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index aca12cd..c31c661 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -2909,8 +2909,11 @@ search_collection(){ _path=$(std::get_abspath "${_collection}") return fi - local _dirs2search=( "${UsrCollectionsDir}" "${SysCollectionsDir}" ) + local _dirs2search=( "${UsrCollectionsDir}" ) local _dir + for _dir in "${UsedOverlays[@]}"; do + _dirs2search+=( "${_dir}" ) + done for _dir in "${_dirs2search[@]}"; do if [[ -r "${_dir}/${_collection}" ]]; then _path="${_dir}/${_collection}" @@ -3001,7 +3004,7 @@ subcommand_savelist() { get_collections() { local -n _result="$1" - local -- _dir="$2" + local -n gc_dirs="$2" shift 2 _result=() local _pattern @@ -3009,16 +3012,16 @@ subcommand_savelist() { for _pattern in "$@"; do while read _coll; do _result+=( "${_coll}" ) - done < <(find "${_dir}" -type f -ipath "*/${_pattern}" -printf "%P\n") + done < <(find "${gc_dirs[@]}" -type f -ipath "*/${_pattern}" -printf "%P\n") done } print_collections() { local -r prt_header="$1" - local -r prt_dir="$2" + local -n prt_dirs="$2" shift 2 local -a prt_collections=() - get_collections prt_collections "${prt_dir}" "$@" + get_collections prt_collections prt_dirs "$@" (( ${#prt_collections[@]} == 0 )) && return 0 @@ -3048,9 +3051,14 @@ subcommand_savelist() { if (( ${#args[@]} == 0 )); then args[0]='*' fi - local -a collections=() - print_collections "User collections:" "${UsrCollectionsDir}" "${args[@]}" - print_collections "\nSystem collections:" "${SysCollectionsDir}" "${args[@]}" + local -a _dirs=( "${UsrCollectionsDir[@]}" ) + print_collections "User collections:" _dirs "${args[@]}" + _dirs=() + local _ol + for _ol in "${UsedOverlays[@]}"; do + _dirs+=( "${OverlayInfo[${_ol}:inst_root]}/collections" ) + done + print_collections "\nSystem collections:" _dirs "${args[@]}" } ############################################################################## @@ -3092,7 +3100,7 @@ subcommand_saverm() { search_collection collection "${collection}" test -e "${collection}" || \ die_collection_doesnt_exist "${collection}" - rm -f "${collection}" 2>/dev/null || \ + ${rm} -f "${collection}" 2>/dev/null || \ die_removing_collection_failed "${collection}" done } From 14941fc8c39b1102889e1866ef4278f80e9ac049 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 4 Jul 2023 17:30:04 +0200 Subject: [PATCH 2/3] don't save Pmodules module in collection --- Pmodules/modulecmd.bash.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index c31c661..81f5fc7 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -2879,6 +2879,7 @@ subcommand_save() { IFS=':' read -a modules <<< "${LOADEDMODULES}" local -- m='' for m in "${modules[@]}"; do + [[ $m == Pmodules/* ]] && continue s+="module load $m;\n" done From 460e6624f993326125db94847f6c9aff36ecab1b Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 4 Jul 2023 17:31:24 +0200 Subject: [PATCH 3/3] modulecmd.bash.in: bugfix in search_collection --- Pmodules/modulecmd.bash.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 81f5fc7..06d213e 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -2911,9 +2911,9 @@ search_collection(){ return fi local _dirs2search=( "${UsrCollectionsDir}" ) - local _dir - for _dir in "${UsedOverlays[@]}"; do - _dirs2search+=( "${_dir}" ) + local _ol + for _ol in "${UsedOverlays[@]}"; do + _dirs2search+=( "${OverlayInfo[${_ol}:inst_root]}/collections" ) done for _dir in "${_dirs2search[@]}"; do if [[ -r "${_dir}/${_collection}" ]]; then