From 7fe59f99e287ef54ea041eab8448b7bc4a242a36 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 17 Sep 2019 13:54:41 +0200 Subject: [PATCH] libpbuild.bash: check supported system, os and compiler - functions pbuild::supported_os() and pbuild::supported_compiler() added - bugfix in check of supported system --- Pmodules/libpbuild.bash | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 32d6a3d..e0fe47e 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -159,12 +159,36 @@ pbuild::compile_in_sourcetree() { # Check whether the script is running on a supported OS. # # Arguments: -# $@: supported opertating systems (as printed by 'uname -s') +# $@: supported opertating systems (something like RHEL6, macOS10.14, ...). +# Default is all. # pbuild::supported_systems() { SUPPORTED_SYSTEMS+=( "$@" ) } +############################################################################## +# +# Check whether the script is running on a supported OS. +# +# Arguments: +# $@: supported opertating systems (like Linux, Darwin). +# Default is all. +# +pbuild::supported_os() { + SUPPORTED_OS+=( "$@" ) +} + +############################################################################## +# +# Check whether the loaded compiler is supported. +# +# Arguments: +# $@: supported compiler (like GCC, Intel, PGI). +# Default is all. +# +pbuild::supported_compiler() { + SUPPORTED_COMPILERS+=( "$@" ) +} #...................................................................... # # compute full module name and installation prefix @@ -653,13 +677,35 @@ pbuild::make_all() { check_supported_systems() { [[ -z "${SUPPORTED_SYSTEMS}" ]] && return 0 for sys in "${SUPPORTED_SYSTEMS[@]}"; do - [[ ${sys} == ${system} ]] && return 0 + [[ ${sys,,} == ${system,,} ]] && return 0 done std::die 1 \ "%s " "${module_name}/${module_version}:" \ "Not available for ${system}." } + #...................................................................... + check_supported_os() { + [[ -z "${SUPPORTED_OS}" ]] && return 0 + for os in "${SUPPORTED_OS[@]}"; do + [[ ${os,,} == ${OS,,} ]] && return 0 + done + std::die 1 \ + "%s " "${module_name}/${module_version}:" \ + "Not available for ${OS}." + } + + #...................................................................... + check_supported_compilers() { + [[ -z "${SUPPORTED_COMPILERS}" ]] && return 0 + for compiler in "${SUPPORTED_COMPILERS[@]}"; do + [[ ${compiler,,} == ${COMPILER,,} ]] && return 0 + done + std::die 1 \ + "%s " "${module_name}/${module_version}:" \ + "Not available for ${COMPILER}." + } + #...................................................................... # non-redefinable post-install post_install() { @@ -976,6 +1022,8 @@ pbuild::make_all() { # setup module specific environment if [[ "${bootstrap}" == 'no' ]]; then check_supported_systems + check_supported_os + check_supported_compilers set_full_module_name_and_prefix if [[ "${module_release}" == 'removed' ]]; then remove_module @@ -1061,6 +1109,8 @@ pbuild.init_env() { SOURCE_NAMES=() CONFIGURE_ARGS=() SUPPORTED_SYSTEMS=() + SUPPORTED_OS=() + SUPPORTED_COMPILERS=() PATCH_FILES=() PATCH_STRIPS=() PATCH_STRIP_DEFAULT='1'