diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index e10c0a6..d993b45 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}" @@ -1158,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 @@ -1265,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" @@ -1296,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//:/ } ) @@ -1323,7 +1330,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[@]} @@ -1355,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 } #...................................................................... @@ -1429,11 +1436,16 @@ pbuild.build_module() { "since the dependency '$m' is ${release_of_dependency}" fi - std::info "Loading module: ${m}\n" - module load "${m}" + 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}'" @@ -1473,6 +1485,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 8bc9dfb..0a3eb24 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -566,7 +566,7 @@ subcommand_load() { "${m}") if [[ ${verbosity_lvl} != silent ]] && \ [[ ${release} != stable ]]; then - std::info "%s\n" "${msg}" + std::info "%s" "${msg}" fi logger "${msg}" done @@ -969,7 +969,7 @@ subcommand_avail() { esac printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2 done - std::info "\n" + std::info "" } machine_output() { @@ -995,7 +995,7 @@ subcommand_avail() { esac printf "%-20s\t%s\n" "${mod}" "${out}" 1>&2 done - std::info "\n" + std::info "" } human_readable_output() { @@ -1195,11 +1195,11 @@ 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}]} @@ -1208,20 +1208,20 @@ subcommand_use() { 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 local overlay @@ -1242,9 +1242,9 @@ subcommand_use() { fi done if (( n == 0 )); then - std::info "\tnone\n" + std::info "\tnone" fi - std::info "\n" + std::info "" } use () {