Commit f1f8acf4 authored by gsell's avatar gsell

Merge branch '47-runtime-module-dependencies' into 'master'

Resolve "Runtime module dependencies"

Closes #47

See merge request !57
parents ed5ac6f4 0f21df5b
......@@ -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
......
......@@ -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}"
......
......@@ -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}"
}
#......................................................................
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment