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 ...@@ -20,6 +20,15 @@ unset __path
#............................................................................. #.............................................................................
# disable auto-echo feature of 'cd' # disable auto-echo feature of 'cd'
unset CDPATH 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 declare -A SOURCE_UNPACK_DIRS
#............................................................................. #.............................................................................
...@@ -749,16 +758,17 @@ pbuild::make_all() { ...@@ -749,16 +758,17 @@ pbuild::make_all() {
#.............................................................. #..............................................................
# write run time dependencies to file # write run time dependencies to file
write_runtime_dependencies() { write_runtime_dependencies() {
local -r fname="${PREFIX}/.dependencies" local -r fname="$1"
shift
std::info \ std::info \
"%s %s\n" \ "%s %s\n" \
"${module_name}/${module_version}:" \ "${module_name}/${module_version}:" \
"writing run-time dependencies to ${fname} ..." "writing run-time dependencies to ${fname} ..."
local dep local dep
echo -n "" > "${fname}" echo -n "" > "${fname}"
for dep in "${runtime_dependencies[@]}"; do for dep in "$@"; do
[[ -z $dep ]] && continue [[ -z $dep ]] && continue
if [[ ! $dep =~ .*/.* ]]; then if [[ ! $dep == */* ]]; then
# no version given: derive the version # no version given: derive the version
# from the currently loaded module # from the currently loaded module
dep=$( "${MODULECMD}" bash list -t 2>&1 1>/dev/null \ dep=$( "${MODULECMD}" bash list -t 2>&1 1>/dev/null \
...@@ -786,7 +796,16 @@ pbuild::make_all() { ...@@ -786,7 +796,16 @@ pbuild::make_all() {
[[ "${OS}" == "Linux" ]] && post_install_linux [[ "${OS}" == "Linux" ]] && post_install_linux
install_doc install_doc
install_pmodules_files 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 return 0
} }
...@@ -1125,6 +1144,7 @@ pbuild.build_module() { ...@@ -1125,6 +1144,7 @@ pbuild.build_module() {
# used in pbuild::make_all # used in pbuild::make_all
declare bootstrap='no' declare bootstrap='no'
declare -a runtime_dependencies=() declare -a runtime_dependencies=()
declare -a install_dependencies=()
#...................................................................... #......................................................................
# #
...@@ -1236,6 +1256,10 @@ pbuild.build_module() { ...@@ -1236,6 +1256,10 @@ pbuild.build_module() {
elif [[ "${m:0:2}" == "r:" ]]; then elif [[ "${m:0:2}" == "r:" ]]; then
m=${m#*:} # remove 'r:' m=${m#*:} # remove 'r:'
runtime_dependencies+=( "$m" ) runtime_dependencies+=( "$m" )
elif [[ "${m:0:2}" == "R:" ]]; then
m=${m#*:} # remove 'R:'
install_dependencies+=( "$m" )
continue
else else
runtime_dependencies+=( "$m" ) runtime_dependencies+=( "$m" )
fi fi
......
...@@ -56,7 +56,7 @@ SELECT VARIANT TO BUILD: ...@@ -56,7 +56,7 @@ SELECT VARIANT TO BUILD:
--system --system
Specify the system for selecting a variants. Defaults to the Specify the system for selecting a variants. Defaults to the
output of 'uname -s'. OS version and release like 'rhel6'.
--with=P/V --with=P/V
Select variant to compile. Use multiple '--with' arguments Select variant to compile. Use multiple '--with' arguments
...@@ -282,10 +282,10 @@ find_variants_files(){ ...@@ -282,10 +282,10 @@ find_variants_files(){
shopt -q nullglob || : shopt -q nullglob || :
local -i nullglob_set=$? local -i nullglob_set=$?
shopt -s nullglob shopt -s nullglob
local files=( "${BUILDBLOCK_DIR}"/*/variants\.${opt_system} ) local files=( "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}"\.${opt_system} )
files+=( "${BUILDBLOCK_DIR}"/*/variants.$(uname -s) ) files+=( "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}.$(uname -s)" )
local f local f
for f in "${BUILDBLOCK_DIR}"/*/variants; do for f in "${BUILDBLOCK_DIR}"/*/"${BNAME_VARIANTS}"; do
[[ -e "${f}.${opt_system}" ]] \ [[ -e "${f}.${opt_system}" ]] \
|| [[ -e "${f}.$(uname -s)" ]] \ || [[ -e "${f}.$(uname -s)" ]] \
|| files+=( "$f" ) || files+=( "$f" )
...@@ -317,7 +317,7 @@ expand_variants_file(){ ...@@ -317,7 +317,7 @@ expand_variants_file(){
# skip empty and comment lines # skip empty and comment lines
[[ -z ${toks} ]] && continue [[ -z ${toks} ]] && continue
[[ ${toke:0:1} == '#' ]] && continue [[ ${toke:0:1} == '#' ]] && continue
# ignore first (module/version) and second (release) token
deps=( ${toks[*]:2} ) deps=( ${toks[*]:2} )
expand_deps "${toks[0]} ${toks[1]}" "${deps[@]}" expand_deps "${toks[0]} ${toks[1]}" "${deps[@]}"
done < "${input}" done < "${input}"
......
...@@ -573,12 +573,15 @@ subcommand_install() { ...@@ -573,12 +573,15 @@ subcommand_install() {
# compute filename with dependencies of given module # compute filename with dependencies of given module
local -i i=0 n=0 local -i i=0 n=0
std::split_fname items n "${modulefile}" 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 for (( i = n-2; i >= 2; i-=2 )); do
fname_dependencies+="/${items[$i]}/${items[i+1]}" prefix+="/${items[$i]}/${items[i+1]}"
done done
fname_dependencies+='/.dependencies' local tmpfile=$(mktemp /tmp/Pmodules_XXXXXX)
[[ -r ${fname_dependencies} ]] || return 0
local fname_dependencies="${prefix}/.dependencies"
[[ -r "${prefix}/.dependencies" ]] && cat "$_" > "${tmpfile}"
[[ -r "${prefix}/.install_dependencies" ]] && cat "$_" >> "${tmpfile}"
# loop over all dependecies # loop over all dependecies
local dep local dep
...@@ -588,7 +591,8 @@ subcommand_install() { ...@@ -588,7 +591,8 @@ subcommand_install() {
[[ -z ${dep} ]] && continue [[ -z ${dep} ]] && continue
# search for module with current modulepath and remember # 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} ]] || \ [[ -n ${modulename} ]] || \
std::die 3 "Oops: required module '${dep}' not found!" std::die 3 "Oops: required module '${dep}' not found!"
modulename=${modulename/${src_prefix}\/} modulename=${modulename/${src_prefix}\/}
...@@ -596,11 +600,13 @@ subcommand_install() { ...@@ -596,11 +600,13 @@ subcommand_install() {
resolve_dependencies_of_module "${modulename}" resolve_dependencies_of_module "${modulename}"
# append new node in hierarchy to modulepath # append new node in hierarchy to modulepath
if [[ -n ${map_to_family[${dep}]} ]]; then 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}\/}" path+="${modulename/*\/${PMODULES_MODULEFILES_DIR}\/}"
modulepath+=( "${path}" ) modulepath+=( "${path}" )
fi fi
done < "${fname_dependencies}" done < "${tmpfile}"
rm "${tmpfile}"
} }
#...................................................................... #......................................................................
......
...@@ -3,5 +3,5 @@ coreutils 8.31 ...@@ -3,5 +3,5 @@ coreutils 8.31
getopt 1.1.6 getopt 1.1.6
gettext 0.19.8 gettext 0.19.8
modules 3.2.10.1 modules 3.2.10.1
Pmodules 1.0.0rc6 Pmodules 1.0.0rc7
Tcl 8.6.9 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