mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-28 18:29:39 +02:00
modulecmd: rel_stage refactored to relstage
This commit is contained in:
+59
-58
@@ -187,7 +187,7 @@ die_illegal_group(){
|
||||
"${CMD}" "${subcommand}" "invalid group name" "$1"
|
||||
}
|
||||
|
||||
die_illegal_rel_stage(){
|
||||
die_illegal_relstage(){
|
||||
std::die 3 "%s %s: %s -- %s\n" \
|
||||
"${CMD}" "${subcommand}" "invalid release stage" "$1"
|
||||
}
|
||||
@@ -299,17 +299,18 @@ get_module_config(){
|
||||
local -n ref_cfg="$1"
|
||||
local -r dir="$2"
|
||||
local -r modulefile="${dir}/$3"
|
||||
debug "modulefile: $modulefile"
|
||||
|
||||
ref_cfg['rel_stage']='unstable'
|
||||
ref_cfg['relstage']='unstable'
|
||||
ref_cfg['systems']=''
|
||||
ref_cfg['blocklist']=''
|
||||
if [[ ! -v Dir2OverlayMap[${dir%/${PMODULES_MODULEFILES_DIR}*}] ]]; then
|
||||
# this module is not in an overlay
|
||||
ref_cfg['rel_stage']='stable'
|
||||
ref_cfg['relstage']='stable'
|
||||
return
|
||||
fi
|
||||
local -r config_file="${modulefile%/*}/.config-${modulefile##*/}"
|
||||
local -r rel_stage_file="${modulefile%/*}/.release-${modulefile##*/}"
|
||||
local -r relstage_file="${modulefile%/*}/.release-${modulefile##*/}"
|
||||
if [[ -r ${config_file} ]]; then
|
||||
local -- yaml=$(${yq} -e '.' < "${config_file}")
|
||||
debug "yaml: ${yaml}"
|
||||
@@ -332,10 +333,10 @@ get_module_config(){
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
elif [[ -r ${rel_stage_file} ]]; then
|
||||
ref_cfg['rel_stage']=$( < "${rel_stage_file}" )
|
||||
elif [[ -r ${relstage_file} ]]; then
|
||||
ref_cfg['relstage']=$( < "${relstage_file}" )
|
||||
else
|
||||
ref_cfg['rel_stage']='unstable'
|
||||
ref_cfg['relstage']='unstable'
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -574,7 +575,7 @@ USAGE:
|
||||
'
|
||||
|
||||
subcommand_load() {
|
||||
local rel_stage='undef'
|
||||
local relstage='undef'
|
||||
local current_modulefile=''
|
||||
local prefix=''
|
||||
local m=''
|
||||
@@ -590,13 +591,13 @@ subcommand_load() {
|
||||
# none
|
||||
get_load_hints() {
|
||||
local -n output="$1"
|
||||
local rel_stage=''
|
||||
local relstage=''
|
||||
output=''
|
||||
while read -a line; do
|
||||
[[ -z ${line} ]] && continue
|
||||
rel_stage=${line[1]}
|
||||
if [[ ! ":${UsedReleaseStages}:" =~ "${rel_stage}" ]]; then
|
||||
output+="module use ${rel_stage}; "
|
||||
relstage=${line[1]}
|
||||
if [[ ! ":${UsedReleaseStages}:" =~ "${relstage}" ]]; then
|
||||
output+="module use ${relstage}; "
|
||||
fi
|
||||
local group=${line[2]}
|
||||
if [[ ! ":${UsedGroups}:" =~ ":${group}:" ]] && \
|
||||
@@ -716,23 +717,23 @@ subcommand_load() {
|
||||
|
||||
# extendet module name is either
|
||||
# - group:name or
|
||||
# - group:name:rel_stage or
|
||||
# - rel_stage:name or
|
||||
# - rel_stage:group:name or
|
||||
# - name:rel_stage
|
||||
# - group:name:relstage or
|
||||
# - relstage:name or
|
||||
# - relstage:group:name or
|
||||
# - name:stage
|
||||
|
||||
|
||||
IFS=':'
|
||||
local -a toks=($m)
|
||||
unset IFS
|
||||
local group=''
|
||||
local rel_stage=''
|
||||
local relstage=''
|
||||
if is_group "${toks[0]}"; then
|
||||
group=${toks[0]}
|
||||
m=${toks[1]}
|
||||
rel_stage=${toks[2]}
|
||||
relstage=${toks[2]}
|
||||
elif is_release_stage "${toks[0]}"; then
|
||||
rel_stage=${toks[0]}
|
||||
relstage=${toks[0]}
|
||||
if is_group "${toks[1]}"; then
|
||||
group=${toks[1]}
|
||||
m=${toks[2]}
|
||||
@@ -744,9 +745,9 @@ subcommand_load() {
|
||||
m=${toks[0]}
|
||||
if is_group "${toks[1]}"; then
|
||||
group=${toks[1]}
|
||||
rel_stage=${toks[2]}
|
||||
relstage=${toks[2]}
|
||||
else
|
||||
rel_stage=${toks[1]}
|
||||
relstage=${toks[1]}
|
||||
group=${toks[2]}
|
||||
fi
|
||||
fi
|
||||
@@ -762,20 +763,20 @@ subcommand_load() {
|
||||
modulepath=( "${mod_root}/${group}" "${modulepath[@]}" )
|
||||
done
|
||||
fi
|
||||
if [[ -n ${rel_stage} ]]; then
|
||||
is_release_stage "${rel_stage}" || \
|
||||
die_illegal_rel_stage "${rel_stage}"
|
||||
std::append_path UsedReleaseStages "${rel_stage}"
|
||||
if [[ -n ${relstage} ]]; then
|
||||
is_release_stage "${relstage}" || \
|
||||
die_illegal_relstage "${relstage}"
|
||||
std::append_path UsedReleaseStages "${relstage}"
|
||||
g_env_must_be_saved='yes'
|
||||
fi
|
||||
fi # handle extended module names
|
||||
local moduledir=''
|
||||
find_modulefile current_modulefile rel_stage moduledir "${m}" "${modulepath[@]}"
|
||||
find_modulefile current_modulefile relstage moduledir "${m}" "${modulepath[@]}"
|
||||
if [[ -z ${current_modulefile} ]]; then
|
||||
local fname=$(std::get_abspath "${m}")
|
||||
if [[ -r "${fname}" ]]; then
|
||||
current_modulefile="${fname}"
|
||||
rel_stage='stable'
|
||||
relstage='stable'
|
||||
else
|
||||
local hints=''
|
||||
get_load_hints hints
|
||||
@@ -838,17 +839,17 @@ subcommand_load() {
|
||||
fi
|
||||
local msg=''
|
||||
if [[ ${verbosity_lvl} != silent ]] && \
|
||||
[[ ${rel_stage} != stable ]]; then
|
||||
[[ ${relstage} != stable ]]; then
|
||||
msg=$(printf "%s %s: %s -- %s" \
|
||||
"${CMD}" 'load' \
|
||||
"${rel_stage} module has been loaded" \
|
||||
"${relstage} module has been loaded" \
|
||||
"${m}")
|
||||
std::info "%s" "${msg}"
|
||||
fi
|
||||
msg=$(printf "%s: %s %s %s" \
|
||||
'load' \
|
||||
"modulefile=${current_modulefile}" \
|
||||
"rel-stage=${rel_stage}" \
|
||||
"rel-stage=${relstage}" \
|
||||
"user=${USER}")
|
||||
${logger} -t Pmodules "${msg}"
|
||||
done
|
||||
@@ -1064,14 +1065,14 @@ subcommand_show() {
|
||||
# $4... module path (fully qualified directory names)
|
||||
#
|
||||
# return list like
|
||||
# modulename_1 rel_stage_1 modulefile_1 ...
|
||||
# modulename_1 relstage_1 modulefile_1 ...
|
||||
#
|
||||
get_available_modules() {
|
||||
local -n gam_mods="$1"
|
||||
local -r module="$2"
|
||||
local -r used_rel_stages="${3:-${UsedReleaseStages}}"
|
||||
local -r used_relstages="${3:-${UsedReleaseStages}}"
|
||||
shift 3 # in the for loop below we use $@ to loop over module path
|
||||
local rel_stage
|
||||
local relstage
|
||||
|
||||
local -A dict
|
||||
local -A modulenames
|
||||
@@ -1125,9 +1126,9 @@ get_available_modules() {
|
||||
[[ "${add}" == 'no' ]] && continue
|
||||
local -A cfg=()
|
||||
get_module_config cfg "${dir}" "${mod}"
|
||||
is_available cfg "${used_rel_stages}" "${os_release}" "${HOSTNAME}" || continue
|
||||
is_available cfg "${used_relstages}" "${os_release}" "${HOSTNAME}" || continue
|
||||
|
||||
gam_mods+=( "${mod}" "${cfg['rel_stage']}" "${dir}/${mod}" "${ol}" )
|
||||
gam_mods+=( "${mod}" "${cfg['relstage']}" "${dir}/${mod}" "${ol}" )
|
||||
dict[${sdirs}/${mod}]=1
|
||||
done < <(${find} -L "${dir_entries[@]}" \
|
||||
\( -type f -o -type l \) \
|
||||
@@ -1156,7 +1157,7 @@ get_available_modules() {
|
||||
#
|
||||
find_modulefile() {
|
||||
local -n fm_modulefile="$1"
|
||||
local -n fm_rel_stage="$2"
|
||||
local -n fm_relstage="$2"
|
||||
local -n fm_dir="$3"
|
||||
local -r module="$4"
|
||||
local -a dirs=("${@:5}")
|
||||
@@ -1186,7 +1187,7 @@ find_modulefile() {
|
||||
is_available cfg "${ReleaseStages}" "${os_release}" "${HOSTNAME}" || continue
|
||||
|
||||
fm_modulefile="${dir}/${mod}"
|
||||
fm_rel_stage="${cfg['rel_stage']}"
|
||||
fm_relstage="${cfg['relstage']}"
|
||||
fm_dir="${dir}"
|
||||
return 0
|
||||
done
|
||||
@@ -1216,7 +1217,7 @@ find_modulefile() {
|
||||
get_module_config cfg "${dir}" "${mod}"
|
||||
is_available cfg "${ReleaseStages}" "${os_release}" "${HOSTNAME}" || continue
|
||||
fm_modulefile="${dir}/${mod}"
|
||||
fm_rel_stage="${cfg['rel_stage']}"
|
||||
fm_relstage="${cfg['relstage']}"
|
||||
fm_dir="${dir}"
|
||||
return 0
|
||||
done
|
||||
@@ -1288,13 +1289,13 @@ subcommand_avail() {
|
||||
local -i i=0
|
||||
for (( i=0; i<${#mods[@]}; i+=4 )); do
|
||||
local mod=${mods[i]}
|
||||
local rel_stage=${mods[i+1]}
|
||||
case ${rel_stage} in
|
||||
local relstage=${mods[i+1]}
|
||||
case ${relstage} in
|
||||
stable )
|
||||
out=''
|
||||
;;
|
||||
* )
|
||||
out="${rel_stage}"
|
||||
out="${relstage}"
|
||||
;;
|
||||
esac
|
||||
printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2
|
||||
@@ -1315,13 +1316,13 @@ subcommand_avail() {
|
||||
output_header "$1"
|
||||
for (( i=0; i<${#mods[@]}; i+=4 )); do
|
||||
local mod=${mods[i]}
|
||||
local rel_stage=${mods[i+1]}
|
||||
case ${rel_stage} in
|
||||
local relstage=${mods[i+1]}
|
||||
case ${relstage} in
|
||||
stable )
|
||||
out=''
|
||||
;;
|
||||
* )
|
||||
out=${rel_stage}
|
||||
out=${relstage}
|
||||
;;
|
||||
esac
|
||||
printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2
|
||||
@@ -1338,13 +1339,13 @@ subcommand_avail() {
|
||||
local -i max_length=1
|
||||
for ((i=0; i<${#mods[@]}; i+=4)); do
|
||||
if [[ ${verbosity_lvl} == 'verbose' ]]; then
|
||||
local rel_stage=${mods[i+1]}
|
||||
case ${rel_stage} in
|
||||
local relstage=${mods[i+1]}
|
||||
case ${relstage} in
|
||||
stable )
|
||||
mod="${mods[i]}"
|
||||
;;
|
||||
* )
|
||||
mod="${mods[i]}(${rel_stage:0:1})"
|
||||
mod="${mods[i]}(${relstage:0:1})"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
@@ -1379,7 +1380,7 @@ subcommand_avail() {
|
||||
#......................................................................
|
||||
local pattern=()
|
||||
local output_function='human_readable_output'
|
||||
local opt_use_rel_stages="${UsedReleaseStages}"
|
||||
local opt_use_relstages="${UsedReleaseStages}"
|
||||
local -A opt_groups=()
|
||||
local val=''
|
||||
while (($# > 0)); do
|
||||
@@ -1388,7 +1389,7 @@ subcommand_avail() {
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-a | --all | --all-release-stages )
|
||||
opt_use_rel_stages="${ReleaseStages}"
|
||||
opt_use_relstages="${ReleaseStages}"
|
||||
;;
|
||||
-h | --human )
|
||||
output_function='human_readable_output'
|
||||
@@ -1476,7 +1477,7 @@ subcommand_avail() {
|
||||
get_available_modules \
|
||||
mods \
|
||||
"${string}*" \
|
||||
"${opt_use_rel_stages}" \
|
||||
"${opt_use_relstages}" \
|
||||
"${path[@]}"
|
||||
|
||||
[[ ${#mods[@]} == 0 ]] && continue
|
||||
@@ -2463,17 +2464,17 @@ subcommand_search() {
|
||||
|
||||
# get and print all available modules in $mpath
|
||||
# with respect to the requested release stage
|
||||
# tmpfile: module/version rel_stage group dependencies...
|
||||
# tmpfile: module/version relstage group dependencies...
|
||||
local mods
|
||||
get_available_modules \
|
||||
mods \
|
||||
"${module}" \
|
||||
"${opt_use_rel_stages}" \
|
||||
"${opt_use_relstages}" \
|
||||
"${modulepath[@]}"
|
||||
local i=0
|
||||
for (( i=0; i<${#mods[@]}; i+=4 )); do
|
||||
local name=${mods[i]}
|
||||
local rel_stage=${mods[i+1]}
|
||||
local relstage=${mods[i+1]}
|
||||
local modulefile=${mods[i+2]}
|
||||
local ol=${mods[i+3]}
|
||||
|
||||
@@ -2503,7 +2504,7 @@ subcommand_search() {
|
||||
unset IFS
|
||||
fi
|
||||
|
||||
echo ${name} ${rel_stage} ${group} ${modulefile} \
|
||||
echo ${name} ${relstage} ${group} ${modulefile} \
|
||||
${ol} \
|
||||
${deps[@]} >> "${tmpfile}"
|
||||
done
|
||||
@@ -2540,7 +2541,7 @@ subcommand_search() {
|
||||
"${CMD}" 'search' \
|
||||
"illegal release stage" \
|
||||
"${arg}"
|
||||
opt_use_rel_stages+="${arg}:"
|
||||
opt_use_relstages+="${arg}:"
|
||||
;;
|
||||
--with | --with=* )
|
||||
if [[ "$1" == --with ]]; then
|
||||
@@ -2562,7 +2563,7 @@ subcommand_search() {
|
||||
done
|
||||
;;
|
||||
-a | --all-releases-stages )
|
||||
opt_use_rel_stages+="${ReleaseStages}"
|
||||
opt_use_relstages+="${ReleaseStages}"
|
||||
;;
|
||||
--src | --src=*)
|
||||
if [[ "$1" == --src ]]; then
|
||||
@@ -2624,8 +2625,8 @@ subcommand_search() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "${opt_use_rel_stages}" == ":" ]]; then
|
||||
opt_use_rel_stages=":${UsedReleaseStages}:"
|
||||
if [[ "${opt_use_relstages}" == ":" ]]; then
|
||||
opt_use_relstages=":${UsedReleaseStages}:"
|
||||
fi
|
||||
|
||||
if [[ ${#modules[@]} == 0 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user