From 80ece1c8f64fbb5790aa17f40f1b76ccbc24a863 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 14:55:36 +0200 Subject: [PATCH 01/17] modbuild: extendable hierarchy definition via configuration file - the definition of module hierarchies can now be done in a configuration file. - The former settings are now defaults which can be overriden. --- Pmodules/libpbuild.bash | 198 +++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 113 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 7b48df0..6ca95d2 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -183,9 +183,6 @@ pbuild.verbose() { verbose="$1" } -# module name including path in hierarchy and version -# (ex: 'gcc/6.1.0/openmpi/1.10.2' for openmpi compiled with gcc 6.1.0) -declare -x fully_qualified_module_name='' # group this module is in (ex: 'Programming') declare -x GROUP='' @@ -245,76 +242,6 @@ pbuild::supported_os() { pbuild::supported_compilers() { SUPPORTED_COMPILERS+=( "$@" ) } -#...................................................................... -# -# compute full module name and installation prefix -# -# The following variables are expected to be set: -# GROUP module group -# P module name -# V module version -# variables defining the hierarchical environment like -# COMPILER and COMPILER_VERSION -# -# The following variables are set in this function -# fully_qualified_module_name -# PREFIX -# -set_full_module_name_and_prefix() { - join_by() { - local IFS="$1" - shift - echo "$*" - } - - [[ -n ${GROUP} ]] || std::die 1 \ - "${module_name}/${module_version}:" \ - "group not set." - - # build module name - # :FIXME: this should be read from a configuration file - local name=() - case ${GROUP} in - Compiler ) - name+=( "${COMPILER}/${COMPILER_VERSION}" ) - name+=( "${module_name}/${module_version}" ) - ;; - MPI ) - name+=( "${COMPILER}/${COMPILER_VERSION}" ) - name+=( "${MPI}/${MPI_VERSION}" ) - name+=( "${module_name}/${module_version}" ) - ;; - HDF5 ) - name+=( "${COMPILER}/${COMPILER_VERSION}" ) - name+=( "${MPI}/${MPI_VERSION}" ) - name+=( "${HDF5}/${HDF5_VERSION}" ) - name+=( "${module_name}/${module_version}" ) - ;; - OPAL ) - name+=( "${COMPILER}/${COMPILER_VERSION}" ) - name+=( "${MPI}/${MPI_VERSION}" ) - name+=( "${OPAL}/${OPAL_VERSION}" ) - name+=( "${module_name}/${module_version}" ) - ;; - HDF5_serial ) - name+=( "${COMPILER}/${COMPILER_VERSION}" ) - name+=( "hdf5_serial/${HDF5_SERIAL_VERSION}" ) - name+=( "${module_name}/${module_version}" ) - ;; - * ) - name+=("${module_name}/${module_version}" ) - ;; - esac - - # set full module name - fully_qualified_module_name=$( join_by '/' "${name[@]}" ) - # set PREFIX of module - PREFIX="${PMODULES_ROOT}/${GROUP}" - local -i i=0 - for ((i=${#name[@]}-1; i >= 0; i--)); do - PREFIX+="/${name[i]}" - done -} ############################################################################## # @@ -330,7 +257,6 @@ pbuild::add_to_group() { "${FUNCNAME}: missing group argument." fi GROUP="$1" - set_full_module_name_and_prefix } ############################################################################## @@ -722,6 +648,10 @@ pbuild::make_all() { set -e local -r logfile="${BUILDBLOCK_DIR}/pbuild.log" + # module name including path in hierarchy and version + # (ex: 'gcc/6.1.0/openmpi/1.10.2' for openmpi compiled with gcc 6.1.0) + local modulefile_dir='' + local modulefile_name='' # # To be able to set environment variables in one of the 'pbuild::TARGET' @@ -783,6 +713,74 @@ pbuild::make_all() { } #...................................................................... + # + # compute full module name and installation prefix + # + # The following variables are expected to be set: + # GROUP module group + # P module name + # V module version + # variables defining the hierarchical environment like + # COMPILER and COMPILER_VERSION + # + # The following variables are set in this function + # modulefile_dir + # modulefile_name + # PREFIX + # + set_full_module_name_and_prefix() { + join_by() { + local IFS="$1" + shift + echo "$*" + } + + [[ -n ${GROUP} ]] || std::die 1 \ + "${module_name}/${module_version}:" \ + "group not set." + + # define defaults if not set in configuration file + : ${Compiler_HIERARCHY:='${COMPILER}/${COMPILER_VERSION}'} + : ${CUDA_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} cuda/${CUDA_VERSION}'} + : ${MPI_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} ${MPI}/${MPI_VERSION}'} + : ${HDF5_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} ${MPI}/${MPI_VERSION} hdf5/${HDF5_VERSION}'} + : ${HDF5_SERIAL_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} hdf5_serial/${HDF5_SERIAL_VERSION}'} + + # evaluate + local names=() + local vname="${GROUP}_HIERARCHY" + if [[ -n ${!vname} ]]; then + names=( $(eval echo ${!vname}) ) + fi + + modulefile_dir=$(join_by '/' \ + "${PMODULES_ROOT}/${GROUP}/${PMODULES_MODULEFILES_DIR}" \ + "${names[@]}" \ + "${module_name}") + modulefile_name="${modulefile_dir}/${module_version}" + PREFIX="${PMODULES_ROOT}/${GROUP}/${module_name}/${module_version}" + local -i i=0 + for ((i=${#names[@]}-1; i >= 0; i--)); do + PREFIX+="/${names[i]}" + done + } + + #...................................................................... + # Select the modulefile to install. Modulefiles can be versioned like + # modulefile-10.2.0 + # modulefile-10.2 + # modulefile-10 + # modulefile + # the most specific modulefile will be selected. Example: + # For a version 10.2.1 the file moduelfile-10.2 would be selected. + # + # Arguments: + # $1 upvar to return the filename + # + # Used gloabal variables: + # VERSIONS + # BUILDBLOCK_DIR + # find_modulefile() { local "$1" local fname='' @@ -924,9 +922,11 @@ pbuild::make_all() { } #...................................................................... - # Install modulefile + # Install modulefile in ${PMODULES_ROOT}/${GROUP}/modulefiles/... + # + # Arguments + # none install_modulefile() { - local src='' find_modulefile src if (( $? != 0 )); then @@ -936,34 +936,16 @@ pbuild::make_all() { "skipping modulefile installation ..." return fi - # assemble name of modulefile - local dst="${PMODULES_ROOT}/" - dst+="${GROUP}/" - dst+="${PMODULES_MODULEFILES_DIR}/" - dst+="${fully_qualified_module_name}" - - # directory where to install modulefile - local -r dstdir=${dst%/*} - std::info \ "%s " \ "${module_name}/${module_version}:" \ - "installing modulefile in '${dstdir}' ..." - mkdir -p "${dstdir}" - install -m 0444 "${src}" "${dst}" + "installing modulefile '${modulefile_name}' ..." + mkdir -p "${modulefile_dir}" + install -m 0444 "${src}" "${modulefile_name}" } install_release_file() { - local dst="${PMODULES_ROOT}/" - dst+="${GROUP}/" - dst+="${PMODULES_MODULEFILES_DIR}/" - dst+="${fully_qualified_module_name}" - - # directory where to install release file - local -r dstdir=${dst%/*} - mkdir -p "${dstdir}" - - local -r release_file="${dst%/*}/.release-${module_version}" + local -r release_file="${modulefile_dir}/.release-${module_version}" if [[ -r "${release_file}" ]]; then local release @@ -1121,24 +1103,14 @@ pbuild::make_all() { "removing all files in '${PREFIX}' ..." [[ "${dry_run}" == 'no' ]] && rm -rf ${PREFIX} fi - - # assemble name of modulefile - local dst="${PMODULES_ROOT}/" - dst+="${GROUP}/" - dst+="${PMODULES_MODULEFILES_DIR}/" - dst+="${fully_qualified_module_name}" - - # directory where to install modulefile - local -r dstdir=${dst%/*} - - if [[ -e "${dst}" ]]; then + if [[ -e "${modulefile_name}" ]]; then std::info \ "%s " \ "${module_name}/${module_version}:" \ - "removing modulefile '${dst}' ..." - [[ "${dry_run}" == 'no' ]] && rm -v "${dst}" + "removing modulefile '${modulefile_name}' ..." + [[ "${dry_run}" == 'no' ]] && rm -v "${modulefile_name}" fi - local release_file="${dstdir}/.release-${module_version}" + local release_file="${modulefile_dir}/.release-${module_version}" if [[ -e "${release_file}" ]]; then std::info \ "%s " \ @@ -1146,7 +1118,7 @@ pbuild::make_all() { "removing release file '${release_file}' ..." [[ "${dry_run}" == 'no' ]] && rm -v "${release_file}" fi - rmdir -p "${dstdir}" 2>/dev/null || : + rmdir -p "${modulefile_dir}" 2>/dev/null || : } ######################################################################## From aca3e2c8b597e8fdd2f4d1a1ce6e95c0530d2122 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:05:26 +0200 Subject: [PATCH 02/17] libstd: unused std::upvars() removed --- Pmodules/libstd.bash | 66 -------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/Pmodules/libstd.bash b/Pmodules/libstd.bash index be491b6..eb8525d 100644 --- a/Pmodules/libstd.bash +++ b/Pmodules/libstd.bash @@ -205,72 +205,6 @@ std::upvar() { fi } - -# Assign variables one scope above the caller -# Usage: local varname [varname ...] && -# upvars [-v varname value] | [-aN varname [value ...]] ... -# Available OPTIONS: -# -aN Assign next N values to varname as array -# -v Assign single value to varname -# Return: 1 if error occurs -# Example: -# -# f() { local a b; g a b; declare -p a b; } -# g() { -# local c=( foo bar ) -# local "$1" "$2" && upvars -v $1 A -a${#c[@]} $2 "${c[@]}" -# } -# f # Ok: a=A, b=(foo bar) -# -std::upvars() { - if ! (( $# )); then - echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname"\ - "value] | [-aN varname [value ...]] ..." 1>&2 - return 2 - fi - while (( $# )); do - case $1 in - -a*) - # Error checking - [[ ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing"\ - "number specifier" 1>&2; return 1; } - printf %d "${1#-a}" &> /dev/null || { echo "bash:"\ - "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2 - return 1; } - # Assign array of -aN elements - [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && - shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\ - "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; } - ;; - -v) - # Assign single value - [[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && - shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing"\ - "argument(s)" 1>&2; return 1; } - ;; - --help) echo "\ -Usage: local varname [varname ...] && - ${FUNCNAME[0]} [-v varname value] | [-aN varname [value ...]] ... -Available OPTIONS: --aN VARNAME [value ...] assign next N values to varname as array --v VARNAME value assign single value to varname ---help display this help and exit ---version output version information and exit" - return 0 ;; - --version) echo "\ -${FUNCNAME[0]}-0.9.dev -Copyright (C) 2010 Freddy Vulto -License GPLv3+: GNU GPL version 3 or later -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - return 0 ;; - *) - echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2 - return 1 ;; - esac - done -} - std.get_os_release_linux() { local lsb_release=$(which lsb_release) local ID='' From 1497ca647de2c73e50c8377d9fb1f0e7b90f9483 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:06:06 +0200 Subject: [PATCH 03/17] version set to 1.0.0rc9 --- config/versions.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/versions.conf b/config/versions.conf index 2311805..442193e 100644 --- a/config/versions.conf +++ b/config/versions.conf @@ -4,5 +4,5 @@ findutils 4.7.0 getopt 1.1.6 gettext 0.21 modules 3.2.10.1 -Pmodules 1.0.0rc8 +Pmodules 1.0.0rc9 Tcl 8.6.10 From f24836958145f559aab41f0a80ff79d02c892ca4 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:07:50 +0200 Subject: [PATCH 04/17] modulecmd: remove tmp file created in module search --- Pmodules/modulecmd.bash.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 563a587..3eaab5f 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -21,6 +21,7 @@ sort=$(PATH=/bin:/usr/bin /usr/bin/which sort) declare -r sort awk=$(PATH=/bin:/usr/bin /usr/bin/which awk) declare -r awk +rm=$(PATH=/bin:/usr/bin /usr/bin/which rm) if [[ $(uname -s) == 'Darwin' ]]; then declare -r getopt="${libexecdir}/getopt" declare -r find="${libexecdir}/find" @@ -1755,7 +1756,7 @@ subcommand_search() { done done print_result "${tmpfile}" - #rm -f "${tmpfile}" + ${rm} -f "${tmpfile}" } while (( $# > 0 )); do From 1cc1db14779f16ed46d4481bfba2089e1f174221 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:09:35 +0200 Subject: [PATCH 05/17] modulecmd: unloading/purging a Pmodules module bug fixed - the environment variable PMODULE_HOME must not be unset if a Pmodules module is unloaded or purged --- Pmodules/modulecmd.bash.in | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 3eaab5f..a7d220d 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -609,7 +609,15 @@ subcommand_unload() { "${CMD}" "${subcommand}" \ "missing argument" fi - + + # The module() function uses PMODULES_HOME to call modulecmd. + # If a Pmodules module is unloaded this evnvironment variable + # will be unset. In consequence the module() function would + # fail. Instead of comparing the name of the module to unload + # with 'Pmodules', we save the value and set it at the end of + # the loop again, if it has been unset. + local saved_home="${PMODULES_HOME}" + local arg for arg in "${args[@]}"; do local output=$("${modulecmd}" "${Shell}" 'unload' "${arg}") @@ -623,6 +631,10 @@ subcommand_unload() { ;; esac done + if [[ -z ${PMODULES_HOME} ]]; then + PMODULES_HOME=${saved_home} + export_env 'PMODULES_HOME' + fi } ############################################################################## @@ -1398,10 +1410,15 @@ subcommand_purge() { "${CMD}" "${subcommand}" \ "no arguments allowd" fi + # we cannot unset PMODULES_HOME, otherwise the module function + # would fail. + local saved_home="${PMODULES_HOME}" "${modulecmd}" "${Shell}" "${subcommand}" reset_modulepath reset_used_groups - export_env MODULEPATH + PMODULES_HOME="${saved_home}" + + export_env MODULEPATH PMODULES_HOME } ############################################################################## From 96a7ca406a3720c0bf20803b3bcc8af64dd91ceb Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:12:50 +0200 Subject: [PATCH 06/17] modulecmd: use upvar to return avail modules --- Pmodules/modulecmd.bash.in | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index a7d220d..ba2e4fc 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -741,17 +741,17 @@ subcommand_show() { # modulename1 release1 modulename2 release2 ... # get_available_modules() { - local -r module="$1" - local -r use_releases="${2:-${UsedReleases}}" - shift 2 - local -a dirs=( "$@" ) + local var="$1" + local -r module="$2" + local -r use_releases="${3:-${UsedReleases}}" + shift 3 # in the for loop below we use $@ to loop over the directories local -a mods=() local release local dir='' - for dir in "${dirs[@]}"; do - test -d "${dir}" || return 0 + for dir in "$@"; do + test -d "${dir}" || continue { cd "${dir}" while read mod; do @@ -763,7 +763,7 @@ get_available_modules() { done < <(${find} -L * \( -type f -o -type l \) -not -name ".*" -ipath "${module}*") } done - echo "${mods[@]}" + std::upvar ${var} "${mods[@]}" } ############################################################################## @@ -945,10 +945,11 @@ subcommand_avail() { local string for string in "${pattern[@]}"; do for dir in "${modulepath[@]}"; do - mods=( $( get_available_modules \ - "${string}" \ - "${opt_use_releases}" \ - "${dir}" ) ) + get_available_modules \ + mods \ + "${string}" \ + "${opt_use_releases}" \ + "${dir}" [[ ${#mods[@]} == 0 ]] && continue ${output_function} done @@ -1732,11 +1733,12 @@ subcommand_search() { # with respect to the requested releases # tmpfile: module/version release group group- # dependencies... - local mods=( $( get_available_modules \ - "${module}" \ - "${opt_use_releases}" \ - "${modulepath[@]}" \ - ) ) + local mods + get_available_modules \ + mods \ + "${module}" \ + "${opt_use_releases}" \ + "${modulepath[@]}" \ for (( i=0; i<${#mods[@]}; i+=3 )); do local name=${mods[i]} From b2c51afe39494c8b10f6bcfffadd0367a41938ac Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:15:07 +0200 Subject: [PATCH 07/17] modulecmd: update usage output for sub-command search --- Pmodules/modulecmd.bash.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index ba2e4fc..8501996 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1524,6 +1524,12 @@ USAGE: for modules whose name match the argument. SWITCHES: + -a|--all-releases + Search within all releases. + + --all-deps + Show all dependecies + --no-header Suppress output of a header. @@ -1532,8 +1538,8 @@ SWITCHES: switch multiple times. Without this switch, the used releases will be searched. - -a|--all-releases - Search within all releases. + --verbose + vebose output --with=STRING Search for modules compiled with modules matching string. The @@ -1543,9 +1549,6 @@ SWITCHES: lists all modules in the hierarchy compiled with gcc 4.8.3. - --verbose - vebose output - --wrap wrap output ' From 85894a6f222caeb18064cb5b4366030a5a3424c4 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:16:25 +0200 Subject: [PATCH 08/17] modbuild: add option to pass use-flags --- Pmodules/modbuild.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index fbff037..2d30689 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -229,6 +229,13 @@ parse_args() { --system=* ) opt_system="${1/*=}" ;; + --use-flags ) + USE_FLAGS="y:$2:" + shift + ;; + --use-flags=* ) + USE_FLAGS=":${1/--use-flags=}:" + ;; --with ) opt_with_modules+=( "$2" ) shift From 34af38d21687daf99bdd52f4b92a3e9517dc96c7 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:17:01 +0200 Subject: [PATCH 09/17] modbuild: libpbuild_dyn.bash is not required any more --- Pmodules/modbuild.in | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index 2d30689..6aa9543 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -416,11 +416,6 @@ pbuild.update_modulefiles "${opt_update_modulefiles}" pbuild.system "${opt_system}" pbuild.verbose "${opt_verbose}" -source libpbuild_dyn.bash || \ - std::die 3 "Oops: cannot source library -- '$_'" - -# source build configuration, -# must be done before sourcing libpbuild! if [[ "${opt_bootstrap}" == 'yes' ]]; then test -d "${BUILDBLOCK_DIR}/../../config" && PATH+=":$_" else From e1bd5e8986e930c3ad56e6063f49764ac0351383 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:18:24 +0200 Subject: [PATCH 10/17] libpbuild: handle use-flags passed as argument to modbuild --- Pmodules/libpbuild.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 6ca95d2..78e085f 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -1182,13 +1182,13 @@ pbuild.init_env() { V_MINOR='' # second number in version string (or empty) V_PATCHLVL='' # third number in version string (or empty) V_RELEASE='' # module release (or empty) - USE_FLAGS='' # architectures (or empty) + : ${USE_FLAGS:=''} # architectures (or empty) local tmp='' if [[ "$v" =~ "_" ]]; then tmp="${v#*_}" - USE_FLAGS=":${tmp//_/:}:" + USE_FLAGS+=":${tmp//_/:}:" v="${v%%_*}" fi V_PKG="${v%%-*}" # version without the release number From 1068fafab1fc15301542c08991193474f204bdcb Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:19:17 +0200 Subject: [PATCH 11/17] libpbuild: handle error if tar fails in pbuild::prep() --- Pmodules/libpbuild.bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 78e085f..0ae9142 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -429,13 +429,13 @@ pbuild::prep() { unpack() { local -r file="$1" local -r dir="${2:-${SRC_DIR}}" - ( - if [[ -n "${dir}" ]]; then - mkdir -p "${dir}" - cd "${dir}" - fi - tar -xv --strip-components 1 -f "${file}" - ) + tar --directory="${dir}" -xv --strip-components 1 -f "${file}" || { + rm -f "${file}" + std::die 4 \ + "%s " \ + "${module_name}/${module_version}:" \ + "cannot unpack sources!" + } } patch_sources() { From 36086fdd5724f1f73ae6b080f38eeb0d919ae406 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:37:58 +0200 Subject: [PATCH 12/17] libpbuild: handle error if appling a patch fails in pbuild::prep() --- Pmodules/libpbuild.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 0ae9142..07fee3c 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -447,7 +447,11 @@ pbuild::prep() { "${module_name}/${module_version}:" \ "Appling patch '${PATCH_FILES[_i]}' ..." local -i strip_val="${PATCH_STRIPS[_i]:-${PATCH_STRIP_DEFAULT}}" - patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}" + patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}" || \ + std::die 4 \ + "%s " \ + "${module_name}/${module_version}:" \ + "error patching sources!" done } if [[ -z "${SOURCE_URLS}" ]]; then From c8d2e065aaf00aae4985931cfbca4c077b8aa065 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:41:58 +0200 Subject: [PATCH 13/17] libpbuild: handle error if make fails while compiling or installing --- Pmodules/libpbuild.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 07fee3c..336b9f6 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -586,7 +586,10 @@ pbuild::pre_compile() { } pbuild::compile() { - make -j${JOBS} + make -j${JOBS} || \ + std::die 3 \ + "%s " "${module_name}/${module_version}:" \ + "compilation failed!" } pbuild::post_compile() { @@ -598,7 +601,10 @@ pbuild::pre_install() { } pbuild::install() { - make install + make install || \ + std::die 3 \ + "%s " "${module_name}/${module_version}:" \ + "compilation failed!" } pbuild::install_shared_libs() { From 837bf74522284385d203e5077043c9121cf22163 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:45:06 +0200 Subject: [PATCH 14/17] libpbuild: improve test whether a module exist or not --- Pmodules/libpbuild.bash | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 336b9f6..cc7b03e 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -1142,8 +1142,9 @@ pbuild::make_all() { check_supported_os check_supported_compilers set_full_module_name_and_prefix - if module_exists "${module_name}/${module_version}" \ - && [[ ${forece_rebuild} != 'yes' ]]; then + if [[ -e "${modulefile_name}" ]] \ + && [[ -d ${PREFIX} ]] \ + && [[ ${force_rebuild} != 'yes' ]]; then if [[ "${module_release}" == 'removed' ]]; then remove_module else @@ -1260,18 +1261,6 @@ 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" From 3c08327cdbcdb668d95bf59eece1e748b53679fe Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:45:57 +0200 Subject: [PATCH 15/17] libpbuild: add a bit more comments to post_install function --- Pmodules/libpbuild.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index cc7b03e..424dbb9 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -806,11 +806,17 @@ pbuild::make_all() { } #...................................................................... - # non-redefinable post-install + # non-redefinable post-install. Install: + # - documentation files as defined in the build-script + # - modulefile and file with release + # . post_install() { #.............................................................. # install the doc-files specified in the build-script # + # Arguments: + # none + # install_doc() { if [[ -z "${MODULE_DOCFILES}" ]]; then for f in ${VERSIONS[@]/#/pbuild::install_docfiles_}; do From 6dee9b74daf1e8a2ed826678dc521fb1ad0e544f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:47:10 +0200 Subject: [PATCH 16/17] libpbuild: don't print module name and all deps when we are done --- Pmodules/libpbuild.bash | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 424dbb9..0bc0820 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -1459,11 +1459,6 @@ 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" } From 7f089633c7401881ca7d82b0ab94a0dc5b801585 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 19 Apr 2021 15:48:18 +0200 Subject: [PATCH 17/17] libpbuild: better doc what installing build-block files does --- Pmodules/libpbuild.bash | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 0bc0820..3404b63 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -843,12 +843,14 @@ pbuild::make_all() { } #.............................................................. - # install build-block files + # install build-block files # - modulefile # - build-script - # - build dependencies + # - run-time and build dependencies + # in ${PREFIX}/share/${GROUP}/${module_name} # - # Skip installation if modulefile does not exist. + # Arguments: + # none # install_pmodules_files() { local modulefile=''