From 988c2e626642d70a2c274948ab1fc33d3710ca92 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 25 Feb 2021 13:45:57 +0100 Subject: [PATCH 1/3] libpbuild: do not use module() function --- Pmodules/libpbuild.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index fab72b6..56c0615 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -1430,7 +1430,7 @@ pbuild.build_module() { fi std::info "Loading module: ${m}\n" - module load "${m}" + eval $( "${MODULECMD}" bash load "${m}" ) done } From cea58bfc60a1f80d4f40fac41234039d8d3f0202 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 4 Mar 2021 09:31:52 +0100 Subject: [PATCH 2/3] linefeeds in info messages fixed --- Pmodules/libpbuild.bash | 59 +++++++++++++++++++++++--------------- Pmodules/libstd.bash | 4 +-- Pmodules/modulecmd.bash.in | 40 +++++++++++++------------- 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 56c0615..bc82224 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -517,7 +517,7 @@ pbuild::prep() { local i=0 for ((_i = 0; _i < ${#PATCH_FILES[@]}; _i++)); do std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "Appling patch '${PATCH_FILES[_i]}' ..." local -i strip_val="${PATCH_STRIPS[_i]:-${PATCH_STRIP_DEFAULT}}" @@ -641,7 +641,7 @@ pbuild::configure() { "cmake failed" else std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "${FUNCNAME[0]}: skipping..." fi @@ -817,7 +817,7 @@ pbuild::make_all() { local -r docdir="${PREFIX}/${_DOCDIR}/${module_name}" std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "Installing documentation to ${docdir}" install -m 0755 -d \ @@ -865,7 +865,7 @@ pbuild::make_all() { local -r fname="$1" shift std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "writing run-time dependencies to ${fname} ..." local dep @@ -887,7 +887,7 @@ pbuild::make_all() { # multilib problem with LIBRARY_PATH on 64-bit systems post_install_linux() { std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "running post-installation for ${OS} ..." cd "${PREFIX}" @@ -917,7 +917,7 @@ pbuild::make_all() { cleanup_build cleanup_src std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "Done ..." return 0 @@ -931,7 +931,7 @@ pbuild::make_all() { find_modulefile src if (( $? != 0 )); then std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "skipping modulefile installation ..." return @@ -946,7 +946,7 @@ pbuild::make_all() { local -r dstdir=${dst%/*} std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "installing modulefile in '${dstdir}' ..." mkdir -p "${dstdir}" @@ -970,7 +970,7 @@ pbuild::make_all() { read release < "${release_file}" if [[ "${release}" != "${module_release}" ]]; then std::info \ - "%s %s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "changing release from" \ "'${release}' to '${module_release}' ..." @@ -978,7 +978,7 @@ pbuild::make_all() { fi else std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "setting release to '${module_release}' ..." echo "${module_release}" > "${release_file}" @@ -997,7 +997,7 @@ pbuild::make_all() { "BUILD_DIR is set to '/'" std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "Cleaning up '${BUILD_DIR}'..." rm -rf "${BUILD_DIR##*/}" @@ -1015,7 +1015,7 @@ pbuild::make_all() { "Oops: internal error:" \ "SRC_DIR is set to '/'" std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "Cleaning up '${SRC_DIR}'..." rm -rf "${SRC_DIR##*/}" @@ -1071,16 +1071,18 @@ pbuild::make_all() { # build module ${module_name}/${module_version} build_module() { std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ - "start building ..." + "start building" \ + ${with_modules:+with ${with_modules[@]}} \ + "..." [[ ${dry_run} == yes ]] && std::die 0 "" mkdir -p "${SRC_DIR}" mkdir -p "${BUILD_DIR}" std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "preparing sources ..." # write stdout and stderr to logfile, stderr to terminal @@ -1089,21 +1091,21 @@ pbuild::make_all() { [[ "${build_target}" == "prep" ]] && return 0 std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "configuring ..." build_target "${BUILD_DIR}" configure [[ "${build_target}" == "configure" ]] && return 0 std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "compiling ..." build_target "${BUILD_DIR}" compile [[ "${build_target}" == "compile" ]] && return 0 std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "installing ..." mkdir -p "${PREFIX}" @@ -1114,7 +1116,7 @@ pbuild::make_all() { remove_module() { if [[ -d "${PREFIX}" ]]; then std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "removing all files in '${PREFIX}' ..." [[ "${dry_run}" == 'no' ]] && rm -rf ${PREFIX} @@ -1131,7 +1133,7 @@ pbuild::make_all() { if [[ -e "${dst}" ]]; then std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "removing modulefile '${dst}' ..." [[ "${dry_run}" == 'no' ]] && rm -v "${dst}" @@ -1139,7 +1141,7 @@ pbuild::make_all() { local release_file="${dstdir}/.release-${module_version}" if [[ -e "${release_file}" ]]; then std::info \ - "%s %s\n" \ + "%s " \ "${module_name}/${module_version}:" \ "removing release file '${release_file}' ..." [[ "${dry_run}" == 'no' ]] && rm -v "${release_file}" @@ -1323,7 +1325,7 @@ pbuild.build_module() { "${m}: module does not exist," \ "cannot continue with dry run..." - std::info "%s\n" \ + std::info "%s " \ "$m: module does not exist, trying to build it..." local args=( '' ) set -- ${ARGS[@]} @@ -1429,11 +1431,16 @@ pbuild.build_module() { "since the dependency '$m' is ${release_of_dependency}" fi - std::info "Loading module: ${m}\n" + std::info "Loading module: ${m}" eval $( "${MODULECMD}" bash load "${m}" ) done } + std::info \ + "%s " \ + "${module_name}/${module_version}:" \ + ${with_modules:+with ${with_modules[@]}} \ + "building ..." MODULECMD="${PMODULES_HOME}/bin/modulecmd" [[ -x ${MODULECMD} ]] || \ std::die 2 "No such file or executable -- '${MODULECMD}'" @@ -1470,6 +1477,12 @@ pbuild.build_module() { pbuild.init_env "${module_name}" "${module_version}" pbuild::make_all + std::info \ + "%s " \ + "${module_name}/${module_version}:" \ + ${with_modules:+with ${with_modules[@]}} \ + "done!" + std::info "* * * * *\n" } pbuild.bootstrap() { diff --git a/Pmodules/libstd.bash b/Pmodules/libstd.bash index a2db280..be491b6 100644 --- a/Pmodules/libstd.bash +++ b/Pmodules/libstd.bash @@ -7,8 +7,8 @@ std::log() { local -ri fd=$1 local -r fmt="$2" shift 2 - printf -- "$fmt" "$@" 1>&$fd - echo + printf -- "${fmt}" "$@" 1>&$fd + printf -- "\n" 1>&$fd } std::info() { diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index b2fb27a..676e083 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -346,7 +346,7 @@ subcommand_load() { output+="module load ${line[@]:3} ${line[0]}\n" done < <(subcommand_search "${m}" -a --no-header 2>&1) if [[ -n "${output}" ]]; then - std::info "\nTry with one of the following command(s):\n" + std::info "\nTry with one of the following command(s):" std::die 3 "${output}\n" fi } @@ -479,7 +479,7 @@ subcommand_load() { fi fi if [[ ! "${found}" ]]; then - std::info "%s %s: module unavailable -- %s\n" \ + std::info "%s %s: module unavailable -- %s" \ "${CMD}" 'load' "${m}" [[ ${verbosity_lvl} == 'verbose' ]] && output_load_hints std::die 3 "" @@ -540,7 +540,7 @@ subcommand_load() { "${m}") if [[ ${verbosity_lvl} != silent ]] && \ [[ ${release} != stable ]]; then - std::info "%s\n" "${msg}" + std::info "%s" "${msg}" fi logger "${msg}" done @@ -803,7 +803,7 @@ subcommand_avail() { esac printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2 done - std::info "\n" + std::info "" } machine_output() { @@ -829,7 +829,7 @@ subcommand_avail() { esac printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2 done - std::info "\n" + std::info "" } human_readable_output() { @@ -1008,47 +1008,47 @@ subcommand_use() { print_info() { local f local r - std::info "Used groups:\n" + std::info "Used groups:" for f in ${UsedGroups//:/ }; do - std::info "\t${f}\n" + std::info "\t${f}" done - std::info "\nUnused groups:\n" + std::info "\nUnused groups:" local _group for _group in "${!GroupDepths[@]}"; do local -i depth=${GroupDepths[${_group}]} if ! group_is_used "${_group}" && (( depth == 0 )); then - std::info "\t${_group}\n" + std::info "\t${_group}" fi done - std::info "\nUsed releases:\n" + std::info "\nUsed releases:" for r in ${UsedReleases//:/ }; do - std::info "\t${r}\n" + std::info "\t${r}" done - std::info "\nUnused releases:\n" + std::info "\nUnused releases:" for r in ${PMODULES_DEFINED_RELEASES//:/ }; do if ! release_is_used $r; then - std::info "\t${r}\n" + std::info "\t${r}" fi done - std::info "\nUsed flags:\n" + std::info "\nUsed flags:" for flag in "${!UseFlags[@]}"; do - std::info "\t${flag}\n" + std::info "\t${flag}" done - std::info "\nAdditonal directories in MODULEPATH:\n" + std::info "\nAdditonal directories in MODULEPATH:" let n=0 for (( i=0; i<${#modulepath[@]}; i++)); do if [[ ! ${modulepath[i]} =~ ${PMODULES_ROOT} ]]; then - std::info "\t${modulepath[i]}\n" + std::info "\t${modulepath[i]}" let n+=1 fi done if (( n == 0 )); then - std::info "\tnone\n" + std::info "\tnone" fi - std::info "\n" + std::info "" } use () { @@ -1554,7 +1554,7 @@ subcommand_search() { out+="$d/" done out+="${line[0]}" - std::info "${out}\n" + std::info "${out}" done < <("${sort}" -k 1,1 -k 4,4 -k 5,5 "${tmpfile}" | \ awk "${with_modules}") elif [[ "${opt_print_csv}" == "yes" ]]; then From 408f7d72680643947934fac23cad12039c2e2260 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 4 Mar 2021 09:37:53 +0100 Subject: [PATCH 3/3] do not build deprecated versions/variants if not forced --- Pmodules/libpbuild.bash | 71 ++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index bc82224..7b48df0 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -1160,20 +1160,31 @@ pbuild::make_all() { check_supported_os check_supported_compilers set_full_module_name_and_prefix - if [[ "${module_release}" == 'removed' ]]; then - remove_module - elif [[ ! -d "${PREFIX}" ]] || \ - [[ "${force_rebuild}" == 'yes' ]]; then - build_module - else - std::info \ - "%s %s\n" \ - "${module_name}/${module_version}:" \ - "already exists, not rebuilding ..." - if [[ "${opt_update_modulefiles}" == "yes" ]]; then - install_modulefile + if module_exists "${module_name}/${module_version}" \ + && [[ ${forece_rebuild} != 'yes' ]]; then + if [[ "${module_release}" == 'removed' ]]; then + remove_module + else + std::info \ + "%s " \ + "${module_name}/${module_version}:" \ + ${with_modules:+with ${with_modules[@]}} \ + "already exists, not rebuilding ..." + if [[ "${opt_update_modulefiles}" == "yes" ]]; then + install_modulefile + fi + install_release_file + fi + else + if [[ "${module_release}" == 'deprecated' ]]; then + std::info \ + "%s " "${module_name}/${module_version}:" \ + ${with_modules:+with ${with_modules[@]}} \ + "is deprecated, skiping!" + install_release_file + else + build_module fi - install_release_file fi else build_module @@ -1267,6 +1278,18 @@ pbuild.init_env() { configure_with='undef' } +#.............................................................. +# +# Test whether a module with the given name already exists. +# +# Arguments: +# $1: module name/version +# +module_exists() { + [[ -n $("${MODULECMD}" bash avail -m "$1" \ + 2>&1 1>/dev/null) ]] +} + pbuild.build_module() { module_name="$1" module_version="$2" @@ -1298,24 +1321,6 @@ pbuild.build_module() { # :FIXME: needs testing # build_dependency() { - #.............................................................. - # - # Test whether a module with the given name already exists. - # - # Arguments: - # $1: module name - # - # Notes: - # The passed module name should be NAME/VERSION - # :FIXME: this does not really work in a hierarchical group - # without adding the dependencies... - # - module_exists() { - [[ -n $("${MODULECMD}" bash search -a --no-header "$1" \ - 2>&1 1>/dev/null) ]] - } - - local -r m=$1 std::debug "${m}: module not available" local rels=( ${PMODULES_DEFINED_RELEASES//:/ } ) @@ -1357,10 +1362,10 @@ pbuild.build_module() { [[ -x "${buildscript}" ]] || \ std::die 1 \ "$m: build-block not found!" - "${buildscript}" "${m#*/}" ${args[@]} - module_exists "$m" || \ + if ! "${buildscript}" "${m#*/}" ${args[@]}; then std::die 1 \ "$m: oops: build failed..." + fi } #......................................................................