mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-29 18:59:39 +02:00
modbuild: various fixes and improvments
- option '--all-variants' is not required any more, a version can be passed
as regex
- supress output from un-tar, configure, compile and install if not in
verbose mode
- option '--enable-cleanup' added
- remove src directory after successful build by default
- an equal sign ('=') may prepend a version number passed as argument
- various fixes
- issue with using 'pbuild::use_{autotools,cmake}' outside a "prep"-
function fixed
- installing depending shared libs improved
- abort if a target fails
This commit is contained in:
+281
-236
@@ -1,3 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
#.............................................................................
|
||||
@@ -90,7 +91,7 @@ pbuild.enable_cleanup_build() {
|
||||
enable_cleanup_build="$1"
|
||||
}
|
||||
|
||||
declare enable_cleanup_src='no'
|
||||
declare enable_cleanup_src='yes'
|
||||
pbuild.enable_cleanup_src() {
|
||||
enable_cleanup_src="$1"
|
||||
}
|
||||
@@ -125,6 +126,10 @@ declare PMODULES_DISTFILESDIR="${PMODULES_ROOT}/var/distfiles"
|
||||
pbuild.pmodules_distfilesdir() {
|
||||
PMODULES_DISTFILESDIR="$1"
|
||||
}
|
||||
declare verbose='no'
|
||||
pbuild.verbose() {
|
||||
verbose='yes'
|
||||
}
|
||||
|
||||
# module name including path in hierarchy and version
|
||||
# (ex: 'gcc/6.1.0/openmpi/1.10.2' for openmpi compiled with gcc 6.1.0)
|
||||
@@ -142,16 +147,6 @@ declare -x module_release=''
|
||||
# abs. path is "${PREFIX}/${_docdir}/${module_name}"
|
||||
declare -r _DOCDIR='share/doc'
|
||||
|
||||
# initialize module environment.
|
||||
# in case of bootstrapping the modulecmd does not exist. Setting
|
||||
# it to ':' is save. We check the existence later again.
|
||||
MODULECMD="${PMODULES_HOME}/bin/modulecmd"
|
||||
[[ -x ${MODULECMD} ]] || MODULECMD=':'
|
||||
|
||||
eval $( "${MODULECMD}" bash use unstable )
|
||||
eval $( "${MODULECMD}" bash use deprecated )
|
||||
|
||||
|
||||
#..............................................................................
|
||||
#
|
||||
# The following variables are available in build-blocks and set read-only
|
||||
@@ -325,25 +320,54 @@ pbuild::use_cc() {
|
||||
CC="$1"
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
pbuild::pre_prep() {
|
||||
:
|
||||
}
|
||||
eval "pbuild::pre_prep_${system}() { :; }"
|
||||
|
||||
pbuild::post_prep() {
|
||||
:
|
||||
}
|
||||
eval "pbuild::post_prep_${system}() { :; }"
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Find/download tarball for given module.
|
||||
# If the source URL is given, we look for the file-name specified in
|
||||
# the URL. Otherwise we test for several possible names/extensions.
|
||||
# extract sources. For the time being only tar-files are supported.
|
||||
#
|
||||
# The downloaded file will be stored with the name "${module_name}-${module_version}" and extension
|
||||
# derived from URL. The download directory is the first directory passed.
|
||||
#
|
||||
# Arguments:
|
||||
# $1: store file name with upvar here
|
||||
# $2: download URL
|
||||
# $3: output filename (can be empty string)
|
||||
# $4...: download directories
|
||||
#
|
||||
# Returns:
|
||||
# 0 on success otherwise a value > 0
|
||||
#
|
||||
download_source_file() {
|
||||
pbuild::prep() {
|
||||
#......................................................................
|
||||
#
|
||||
# Find/download tarball for given module.
|
||||
# If the source URL is given, we look for the file-name specified in
|
||||
# the URL. Otherwise we test for several possible names/extensions.
|
||||
#
|
||||
# The downloaded file will be stored with the name "${module_name}-${module_version}" and extension
|
||||
# derived from URL. The download directory is the first directory passed.
|
||||
#
|
||||
# Arguments:
|
||||
# $1: store file name with upvar here
|
||||
# $2: download URL
|
||||
# $3: output filename (can be empty string)
|
||||
# $4...: download directories
|
||||
#
|
||||
# Returns:
|
||||
# 0 on success otherwise a value > 0
|
||||
#
|
||||
download_with_curl() {
|
||||
local -r output="$1"
|
||||
local -r url="$2"
|
||||
curl \
|
||||
-L \
|
||||
--output "${output}" \
|
||||
"${url}"
|
||||
if (( $? != 0 )); then
|
||||
curl \
|
||||
--insecure \
|
||||
--output "${output}" \
|
||||
"${url}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_hash_sum() {
|
||||
local -r fname="$1"
|
||||
local -r expected_hash_sum="$2"
|
||||
@@ -364,75 +388,52 @@ download_source_file() {
|
||||
"hash-sum missmatch for file '%s'" "${fname}"
|
||||
}
|
||||
|
||||
local "$1"
|
||||
local var="$1"
|
||||
local -r url="$2"
|
||||
local fname="$3"
|
||||
shift 3
|
||||
dirs+=( "$@" )
|
||||
download_source_file() {
|
||||
local "$1"
|
||||
local var="$1"
|
||||
local -r url="$2"
|
||||
local fname="$3"
|
||||
shift 3
|
||||
dirs+=( "$@" )
|
||||
|
||||
[[ -n "${fname}" ]] || fname="${url##*/}"
|
||||
local expr='s/.*\(.tar.bz2\|.tbz2\|.tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/'
|
||||
local -r extension=$(echo ${fname} | sed "${expr}")
|
||||
local dir=''
|
||||
dirs+=( 'not found' )
|
||||
for dir in "${dirs[@]}"; do
|
||||
[[ -r "${dir}/${fname}" ]] && break
|
||||
done
|
||||
if [[ "${dir}" == 'not found' ]]; then
|
||||
dir="${dirs[0]}"
|
||||
local -r method="${url%:*}"
|
||||
case "${method}" in
|
||||
http | https | ftp )
|
||||
curl \
|
||||
-L \
|
||||
--output "${dir}/${fname}" \
|
||||
"${url}"
|
||||
if (( $? != 0 )); then
|
||||
curl \
|
||||
--insecure \
|
||||
--output "${dir}/${fname}" \
|
||||
"${url}"
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
std::die 4 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Error in download URL:" \
|
||||
"unknown download method '${method}'!"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
local sha256_sum=''
|
||||
local hash=''
|
||||
for hash in "${SOURCE_SHA256_SUMS[@]}"; do
|
||||
if [[ ${hash} =~ $fname: ]]; then
|
||||
sha256_sum="${hash#*:}"
|
||||
fi
|
||||
done
|
||||
if [[ -n "${sha256_sum}" ]]; then
|
||||
check_hash_sum "${dir}/${fname}" "${sha256_sum}"
|
||||
fi
|
||||
std::upvar "${var}" "${dir}/${fname}"
|
||||
[[ -r "${dir}/${fname}" ]]
|
||||
}
|
||||
[[ -n "${fname}" ]] || fname="${url##*/}"
|
||||
local expr='s/.*\(.tar.bz2\|.tbz2\|.tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/'
|
||||
local -r extension=$(echo ${fname} | sed "${expr}")
|
||||
local dir=''
|
||||
dirs+=( 'not found' )
|
||||
for dir in "${dirs[@]}"; do
|
||||
[[ -r "${dir}/${fname}" ]] && break
|
||||
done
|
||||
if [[ "${dir}" == 'not found' ]]; then
|
||||
dir="${dirs[0]}"
|
||||
local -r method="${url%:*}"
|
||||
case "${method}" in
|
||||
http | https | ftp )
|
||||
download_with_curl "${dir}/${fname}" "${url}"
|
||||
;;
|
||||
* )
|
||||
std::die 4 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Error in download URL:" \
|
||||
"unknown download method '${method}'!"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
local sha256_sum=''
|
||||
local hash=''
|
||||
for hash in "${SOURCE_SHA256_SUMS[@]}"; do
|
||||
if [[ ${hash} =~ $fname: ]]; then
|
||||
sha256_sum="${hash#*:}"
|
||||
fi
|
||||
done
|
||||
if [[ -n "${sha256_sum}" ]]; then
|
||||
check_hash_sum "${dir}/${fname}" "${sha256_sum}"
|
||||
fi
|
||||
std::upvar "${var}" "${dir}/${fname}"
|
||||
[[ -r "${dir}/${fname}" ]]
|
||||
}
|
||||
|
||||
pbuild::pre_prep() {
|
||||
:
|
||||
}
|
||||
eval "pbuild::pre_prep_${system}() { :; }"
|
||||
|
||||
pbuild::post_prep() {
|
||||
:
|
||||
}
|
||||
eval "pbuild::post_prep_${system}() { :; }"
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# extract sources. For the time being only tar-files are supported.
|
||||
#
|
||||
pbuild::prep() {
|
||||
unpack() {
|
||||
unpack() {
|
||||
local -r file="$1"
|
||||
local -r dir="$2"
|
||||
(
|
||||
@@ -519,28 +520,32 @@ pbuild::add_configure_args() {
|
||||
}
|
||||
|
||||
pbuild::use_autotools() {
|
||||
if [[ -r "${SRC_DIR}/configure" ]]; then
|
||||
configure_with='autotools'
|
||||
else
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"${FNCNAME[0]}:" \
|
||||
"autotools configuration not available, aborting..."
|
||||
fi
|
||||
configure_with='autotools'
|
||||
}
|
||||
|
||||
pbuild::use_cmake() {
|
||||
if [[ -r "${SRC_DIR}/CMakeLists.txt" ]]; then
|
||||
configure_with='cmake'
|
||||
else
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"${FNCNAME[0]}:" \
|
||||
"CMake script not available, aborting..."
|
||||
fi
|
||||
configure_with='cmake'
|
||||
}
|
||||
|
||||
pbuild::configure() {
|
||||
case "${configure_with}" in
|
||||
autotools )
|
||||
if [[ ! -r "${SRC_DIR}/configure" ]]; then
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"${FNCNAME[0]}:" \
|
||||
"autotools configuration not available, aborting..."
|
||||
fi
|
||||
;;
|
||||
cmake )
|
||||
if [[ ! -r "${SRC_DIR}/CMakeLists.txt" ]]; then
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"${FNCNAME[0]}:" \
|
||||
"CMake script not available, aborting..."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ -r "${SRC_DIR}/configure" ]] && \
|
||||
[[ "${configure_with}" == 'undef' ]] || \
|
||||
[[ "${configure_with}" == 'autotools' ]]; then
|
||||
@@ -597,17 +602,35 @@ pbuild::install() {
|
||||
|
||||
pbuild::install_shared_libs() {
|
||||
local -r binary="${PREFIX}/$1"
|
||||
local -r pattern="$2"
|
||||
local -r pattern="${2//\//\\/}" # escape slash
|
||||
local -r dstdir="${3:-${PREFIX}/lib}"
|
||||
|
||||
install_shared_libs_Linux() {
|
||||
local libs=( $(ldd "${binary}" | \
|
||||
awk "/ => \// && /${pattern}/ {print \$3}") )
|
||||
cp -avL "${libs[@]}" "${dstdir}"
|
||||
}
|
||||
|
||||
install_shared_libs_Darwin() {
|
||||
# https://stackoverflow.com/questions/33991581/install-name-tool-to-update-a-executable-to-search-for-dylib-in-mac-os-x
|
||||
local libs=( $(otool -L "${binary}" | \
|
||||
awk "/${pattern}/ {print \$1}"))
|
||||
cp -avL "${libs[@]}" "${dstdir}"
|
||||
}
|
||||
|
||||
test -e "${binary}" || \
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"${binary}: does not exist or is not executable!"
|
||||
mkdir -p "${dstdir}"
|
||||
local -r libs=( $(ldd "${binary}" | \
|
||||
awk "/ => \// && /${pattern}/ {print \$3}") )
|
||||
cp -avL "${libs[@]}" "${dstdir}"
|
||||
case "${OS}" in
|
||||
Linux )
|
||||
install_shared_libs_Linux
|
||||
;;
|
||||
Darwin )
|
||||
install_shared_libs_Darwin
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
pbuild::post_install() {
|
||||
@@ -615,53 +638,6 @@ pbuild::post_install() {
|
||||
}
|
||||
eval "pbuild::post_install_${system}() { :; }"
|
||||
|
||||
pbuild::cleanup_build() {
|
||||
[[ "${BUILD_DIR}" == "${SRC_DIR}" ]] && return 0
|
||||
|
||||
# the following two checks we should de earlier!
|
||||
[[ -z "${BUILD_DIR}" ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error:" \
|
||||
"BUILD_DIR is unset or set to empty string"
|
||||
[[ ! -d "/${BUILD_DIR}" ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error: " \
|
||||
"BUILD_DIR=${BUILD_DIR} is not a directory"
|
||||
|
||||
{
|
||||
cd "/${BUILD_DIR}/.."
|
||||
[[ "$(pwd)" == "/" ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error:" \
|
||||
"BUILD_DIR is set to '/'"
|
||||
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Cleaning up '${BUILD_DIR}'..."
|
||||
rm -rf "${BUILD_DIR##*/}"
|
||||
};
|
||||
return 0
|
||||
}
|
||||
|
||||
pbuild::cleanup_src() {
|
||||
[[ -d /${SRC_DIR} ]] || return 0
|
||||
{
|
||||
cd "/${SRC_DIR}/..";
|
||||
[[ $(pwd) == / ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error:" \
|
||||
"SRC_DIR is set to '/'"
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Cleaning up '${SRC_DIR}'..."
|
||||
rm -rf "${SRC_DIR##*/}"
|
||||
};
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# The 'do it all' function.
|
||||
@@ -677,6 +653,7 @@ pbuild::make_all() {
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Module group not set! Aborting ..."
|
||||
|
||||
|
||||
#
|
||||
# helper functions
|
||||
#
|
||||
@@ -760,7 +737,8 @@ pbuild::make_all() {
|
||||
shift
|
||||
done
|
||||
|
||||
local buildscript=$( std::get_abspath "${BUILDBLOCK_DIR}"/../../*/${m/\/*}/build )
|
||||
local path="${BUILDBLOCK_DIR}"/../../*/${m/\/*}/build
|
||||
local buildscript=$(std::get_abspath "${path}")
|
||||
[[ -x "${buildscript}" ]] || \
|
||||
std::die 1 \
|
||||
"$m: build-block not found!"
|
||||
@@ -978,6 +956,42 @@ pbuild::make_all() {
|
||||
echo "${module_release}" > "${release_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_build() {
|
||||
[[ ${enable_cleanup_build} == yes ]] || return 0
|
||||
[[ "${BUILD_DIR}" == "${SRC_DIR}" ]] && return 0
|
||||
{
|
||||
cd "/${BUILD_DIR}/.." || std::die 42 "Internal error"
|
||||
[[ "$(pwd)" == "/" ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error:" \
|
||||
"BUILD_DIR is set to '/'"
|
||||
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Cleaning up '${BUILD_DIR}'..."
|
||||
rm -rf "${BUILD_DIR##*/}"
|
||||
};
|
||||
return 0
|
||||
}
|
||||
|
||||
cleanup_src() {
|
||||
[[ ${enable_cleanup_src} == yes ]] || return 0
|
||||
{
|
||||
cd "/${SRC_DIR}/.." || std::die 42 "Internal error"
|
||||
[[ $(pwd) == / ]] && \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Oops: internal error:" \
|
||||
"SRC_DIR is set to '/'"
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"Cleaning up '${SRC_DIR}'..."
|
||||
rm -rf "${SRC_DIR##*/}"
|
||||
};
|
||||
return 0
|
||||
}
|
||||
|
||||
build_target() {
|
||||
local dir="$1"
|
||||
@@ -991,11 +1005,16 @@ pbuild::make_all() {
|
||||
# work because in some function global variables
|
||||
# might to be set.
|
||||
#
|
||||
cd "${dir}" && "pbuild::pre_${target}_${system}"
|
||||
cd "${dir}" && "pbuild::pre_${target}"
|
||||
cd "${dir}" && "pbuild::${target}"
|
||||
cd "${dir}" && "pbuild::post_${target}_${system}"
|
||||
cd "${dir}" && "pbuild::post_${target}"
|
||||
cd "${dir}" && "pbuild::pre_${target}_${system}" || \
|
||||
std::die 42 "Aborting..."
|
||||
cd "${dir}" && "pbuild::pre_${target}" || \
|
||||
std::die 42 "Aborting..."
|
||||
cd "${dir}" && "pbuild::${target}" || \
|
||||
std::die 42 "Aborting..."
|
||||
cd "${dir}" && "pbuild::post_${target}_${system}" || \
|
||||
std::die 42 "Aborting..."
|
||||
cd "${dir}" && "pbuild::post_${target}" || \
|
||||
std::die 42 "Aborting..."
|
||||
touch "${BUILD_DIR}/.${target}"
|
||||
fi
|
||||
}
|
||||
@@ -1003,6 +1022,12 @@ pbuild::make_all() {
|
||||
#......................................................................
|
||||
# build module ${module_name}/${module_version}
|
||||
build_module() {
|
||||
local -r logfile="${BUILD_DIR}/pbuild.log"
|
||||
if [[ "${verbose}" = 'yes' ]]; then
|
||||
local -r output="/dev/fd/1"
|
||||
else
|
||||
local -r output="/dev/null"
|
||||
fi
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"start building ..."
|
||||
@@ -1011,26 +1036,38 @@ pbuild::make_all() {
|
||||
mkdir -p "${SRC_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
build_target "${SRC_DIR}" prep
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"preparing sources ..."
|
||||
build_target "${SRC_DIR}" prep | tee "${logfile}" > ${output}
|
||||
[[ "${build_target}" == "prep" ]] && return 0
|
||||
|
||||
build_target "${BUILD_DIR}" configure
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"configuring ..."
|
||||
build_target "${BUILD_DIR}" configure | tee "${logfile}" >> ${output}
|
||||
[[ "${build_target}" == "configure" ]] && return 0
|
||||
|
||||
build_target "${BUILD_DIR}" compile
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"compiling ..."
|
||||
build_target "${BUILD_DIR}" compile | tee "${logfile}" >> ${output}
|
||||
[[ "${build_target}" == "compile" ]] && return 0
|
||||
|
||||
std::info \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"installing ..."
|
||||
mkdir -p "${PREFIX}"
|
||||
build_target "${BUILD_DIR}" install
|
||||
build_target "${BUILD_DIR}" install | tee "${logfile}" >> ${output}
|
||||
post_install
|
||||
|
||||
[[ "${build_target}" == "install" ]] && return 0
|
||||
|
||||
install_modulefile
|
||||
install_release_file
|
||||
|
||||
[[ ${enable_cleanup_build} == yes ]] && pbuild::cleanup_build
|
||||
[[ ${enable_cleanup_src} == yes ]] && pbuild::cleanup_src
|
||||
cleanup_build
|
||||
cleanup_src
|
||||
std::info "%s" "${module_name}/${module_version}: Done ..."
|
||||
return 0
|
||||
}
|
||||
remove_module() {
|
||||
@@ -1097,6 +1134,63 @@ pbuild::make_all() {
|
||||
}
|
||||
|
||||
pbuild.init_env() {
|
||||
#......................................................................
|
||||
#
|
||||
# parse the passed version string
|
||||
#
|
||||
# the following global variables will be set in this function:
|
||||
# V_MAJOR
|
||||
# V_MINOR
|
||||
# V_PATCHLVL
|
||||
# V_RELEASE
|
||||
# USE_FLAGS
|
||||
#
|
||||
parse_version() {
|
||||
local v="$1"
|
||||
V_MAJOR='' # first number in version string
|
||||
V_MINOR='' # second number in version string (or empty)
|
||||
V_PATCHLVL='' # third number in version string (or empty)
|
||||
V_RELEASE='' # module release (or empty)
|
||||
USE_FLAGS='' # architectures (or empty)
|
||||
|
||||
local tmp=''
|
||||
|
||||
if [[ "$v" =~ "_" ]]; then
|
||||
tmp="${v#*_}"
|
||||
USE_FLAGS=":${tmp//_/:}:"
|
||||
v="${v%%_*}"
|
||||
fi
|
||||
V_PKG="${v%%-*}" # version without the release number
|
||||
V_RELEASE="${v#*-}" # release number
|
||||
|
||||
case "${V_PKG}" in
|
||||
*.*.* )
|
||||
V_MAJOR="${V_PKG%%.*}"
|
||||
tmp="${V_PKG#*.}"
|
||||
V_MINOR="${tmp%%.*}"
|
||||
V_PATCHLVL="${tmp#*.}"
|
||||
;;
|
||||
*.* )
|
||||
V_MAJOR="${V_PKG%.*}"
|
||||
V_MINOR="${V_PKG#*.}"
|
||||
;;
|
||||
* )
|
||||
V_MAJOR="${V_PKG}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
local -r module_name="$1"
|
||||
local -r module_version="$2"
|
||||
|
||||
SRC_DIR="${TEMP_DIR}/${module_name}-${module_version}/src"
|
||||
BUILD_DIR="${TEMP_DIR}/${module_name}-${module_version}/build"
|
||||
|
||||
# P and V can be used in the build-script, so we have to set them here
|
||||
P="${module_name}"
|
||||
V="${module_version}"
|
||||
parse_version "${module_version}"
|
||||
|
||||
unset C_INCLUDE_PATH
|
||||
unset CPLUS_INCLUDE_PATH
|
||||
unset CPP_INCLUDE_PATH
|
||||
@@ -1130,51 +1224,6 @@ pbuild.init_env() {
|
||||
configure_with='undef'
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
#
|
||||
# parse the passed version string
|
||||
#
|
||||
# the following global variables will be set in this function:
|
||||
# V_MAJOR
|
||||
# V_MINOR
|
||||
# V_PATCHLVL
|
||||
# V_RELEASE
|
||||
# USE_FLAGS
|
||||
#
|
||||
parse_version() {
|
||||
local v="$1"
|
||||
V_MAJOR='' # first number in version string
|
||||
V_MINOR='' # second number in version string (or empty)
|
||||
V_PATCHLVL='' # third number in version string (or empty)
|
||||
V_RELEASE='' # module release (or empty)
|
||||
USE_FLAGS='' # architectures (or empty)
|
||||
|
||||
local tmp=''
|
||||
|
||||
if [[ "$v" =~ "_" ]]; then
|
||||
tmp="${v#*_}"
|
||||
USE_FLAGS=":${tmp//_/:}:"
|
||||
v="${v%%_*}"
|
||||
fi
|
||||
V_PKG="${v%%-*}" # version without the release number
|
||||
V_RELEASE="${v#*-}" # release number
|
||||
|
||||
case "${V_PKG}" in
|
||||
*.*.* )
|
||||
V_MAJOR="${V_PKG%%.*}"
|
||||
tmp="${V_PKG#*.}"
|
||||
V_MINOR="${tmp%%.*}"
|
||||
V_PATCHLVL="${tmp#*.}"
|
||||
;;
|
||||
*.* )
|
||||
V_MAJOR="${V_PKG%.*}"
|
||||
V_MINOR="${V_PKG#*.}"
|
||||
;;
|
||||
* )
|
||||
V_MAJOR="${V_PKG}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
pbuild.build_module() {
|
||||
module_name="$1"
|
||||
@@ -1183,37 +1232,32 @@ pbuild.build_module() {
|
||||
shift 3
|
||||
with_modules=( "$@" )
|
||||
|
||||
MODULECMD="${PMODULES_HOME}/bin/modulecmd"
|
||||
[[ -x ${MODULECMD} ]] || \
|
||||
std::die 2 "No such file or executable -- '${MODULECMD}'"
|
||||
|
||||
# P and V can be used in the build-script, so we have to set them here
|
||||
P="${module_name}"
|
||||
V="${module_version}"
|
||||
|
||||
std::info "%s" "${module_name}/${module_version}: Start building ..."
|
||||
eval $( "${MODULECMD}" bash use unstable )
|
||||
eval $( "${MODULECMD}" bash use deprecated )
|
||||
eval $( "${MODULECMD}" bash purge )
|
||||
# :FIXME: this is a hack!!!
|
||||
# shouldn't this be set in the build-script?
|
||||
eval $( "${MODULECMD}" bash use Libraries )
|
||||
|
||||
pbuild.init_env
|
||||
parse_version "${module_version}"
|
||||
|
||||
SRC_DIR="${TEMP_DIR}/${module_name}-${module_version}/src"
|
||||
BUILD_DIR="${TEMP_DIR}/${module_name}-${module_version}/build"
|
||||
|
||||
pbuild.init_env "${module_name}" "${module_version}"
|
||||
source "${BUILD_SCRIPT}"
|
||||
pbuild::make_all
|
||||
std::info "%s" "${module_name}/${module_version}: Done ..."
|
||||
}
|
||||
|
||||
pbuild.bootstrap() {
|
||||
local -r name="$1"
|
||||
local -r version="$2"
|
||||
local -r module_name="$1"
|
||||
local -r module_version="$2"
|
||||
|
||||
# used in pbuild::make_all
|
||||
bootstrap='yes'
|
||||
|
||||
MODULECMD='/usr/bin/true'
|
||||
pbuild.init_env "${module_name}" "${module_version}"
|
||||
|
||||
MODULECMD=$(which true)
|
||||
GROUP='Tools'
|
||||
PREFIX="${PMODULES_ROOT}/${GROUP}/Pmodules/${PMODULES_VERSION}"
|
||||
|
||||
@@ -1226,7 +1270,8 @@ pbuild.bootstrap() {
|
||||
|
||||
PATH+=":${PREFIX}/bin"
|
||||
PATH+=":${PREFIX}/sbin"
|
||||
pbuild.build_module "${name}" "${version}" 'stable'
|
||||
source "${BUILD_SCRIPT}"
|
||||
pbuild::make_all
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
|
||||
+50
-27
@@ -90,10 +90,6 @@ MISCELLANEOUS OPTIONS:
|
||||
--dry-run
|
||||
Dry run.
|
||||
|
||||
--all-variants
|
||||
Build build all variants. In this case the argument 'version'
|
||||
must be a regular expression.
|
||||
|
||||
--disable-cleanup-build
|
||||
--enable-cleanup-build
|
||||
Cleanup files in the build directory. Default is to remove.
|
||||
@@ -106,7 +102,7 @@ MISCELLANEOUS OPTIONS:
|
||||
|
||||
--disable-cleanup
|
||||
--enable-cleanup
|
||||
Cleanup all files in temporyry directory. Default is to
|
||||
Cleanup all files in temporary directory. Default is to
|
||||
remove all files created during building.
|
||||
|
||||
--distdir
|
||||
@@ -145,6 +141,7 @@ parse_args() {
|
||||
;;
|
||||
-v | --verbose )
|
||||
trap 'echo "$BASH_COMMAND"' DEBUG
|
||||
pbuild.verbose 'yes'
|
||||
;;
|
||||
--debug )
|
||||
set -x
|
||||
@@ -161,9 +158,6 @@ parse_args() {
|
||||
--dry-run )
|
||||
pbuild.dry_run 'yes'
|
||||
;;
|
||||
--all-variants )
|
||||
opt_all_variants='yes'
|
||||
;;
|
||||
--config )
|
||||
build_config="$2"
|
||||
shift 1
|
||||
@@ -171,6 +165,10 @@ parse_args() {
|
||||
--config=* )
|
||||
build_config="${1#*=}"
|
||||
;;
|
||||
--enable-cleanup )
|
||||
pbuild.enable_cleanup_build 'yes'
|
||||
pbuild.enable_cleanup_src 'yes'
|
||||
;;
|
||||
--disable-cleanup )
|
||||
pbuild.enable_cleanup_build 'no'
|
||||
pbuild.enable_cleanup_src 'no'
|
||||
@@ -230,7 +228,7 @@ parse_args() {
|
||||
-* )
|
||||
std::die 1 "Invalid option -- '$1'"
|
||||
;;
|
||||
[0-9]* )
|
||||
[=0-9]* )
|
||||
versions+=( "$1" )
|
||||
;;
|
||||
'')
|
||||
@@ -268,6 +266,35 @@ find_variants_files(){
|
||||
std::upvar "$1" "${files[@]}"
|
||||
}
|
||||
|
||||
shopt -s extglob
|
||||
expand_variants_file(){
|
||||
expand_deps(){
|
||||
local text="$1"
|
||||
shift
|
||||
local deps=( "${@}" )
|
||||
echo "${deps[@]}"
|
||||
if (( ${#deps[@]} == 0 )); then
|
||||
echo ${text}
|
||||
else
|
||||
local list
|
||||
eval list=( ${deps[0]} )
|
||||
for dep in ${list[*]}; do
|
||||
expand_deps "${text} ${dep}" "${deps[@]:1}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
local -r input="$1"
|
||||
while read -a toks; do
|
||||
# skip empty and comment lines
|
||||
[[ -z ${toks} ]] && continue
|
||||
[[ ${toke:0:1} == '#' ]] && continue
|
||||
|
||||
deps=( ${toks[*]:2} )
|
||||
expand_deps "${toks[0]} ${toks[1]}" "${deps[@]}"
|
||||
done < "${input}"
|
||||
}
|
||||
|
||||
build_modules() {
|
||||
local name="$1"
|
||||
local version="$2"
|
||||
@@ -280,31 +307,33 @@ build_modules() {
|
||||
local with_modules=( $* )
|
||||
local files
|
||||
find_variants_files files
|
||||
|
||||
# if we have to build a dependency, we might have less dependencies
|
||||
# on it. Or in other words: the list of "with modules" might be
|
||||
# overdetermined. In the loop below we check, which dependencies
|
||||
# specified with '--with' are required.
|
||||
local m
|
||||
local pattern="/^${name}\/${version}[[:blank:]]/"
|
||||
for m in "${with_modules[@]}"; do
|
||||
# check if this module is really a dependency
|
||||
if [[ -n $(awk "/${m%/*}[\/ ]/" "${files}") ]]; then
|
||||
if [[ -n $(awk "/${m%/*}[\/ ]/" "${files[@]}") ]]; then
|
||||
pattern+=" && /${m//\//\\/}/"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
local variants=()
|
||||
local variants_files=()
|
||||
local line=''
|
||||
local lines=()
|
||||
for f in "${files[@]}"; do
|
||||
local line=''
|
||||
while read line; do
|
||||
lines+=( "${line}" )
|
||||
done < <(awk "${pattern}" "${f}")
|
||||
variants+=( "${lines[@]}" )
|
||||
local i
|
||||
for ((i=0; i<${#lines[@]}; i++)); do
|
||||
variants+=( "${line}" )
|
||||
variants_files+=( "$f" )
|
||||
done
|
||||
done < <(expand_variants_file "${f}" | awk "${pattern}")
|
||||
# here we should add a check, whether the version of the
|
||||
# found variants are in the right variants files. Example:
|
||||
# a variant for hdf5/1.10.4 is not allowed in a variants file
|
||||
# for version 1.8
|
||||
# for version 1.8. For this we need the mapping of a variant
|
||||
# to the variants file in array 'variants_files'
|
||||
done
|
||||
if (( ${#variants[@]} == 0 )); then
|
||||
std::info "%s " \
|
||||
@@ -366,15 +395,9 @@ if [[ "${opt_bootstrap}" == 'yes' ]]; then
|
||||
fi
|
||||
|
||||
#
|
||||
# we are NOT bootstrapping!
|
||||
# else
|
||||
#
|
||||
|
||||
# if option '--all-variants' is set, we loop over all variants matching the given
|
||||
# versions
|
||||
for version in "${versions[@]}"; do
|
||||
if [[ "${opt_all_variants}" == "no" ]]; then
|
||||
version="=${version}"
|
||||
fi
|
||||
build_modules "${module_name}" "${version}" "${opt_with_modules[@]}"
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user