mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-08-07 11:52:26 +02:00
version specific modulefiles implemented
This commit is contained in:
+75
-44
@@ -47,7 +47,7 @@ error_handler() {
|
|||||||
|
|
||||||
trap "error_handler" ERR
|
trap "error_handler" ERR
|
||||||
|
|
||||||
declare configure_with='undef'
|
declare configure_with='undef'
|
||||||
|
|
||||||
#..............................................................................
|
#..............................................................................
|
||||||
#
|
#
|
||||||
@@ -214,7 +214,7 @@ set_full_module_name_and_prefix() {
|
|||||||
[[ -n ${GROUP} ]] || std::die 1 \
|
[[ -n ${GROUP} ]] || std::die 1 \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
"group not set."
|
"group not set."
|
||||||
|
|
||||||
# build module name
|
# build module name
|
||||||
# :FIXME: this should be read from a configuration file
|
# :FIXME: this should be read from a configuration file
|
||||||
local name=()
|
local name=()
|
||||||
@@ -298,7 +298,7 @@ pbuild::install_docfiles() {
|
|||||||
# $2: optional variable name to return release via upvar
|
# $2: optional variable name to return release via upvar
|
||||||
#
|
#
|
||||||
# Notes:
|
# Notes:
|
||||||
# The passed module name must be NAME/VERSION!
|
# The passed module name must be NAME/VERSION!
|
||||||
#
|
#
|
||||||
pbuild::module_is_avail() {
|
pbuild::module_is_avail() {
|
||||||
local "$2"
|
local "$2"
|
||||||
@@ -357,7 +357,7 @@ pbuild::prep() {
|
|||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $1: store file name with upvar here
|
# $1: store file name with upvar here
|
||||||
# $2: download URL
|
# $2: download URL
|
||||||
# $3: output filename (can be empty string)
|
# $3: output filename (can be empty string)
|
||||||
# $4...: download directories
|
# $4...: download directories
|
||||||
#
|
#
|
||||||
@@ -378,7 +378,7 @@ pbuild::prep() {
|
|||||||
"${url}"
|
"${url}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_hash_sum() {
|
check_hash_sum() {
|
||||||
local -r fname="$1"
|
local -r fname="$1"
|
||||||
local -r expected_hash_sum="$2"
|
local -r expected_hash_sum="$2"
|
||||||
@@ -657,7 +657,7 @@ pbuild::post_install() {
|
|||||||
pbuild::make_all() {
|
pbuild::make_all() {
|
||||||
source "${BUILD_SCRIPT}"
|
source "${BUILD_SCRIPT}"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
local -r logfile="${BUILDBLOCK_DIR}/pbuild.log"
|
local -r logfile="${BUILDBLOCK_DIR}/pbuild.log"
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -668,7 +668,7 @@ pbuild::make_all() {
|
|||||||
rm -f "${logfile}"
|
rm -f "${logfile}"
|
||||||
if [[ "${verbose}" == 'yes' ]]; then
|
if [[ "${verbose}" == 'yes' ]]; then
|
||||||
exec > >(tee -a "${logfile}")
|
exec > >(tee -a "${logfile}")
|
||||||
else
|
else
|
||||||
exec > >(cat >> "${logfile}")
|
exec > >(cat >> "${logfile}")
|
||||||
fi
|
fi
|
||||||
exec 2> >(tee -a "${logfile}" >&2)
|
exec 2> >(tee -a "${logfile}" >&2)
|
||||||
@@ -719,9 +719,32 @@ pbuild::make_all() {
|
|||||||
"Not available for ${COMPILER}."
|
"Not available for ${COMPILER}."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#......................................................................
|
||||||
|
find_modulefile() {
|
||||||
|
local "$1"
|
||||||
|
local fnames=()
|
||||||
|
fnames+=( "modulefile-${V_MAJOR}" )
|
||||||
|
fnames+=( "modulefile-${V_MAJOR}.${V_MINOR}" )
|
||||||
|
fnames+=( "modulefile-${V_MAJOR}.${V_MINOR}.${V_PATCHLVL}" )
|
||||||
|
fnames+=( "modulefile" )
|
||||||
|
local fname=''
|
||||||
|
local modulefile=''
|
||||||
|
for fname in "${fnames[@]}"; do
|
||||||
|
if [[ -r "${BUILDBLOCK_DIR}/${fname}" ]]; then
|
||||||
|
modulefile="${BUILDBLOCK_DIR}/${fname}"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
std::upvar $1 "${modulefile}"
|
||||||
|
[[ -n "${modulefile}" ]]
|
||||||
|
}
|
||||||
|
|
||||||
#......................................................................
|
#......................................................................
|
||||||
# non-redefinable post-install
|
# non-redefinable post-install
|
||||||
post_install() {
|
post_install() {
|
||||||
|
#..............................................................
|
||||||
|
# install the doc-files specified in the build-script
|
||||||
|
#
|
||||||
install_doc() {
|
install_doc() {
|
||||||
test -n "${MODULE_DOCFILES}" || return 0
|
test -n "${MODULE_DOCFILES}" || return 0
|
||||||
local -r docdir="${PREFIX}/${_DOCDIR}/${module_name}"
|
local -r docdir="${PREFIX}/${_DOCDIR}/${module_name}"
|
||||||
@@ -739,20 +762,27 @@ pbuild::make_all() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#..............................................................
|
#..............................................................
|
||||||
# install build-block
|
# install build-block files
|
||||||
|
# - modulefile
|
||||||
|
# - build-script
|
||||||
|
# - build dependencies
|
||||||
|
#
|
||||||
# Skip installation if modulefile does not exist.
|
# Skip installation if modulefile does not exist.
|
||||||
|
#
|
||||||
install_pmodules_files() {
|
install_pmodules_files() {
|
||||||
test -r "${BUILDBLOCK_DIR}/modulefile" || return 0
|
local modulefile=''
|
||||||
|
find_modulefile modulefile || return 0
|
||||||
|
|
||||||
local -r target_dir="${PREFIX}/share/$GROUP/${module_name}"
|
local -r target_dir="${PREFIX}/share/$GROUP/${module_name}"
|
||||||
install -m 0756 \
|
mkdir -p "${target_dir}"
|
||||||
-d "${target_dir}/files"
|
|
||||||
install -m0444 \
|
install -m0444 \
|
||||||
"${BUILD_SCRIPT}" \
|
"${BUILD_SCRIPT}" \
|
||||||
"${target_dir}"
|
"${target_dir}"
|
||||||
install -m0444 \
|
install -m0444 \
|
||||||
"${BUILDBLOCK_DIR}/modulefile" \
|
"${modulefile}" \
|
||||||
"${target_dir}"
|
"${target_dir}"
|
||||||
|
#install -m 0755 \
|
||||||
|
# -d "${target_dir}/files"
|
||||||
#install -m0444 \
|
#install -m0444 \
|
||||||
# "${variants_file}" \
|
# "${variants_file}" \
|
||||||
# "${target_dir}/files"
|
# "${target_dir}/files"
|
||||||
@@ -785,20 +815,20 @@ pbuild::make_all() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#..............................................................
|
||||||
# sometimes we need an system depended post-install
|
# for Linux we need a special post-install to solve the
|
||||||
|
# multilib problem with LIBRARY_PATH on 64-bit systems
|
||||||
post_install_linux() {
|
post_install_linux() {
|
||||||
std::info \
|
std::info \
|
||||||
"%s %s\n" \
|
"%s %s\n" \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
"running post-installation for ${OS} ..."
|
"running post-installation for ${OS} ..."
|
||||||
cd "${PREFIX}"
|
cd "${PREFIX}"
|
||||||
# solve multilib problem with LIBRARY_PATH
|
|
||||||
# on 64bit Linux
|
|
||||||
[[ -d "lib" ]] && [[ ! -d "lib64" ]] && ln -s lib lib64
|
[[ -d "lib" ]] && [[ ! -d "lib64" ]] && ln -s lib lib64
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#..............................................................
|
||||||
cd "${BUILD_DIR}"
|
cd "${BUILD_DIR}"
|
||||||
[[ "${OS}" == "Linux" ]] && post_install_linux
|
[[ "${OS}" == "Linux" ]] && post_install_linux
|
||||||
install_doc
|
install_doc
|
||||||
@@ -813,14 +843,26 @@ pbuild::make_all() {
|
|||||||
"${PREFIX}/${FNAME_IDEPS}" \
|
"${PREFIX}/${FNAME_IDEPS}" \
|
||||||
"${install_dependencies[@]}"
|
"${install_dependencies[@]}"
|
||||||
fi
|
fi
|
||||||
|
if [[ "${bootstrap}" == 'no' ]]; then
|
||||||
|
install_modulefile
|
||||||
|
install_release_file
|
||||||
|
fi
|
||||||
|
cleanup_build
|
||||||
|
cleanup_src
|
||||||
|
std::info \
|
||||||
|
"%s %s\n" \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"Done ..."
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#......................................................................
|
#......................................................................
|
||||||
# Install modulefile
|
# Install modulefile
|
||||||
install_modulefile() {
|
install_modulefile() {
|
||||||
local -r src="${BUILDBLOCK_DIR}/modulefile"
|
|
||||||
if [[ ! -r "${src}" ]]; then
|
local src=''
|
||||||
|
find_modulefile src
|
||||||
|
if (( $? != 0 )); then
|
||||||
std::info \
|
std::info \
|
||||||
"%s %s\n" \
|
"%s %s\n" \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
@@ -853,7 +895,7 @@ pbuild::make_all() {
|
|||||||
# directory where to install release file
|
# directory where to install release file
|
||||||
local -r dstdir=${dst%/*}
|
local -r dstdir=${dst%/*}
|
||||||
mkdir -p "${dstdir}"
|
mkdir -p "${dstdir}"
|
||||||
|
|
||||||
local -r release_file="${dst%/*}/.release-${module_version}"
|
local -r release_file="${dst%/*}/.release-${module_version}"
|
||||||
|
|
||||||
if [[ -r "${release_file}" ]]; then
|
if [[ -r "${release_file}" ]]; then
|
||||||
@@ -913,7 +955,7 @@ pbuild::make_all() {
|
|||||||
};
|
};
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
build_target() {
|
build_target() {
|
||||||
local dir="$1" # src or build directory, depends on target
|
local dir="$1" # src or build directory, depends on target
|
||||||
local target="$2" # prep, configure, compile or install
|
local target="$2" # prep, configure, compile or install
|
||||||
@@ -936,9 +978,9 @@ pbuild::make_all() {
|
|||||||
for t in "${targets[@]}"; do
|
for t in "${targets[@]}"; do
|
||||||
# We cd into the dir before calling the function -
|
# We cd into the dir before calling the function -
|
||||||
# just to be sure we are in the right directory.
|
# just to be sure we are in the right directory.
|
||||||
#
|
#
|
||||||
# Executing the function in a sub-process doesn't
|
# Executing the function in a sub-process doesn't
|
||||||
# work because in some function global variables
|
# work because in some function global variables
|
||||||
# might/need to be set.
|
# might/need to be set.
|
||||||
#
|
#
|
||||||
cd "${dir}"
|
cd "${dir}"
|
||||||
@@ -989,19 +1031,8 @@ pbuild::make_all() {
|
|||||||
mkdir -p "${PREFIX}"
|
mkdir -p "${PREFIX}"
|
||||||
build_target "${BUILD_DIR}" install
|
build_target "${BUILD_DIR}" install
|
||||||
post_install
|
post_install
|
||||||
|
|
||||||
[[ "${build_target}" == "install" ]] && return 0
|
|
||||||
|
|
||||||
install_modulefile
|
|
||||||
install_release_file
|
|
||||||
cleanup_build
|
|
||||||
cleanup_src
|
|
||||||
std::info \
|
|
||||||
"%s %s\n" \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"Done ..."
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_module() {
|
remove_module() {
|
||||||
if [[ -d "${PREFIX}" ]]; then
|
if [[ -d "${PREFIX}" ]]; then
|
||||||
std::info \
|
std::info \
|
||||||
@@ -1089,17 +1120,17 @@ pbuild.init_env() {
|
|||||||
V_PATCHLVL='' # third number in version string (or empty)
|
V_PATCHLVL='' # third number in version string (or empty)
|
||||||
V_RELEASE='' # module release (or empty)
|
V_RELEASE='' # module release (or empty)
|
||||||
USE_FLAGS='' # architectures (or empty)
|
USE_FLAGS='' # architectures (or empty)
|
||||||
|
|
||||||
local tmp=''
|
local tmp=''
|
||||||
|
|
||||||
if [[ "$v" =~ "_" ]]; then
|
if [[ "$v" =~ "_" ]]; then
|
||||||
tmp="${v#*_}"
|
tmp="${v#*_}"
|
||||||
USE_FLAGS=":${tmp//_/:}:"
|
USE_FLAGS=":${tmp//_/:}:"
|
||||||
v="${v%%_*}"
|
v="${v%%_*}"
|
||||||
fi
|
fi
|
||||||
V_PKG="${v%%-*}" # version without the release number
|
V_PKG="${v%%-*}" # version without the release number
|
||||||
V_RELEASE="${v#*-}" # release number
|
V_RELEASE="${v#*-}" # release number
|
||||||
|
|
||||||
case "${V_PKG}" in
|
case "${V_PKG}" in
|
||||||
*.*.* )
|
*.*.* )
|
||||||
V_MAJOR="${V_PKG%%.*}"
|
V_MAJOR="${V_PKG%%.*}"
|
||||||
@@ -1125,7 +1156,7 @@ pbuild.init_env() {
|
|||||||
|
|
||||||
# P and V can be used in the build-script, so we have to set them here
|
# P and V can be used in the build-script, so we have to set them here
|
||||||
P="${module_name}"
|
P="${module_name}"
|
||||||
V="${module_version}"
|
V="${module_version}"
|
||||||
parse_version "${module_version}"
|
parse_version "${module_version}"
|
||||||
|
|
||||||
SOURCE_URLS=()
|
SOURCE_URLS=()
|
||||||
@@ -1237,7 +1268,7 @@ pbuild.build_module() {
|
|||||||
std::die 1 \
|
std::die 1 \
|
||||||
"$m: oops: build failed..."
|
"$m: oops: build failed..."
|
||||||
}
|
}
|
||||||
|
|
||||||
#......................................................................
|
#......................................................................
|
||||||
#
|
#
|
||||||
# Load build- and run-time dependencies.
|
# Load build- and run-time dependencies.
|
||||||
@@ -1273,11 +1304,11 @@ pbuild.build_module() {
|
|||||||
fi
|
fi
|
||||||
is_loaded "$m" && continue
|
is_loaded "$m" && continue
|
||||||
|
|
||||||
# 'module avail' might output multiple matches if module
|
# 'module avail' might output multiple matches if module
|
||||||
# name and version are not fully specified or in case
|
# name and version are not fully specified or in case
|
||||||
# modules with and without a release number exist.
|
# modules with and without a release number exist.
|
||||||
# Example:
|
# Example:
|
||||||
# mpc/1.1.0 and mpc/1.1.0-1. Since we get a sorted list
|
# mpc/1.1.0 and mpc/1.1.0-1. Since we get a sorted list
|
||||||
# from 'module avail' and the full version should be set
|
# from 'module avail' and the full version should be set
|
||||||
# in the variants file, we look for the first exact
|
# in the variants file, we look for the first exact
|
||||||
# match.
|
# match.
|
||||||
@@ -1305,7 +1336,7 @@ pbuild.build_module() {
|
|||||||
"release cannot be set to '${module_release}'" \
|
"release cannot be set to '${module_release}'" \
|
||||||
"since the dependency '$m' is ${release_of_dependency}"
|
"since the dependency '$m' is ${release_of_dependency}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
std::info "Loading module: ${m}\n"
|
std::info "Loading module: ${m}\n"
|
||||||
module load "${m}"
|
module load "${m}"
|
||||||
done
|
done
|
||||||
@@ -1357,7 +1388,7 @@ pbuild.bootstrap() {
|
|||||||
bootstrap='yes'
|
bootstrap='yes'
|
||||||
|
|
||||||
pbuild.init_env "${module_name}" "${module_version}"
|
pbuild.init_env "${module_name}" "${module_version}"
|
||||||
|
|
||||||
MODULECMD=$(which true)
|
MODULECMD=$(which true)
|
||||||
GROUP='Tools'
|
GROUP='Tools'
|
||||||
PREFIX="${PMODULES_ROOT}/${GROUP}/Pmodules/${PMODULES_VERSION}"
|
PREFIX="${PMODULES_ROOT}/${GROUP}/Pmodules/${PMODULES_VERSION}"
|
||||||
|
|||||||
Reference in New Issue
Block a user