From 75f48ba6ab052729c1dec5021733487b98b7c184 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 28 Sep 2015 17:45:30 +0200 Subject: [PATCH] Pmodules: - templates moved to ${module_group}/${PMODULES_TEMPLATE_DIR} --- Bootstrap/Pmodules/libpbuild.bash | 19 +++++++++++++------ Bootstrap/Pmodules/libpmodules.bash | 1 - Bootstrap/Pmodules/modmanage.bash.in | 21 +++++++++++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Bootstrap/Pmodules/libpbuild.bash b/Bootstrap/Pmodules/libpbuild.bash index 00db6b1..7d3814d 100644 --- a/Bootstrap/Pmodules/libpbuild.bash +++ b/Bootstrap/Pmodules/libpbuild.bash @@ -49,9 +49,6 @@ pbuild::add_to_group() { if [[ -z ${1} ]]; then std::die 42 "${FUNCNAME}: Missing group argument." fi - if [[ ! -d ${PMODULES_ROOT}/${PMODULES_TEMPLATES_DIR}/${1} ]]; then - std::die 43 "${1}: group does not exist." - fi MODULE_GROUP=$1 } @@ -645,9 +642,9 @@ pbuild::make_all() { cd "${dir_name}" local x IFS='/' x=( ${dir_name/${PMODULES_ROOT}\/${MODULE_GROUP}\/} ) - local n=${#x[@]} - local -r _target="../"$(eval printf "../%.s" \ - {1..${n}})${PMODULES_TEMPLATES_DIR##*/}/"${MODULE_GROUP}/${P}/modulefile" + local -i n=${#x[@]} + local _target=$(eval printf "../%.s" {1..${n}}) + _target+="${PMODULES_TEMPLATES_DIR}/${P}/modulefile" ln -fs "${_target}" "${MODULE_NAME##*/}" ) fi @@ -655,6 +652,15 @@ pbuild::make_all() { echo "${MODULE_RELEASE}" > "${release_file}" } + ############################################################################## + install_modulefile() { + local -r src="${BUILD_BLOCK_DIR}/modulefile" + local -r dst="${PMODULES_ROOT}/${MODULE_GROUP}/${PMODULES_TEMPLATES_DIR}/${P}" + + std::info "${MODULE_NAME}: installing modulefile in '${dst}'" + install -m 0444 "${src}" "${dst}" + } + ############################################################################## # # here we really start with make_all() @@ -729,6 +735,7 @@ pbuild::make_all() { set_legacy_link fi set_link + install_modulefile fi return 0 } diff --git a/Bootstrap/Pmodules/libpmodules.bash b/Bootstrap/Pmodules/libpmodules.bash index db19b96..b1b6f2a 100644 --- a/Bootstrap/Pmodules/libpmodules.bash +++ b/Bootstrap/Pmodules/libpmodules.bash @@ -24,7 +24,6 @@ pmodules::check_directories() { [[ -d "${src_prefix}" ]] && [[ -d "${src_prefix}/${PMODULES_CONFIG_DIR}" ]] && - [[ -d "${src_prefix}/${PMODULES_TEMPLATES_DIR}" ]] && [[ -d "${src_prefix}/Tools/Pmodules/${PMODULES_VERSION}" ]] || std::die 1 " Error: the module environment '${src_prefix}' has not been initialized properly!" } diff --git a/Bootstrap/Pmodules/modmanage.bash.in b/Bootstrap/Pmodules/modmanage.bash.in index 015fd48..aa79385 100755 --- a/Bootstrap/Pmodules/modmanage.bash.in +++ b/Bootstrap/Pmodules/modmanage.bash.in @@ -184,6 +184,21 @@ sync_module() { $DRY rsync --links --perms --recursive \ "${src_releasefile}" "${target_releasefile}" 2>/dev/null|| return $? fi + + # copy modulefile template + local -a rel_modulefile_splitted + std::split_fname rel_modulefile_splitted "${rel_modulefile}" + local -r module_group="${rel_modulefile_splitted[0]}" + local -r module_name="${rel_modulefile_splitted[-2]}" + + local -r template="${module_group}/${PMODULES_TEMPLATES_DIR}/${module_name}/" + local -r src_template="${src_prefix}/${template}" + local -r target_template="${target_prefix}/${template}" + if [[ -e "${src_template}" ]]; then + $DRY mkdir -p "${target_template}" + $DRY rsync --links --perms --recursive \ + "${src_template}" "${target_template}" 2>/dev/null|| return $? + fi } # @@ -199,12 +214,6 @@ sync_config() { "${src}" "${dst}" 2>/dev/null || return $? sed -i.bak "s/PMODULES_VERSION=\(.*\)/PMODULES_VERSION=${PMODULES_VERSION}/" "${dst}/environment.bash" echo - - src="$1/${PMODULES_TEMPLATES_DIR}/" - dst="$2/${PMODULES_TEMPLATES_DIR}/" - $DRY rsync --recursive --links --perms --delete --exclude="${src}/.git*" \ - "${src}" "${dst}" 2>/dev/null || return $? - echo } #