diff --git a/build.sh b/build.sh
index 98a304b32202cdcc8726da9ded87747e0abd26ee..81d347fdff5ba405df65dbdb69cab87ca51d7182 100755
--- a/build.sh
+++ b/build.sh
@@ -11,6 +11,8 @@
# Author: Tao Lin <lintao@ihep.ac.cn>
##############################################################################
+THISSCRITDIR=$(dirname $(readlink -e "${BASH_SOURCE[0]}" 2>/dev/null) 2>/dev/null) # Darwin readlink doesnt accept -e
+
function info:() {
echo "INFO: $*" 1>&2
}
@@ -74,8 +76,9 @@ function run-cmake() {
fi
cd $blddir
+ local installarea=$THISSCRITDIR/InstallArea/$CEPCSW_LCG_PLATFORM
- cmake .. -DHOST_BINARY_TAG=${lcg_platform} ${bldgen} || {
+ cmake .. -DCMAKE_INSTALL_PREFIX=$installarea -DHOST_BINARY_TAG=${lcg_platform} ${bldgen} || {
error: "Failed to cmake"
return 1
}
@@ -115,6 +118,7 @@ function run-install() {
# Parse the command line options
##############################################################################
+# The following envvars should be defined after source setup scripts
# The current default platform
lcg_platform=${CEPCSW_LCG_PLATFORM:-x86_64-centos7-gcc11-opt}
lcg_version=${CEPCSW_LCG_VERSION:-103.0.2}
diff --git a/setup.sh b/setup.sh
index 0d748d0418697b68a50b211b4414c2bc493bdb8a..9e89b690cfe147d4dbe3d9facfc0b8e6cedfbd1a 100644
--- a/setup.sh
+++ b/setup.sh
@@ -32,19 +32,32 @@ function cepcsw-external() {
}
function setup-external() {
- local f=$(cepcsw-external)/setup-${CEPCSW_LCG_VERSION}.sh
- if [ ! -f $f ]; then
- error: "Failed to find setup script $f"
+ local f
+
+ # try new os
+ f=$(cepcsw-external)/setup-${CEPCSW_LCG_VERSION}-${CEPCSW_LCG_OS}.sh
+ if [ -f "$f" ]; then
+ info: "Setup CEPCSW externals (os: $CEPCSW_LCG_OS, lcg: $CEPCSW_LCG_VERSION): $f"
+ source $f
return
fi
- info: "Setup CEPCSW externals: $f"
- source $f
+ # legacy
+ if [ "$CEPCSW_LCG_OS" = "centos7" ]; then
+ f=$(cepcsw-external)/setup-${CEPCSW_LCG_VERSION}.sh
+ if [ -f "$f" ]; then
+ info: "Setup CEPCSW externals (os: $CEPCSW_LCG_OS, lcg: $CEPCSW_LCG_VERSION): $f"
+ source $f
+ return
+ fi
+ fi
+
+ error: "Failed to find setup script for CEPCSW_LCG_VERSION: ${CEPCSW_LCG_VERSION}, CEPCSW_LCG_OS: ${CEPCSW_LCG_OS}"
}
-function setup-install-area() {
- local installarea=$THISSCRITDIR/InstallArea
+function setup-install-area() {
+ local installarea=$THISSCRITDIR/InstallArea/$CEPCSW_LCG_PLATFORM
if [ ! -d "$installarea" ]; then
info: "The InstallArea is not created yet. Please run ./build.sh first, then source setup.sh again."
return
@@ -64,16 +77,58 @@ function setup-install-area() {
info: "Setup CEPCSW: $installarea"
}
+function detect-os() {
+ local os=$(source /etc/os-release; echo $ID)
+ local os_ver=$(source /etc/os-release; echo $VERSION_ID)
+
+ local cepcsw_lcg_os
+
+ case "$os" in
+ almalinux)
+ cepcsw_lcg_os=el
+ ;;
+ centos)
+ cepcsw_lcg_os=centos
+ ;;
+ esac
+
+ case "$os_ver" in
+ 7*)
+ cepcsw_lcg_os=${cepcsw_lcg_os}7
+ ;;
+ 9*)
+ cepcsw_lcg_os=${cepcsw_lcg_os}9
+ ;;
+ esac
+
+ export CEPCSW_LCG_OS=${cepcsw_lcg_os}
+
+}
+
##############################################################################
# Parse the command line options
##############################################################################
-# CEPCSW_LCG_VERSION=${1}; shift
+# CEPCSW_LCG_OS: centos7 or el9
+if [ -z "$CEPCSW_LCG_OS" ]; then
+ # try to detect os
+ detect-os
+fi
+
+# if user don't specify the version, try to detect according to the current os
if [ -z "$CEPCSW_LCG_VERSION" ]; then
- CEPCSW_LCG_VERSION=103.0.2
+ case "$CEPCSW_LCG_OS" in
+ el9)
+ CEPCSW_LCG_VERSION=105.0.0
+ ;;
+ *)
+ CEPCSW_LCG_VERSION=103.0.2
+ ;;
+ esac
fi
export CEPCSW_LCG_VERSION
+
setup-external
setup-install-area