From 0f21df5b404f2c436c5da65595eb065ebdc9cb92 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 2 Jul 2020 10:28:43 +0200 Subject: [PATCH] install dependencies implemented install dependencies are dependencies which are required at run.time but must not be loaded. Use-cases are for example are Intel and PGI compiler. --- Pmodules/libpbuild.bash | 32 ++++++++++++++++++++++++++++---- Pmodules/modbuild.in | 10 +++++----- Pmodules/modmanage.bash.in | 20 +++++++++++++------- config/versions.conf | 2 +- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 0a34c5b..4aabf69 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -20,6 +20,15 @@ unset __path #............................................................................. # disable auto-echo feature of 'cd' unset CDPATH + +#............................................................................. +# define constants +declare -r BNAME_VARIANTS='variants' +declare -r FNAME_RDEPS='.dependencies' +declare -r FNAME_IDEPS='.install_dependencies' +declare -r FNAME_BDEPS='.build_dependencies' + +#............................................................................. declare -A SOURCE_UNPACK_DIRS #............................................................................. @@ -749,16 +758,17 @@ pbuild::make_all() { #.............................................................. # write run time dependencies to file write_runtime_dependencies() { - local -r fname="${PREFIX}/.dependencies" + local -r fname="$1" + shift std::info \ "%s %s\n" \ "${module_name}/${module_version}:" \ "writing run-time dependencies to ${fname} ..." local dep echo -n "" > "${fname}" - for dep in "${runtime_dependencies[@]}"; do + for dep in "$@"; do [[ -z $dep ]] && continue - if [[ ! $dep =~ .*/.* ]]; then + if [[ ! $dep == */* ]]; then # no version given: derive the version # from the currently loaded module dep=$( "${MODULECMD}" bash list -t 2>&1 1>/dev/null \ @@ -786,7 +796,16 @@ pbuild::make_all() { [[ "${OS}" == "Linux" ]] && post_install_linux install_doc install_pmodules_files - write_runtime_dependencies + if [[ -n "${runtime_dependencies}" ]]; then + write_runtime_dependencies \ + "${PREFIX}/${FNAME_RDEPS}" \ + "${runtime_dependencies[@]}" + fi + if [[ -n "${install_dependencies}" ]]; then + write_runtime_dependencies \ + "${PREFIX}/${FNAME_IDEPS}" \ + "${install_dependencies[@]}" + fi return 0 } @@ -1125,6 +1144,7 @@ pbuild.build_module() { # used in pbuild::make_all declare bootstrap='no' declare -a runtime_dependencies=() + declare -a install_dependencies=() #...................................................................... # @@ -1236,6 +1256,10 @@ pbuild.build_module() { elif [[ "${m:0:2}" == "r:" ]]; then m=${m#*:} # remove 'r:' runtime_dependencies+=( "$m" ) + elif [[ "${m:0:2}" == "R:" ]]; then + m=${m#*:} # remove 'R:' + install_dependencies+=( "$m" ) + continue else runtime_dependencies+=( "$m" ) fi diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index 1e6831e..fbff037 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -56,7 +56,7 @@ SELECT VARIANT TO BUILD: --system Specify the system for selecting a variants. Defaults to the - output of 'uname -s'. + OS version and release like 'rhel6'. --with=P/V Select variant to compile. Use multiple '--with' arguments @@ -282,10 +282,10 @@ find_variants_files(){ shopt -q nullglob || : local -i nullglob_set=$? shopt -s nullglob - local files=( "${BUILDBLOCK_DIR}"/*/variants\.${opt_system} ) - files+=( "${BUILDBLOCK_DIR}"/*/variants.$(uname -s) ) + local files=( "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}"\.${opt_system} ) + files+=( "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}.$(uname -s)" ) local f - for f in "${BUILDBLOCK_DIR}"/*/variants; do + for f in "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}"; do [[ -e "${f}.${opt_system}" ]] \ || [[ -e "${f}.$(uname -s)" ]] \ || files+=( "$f" ) @@ -317,7 +317,7 @@ expand_variants_file(){ # skip empty and comment lines [[ -z ${toks} ]] && continue [[ ${toke:0:1} == '#' ]] && continue - + # ignore first (module/version) and second (release) token deps=( ${toks[*]:2} ) expand_deps "${toks[0]} ${toks[1]}" "${deps[@]}" done < "${input}" diff --git a/Pmodules/modmanage.bash.in b/Pmodules/modmanage.bash.in index f0c1e87..9a59809 100755 --- a/Pmodules/modmanage.bash.in +++ b/Pmodules/modmanage.bash.in @@ -573,12 +573,15 @@ subcommand_install() { # compute filename with dependencies of given module local -i i=0 n=0 std::split_fname items n "${modulefile}" - local fname_dependencies="${src_prefix}/${items[0]}" + local prefix="${src_prefix}/${items[0]}" for (( i = n-2; i >= 2; i-=2 )); do - fname_dependencies+="/${items[$i]}/${items[i+1]}" + prefix+="/${items[$i]}/${items[i+1]}" done - fname_dependencies+='/.dependencies' - [[ -r ${fname_dependencies} ]] || return 0 + local tmpfile=$(mktemp /tmp/Pmodules_XXXXXX) + + local fname_dependencies="${prefix}/.dependencies" + [[ -r "${prefix}/.dependencies" ]] && cat "$_" > "${tmpfile}" + [[ -r "${prefix}/.install_dependencies" ]] && cat "$_" >> "${tmpfile}" # loop over all dependecies local dep @@ -588,7 +591,8 @@ subcommand_install() { [[ -z ${dep} ]] && continue # search for module with current modulepath and remember - local modulename=$(find "${modulepath[@]}" -path "*/${dep}" 2>/dev/null | head -n 1 ) + local modulename=$(find "${modulepath[@]}" -path "*/${dep}" \ + 2>/dev/null | head -n 1 ) [[ -n ${modulename} ]] || \ std::die 3 "Oops: required module '${dep}' not found!" modulename=${modulename/${src_prefix}\/} @@ -596,11 +600,13 @@ subcommand_install() { resolve_dependencies_of_module "${modulename}" # append new node in hierarchy to modulepath if [[ -n ${map_to_family[${dep}]} ]]; then - local path="${src_prefix}/${map_to_family[${dep}]}/${PMODULES_MODULEFILES_DIR}/" + local path="${src_prefix}/${map_to_family[${dep}]}/" + path+="${PMODULES_MODULEFILES_DIR}/" path+="${modulename/*\/${PMODULES_MODULEFILES_DIR}\/}" modulepath+=( "${path}" ) fi - done < "${fname_dependencies}" + done < "${tmpfile}" + rm "${tmpfile}" } #...................................................................... diff --git a/config/versions.conf b/config/versions.conf index f6eedf4..12b07c4 100644 --- a/config/versions.conf +++ b/config/versions.conf @@ -3,5 +3,5 @@ coreutils 8.31 getopt 1.1.6 gettext 0.19.8 modules 3.2.10.1 -Pmodules 1.0.0rc6 +Pmodules 1.0.0rc7 Tcl 8.6.9