diff --git a/scripts/cvmfs/setup-nightlies.sh b/scripts/cvmfs/setup-nightlies.sh index 8963b9d4..b272e584 100644 --- a/scripts/cvmfs/setup-nightlies.sh +++ b/scripts/cvmfs/setup-nightlies.sh @@ -140,6 +140,24 @@ elif [ "$os" = "ubuntu22.04" ]; then echo "Ubuntu 22.04 detected" fi +_replace_marlin_dll() { + # replace the library on MARLIN_DLL with the local one (if any) + local pkg_name=${1} + local install_prefix=${2} + if echo ${MARLIN_DLL} | grep -qE "/${pkg_name}/"; then + local old_lib=$(echo ${MARLIN_DLL} | tr ":" "\n" | grep -E "/${pkg_name}/") + local lib_name=$(basename ${old_lib}) + for d in lib lib64; do + local new_lib=$(pwd)/${install_prefix}/${d}/${lib_name} + if [ -f ${new_lib} ]; then + export MARLIN_DLL=$(echo ${MARLIN_DLL%:} | tr ":" "\n" | grep -Ev "/${pkg_name}/" | tr "\n" ":")${new_lib} + echo "Replaced library on MARLIN_DLL: old: '${old_lib}'" + echo " new: '${new_lib}'" + break; + fi + done + fi +} k4_local_repo() { for arg in "$@"; do @@ -168,7 +186,7 @@ k4_local_repo() { export CMAKE_PREFIX_PATH=$(echo $CMAKE_PREFIX_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") export PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") export ROOT_INCLUDE_PATH=$(echo $ROOT_INCLUDE_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") - export MARLIN_DLL=$(echo $MARLIN_DLL | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") + _replace_marlin_dll ${current_repo} ${install} export PATH=$PWD/$install/bin:$PATH export LD_LIBRARY_PATH=$PWD/$install/lib:$PWD/$install/lib64:$LD_LIBRARY_PATH export PYTHONPATH=$PWD/$install/python:$PYTHONPATH diff --git a/scripts/cvmfs/setup-releases.sh b/scripts/cvmfs/setup-releases.sh index 37025ad8..7ca7ae71 100644 --- a/scripts/cvmfs/setup-releases.sh +++ b/scripts/cvmfs/setup-releases.sh @@ -153,6 +153,25 @@ elif [ "$os" = "ubuntu22.04" ]; then echo "Ubuntu 22.04 detected" fi +_replace_marlin_dll() { + # replace the library on MARLIN_DLL with the local one (if any) + local pkg_name=${1} + local install_prefix=${2} + if echo ${MARLIN_DLL} | grep -qE "/${pkg_name}/"; then + local old_lib=$(echo ${MARLIN_DLL} | tr ":" "\n" | grep -E "/${pkg_name}/") + local lib_name=$(basename ${old_lib}) + for d in lib lib64; do + local new_lib=$(pwd)/${install_prefix}/${d}/${lib_name} + if [ -f ${new_lib} ]; then + export MARLIN_DLL=$(echo ${MARLIN_DLL%:} | tr ":" "\n" | grep -Ev "/${pkg_name}/" | tr "\n" ":")${new_lib} + echo "Replaced library on MARLIN_DLL: old: '${old_lib}'" + echo " new: '${new_lib}'" + break; + fi + done + fi +} + k4_local_repo() { for arg in "$@"; do @@ -181,7 +200,7 @@ k4_local_repo() { export CMAKE_PREFIX_PATH=$(echo $CMAKE_PREFIX_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") export PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") export ROOT_INCLUDE_PATH=$(echo $ROOT_INCLUDE_PATH | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") - export MARLIN_DLL=$(echo $MARLIN_DLL | tr ":" "\n" | grep -Ev "/${current_repo}/" | tr "\n" ":") + _replace_marlin_dll ${current_repo} ${install} export PATH=$PWD/$install/bin:$PATH export LD_LIBRARY_PATH=$PWD/$install/lib:$PWD/$install/lib64:$LD_LIBRARY_PATH export PYTHONPATH=$PWD/$install/python:$PYTHONPATH diff --git a/scripts/cvmfs/setup.sh b/scripts/cvmfs/setup.sh new file mode 100644 index 00000000..bd95fcf6 --- /dev/null +++ b/scripts/cvmfs/setup.sh @@ -0,0 +1,212 @@ +#!/usr/bin/env bash + +# This script sets up the Key4hep software stack from CVMFS depending on its +# location it either uses the nightlies or the releases + +SCRIPT_SOURCE=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd) +SCRIPT_BASE_DIR=$(dirname "${SCRIPT_SOURCE}") + +function _setup_script_usage() { + echo "_Setup_Script_Usage: source ${SCRIPT_SOURCE} [-r ] [--list-releases [distribution]] [--list-packages [distribution]]" + echo " -r , --release : setup a specific release, if not specified the latest release will be used (also used for --list-packages)" + echo " -h, --help : print this help message" + echo " --list-releases [distribution] : list available releases for the specified distribution (almalinux, centos, ubuntu). By default (no OS is specified) it will list the releases for the detected distribution" + echo " --list-packages [distribution] : list available packages and their versions for the specified distribution (almalinux, centos, ubuntu). By default (no OS is specified) it will list the packages for the detected distribution" +} + +function _k4_check_release() { + local release=${1} + local os=${2} + if [[ ! -d "/cvmfs/sw-nightlies.hsf.org/key4hep/releases/${release}" || -z "$(ls "/cvmfs/sw-nightlies.hsf.org/key4hep/releases/${release}" | grep ${os})" ]]; then + echo "Release ${release} not found, this is a list of the available releases:" + find /cvmfs/sw-nightlies.hsf.org/key4hep/releases/ -maxdepth 2 -type d -name "*${os}*" | awk -F/ '{print $(NF-1)}' | sort + echo "Aborting..." + return 1 + fi + return 0 +} + +function _k4_setup_list_releases() { + # List the available release for the passed OS. Assumes that OS has been + # sanitized before + local os=$1 + find ${SCRIPT_BASE_DIR}/releases/ -maxdepth 2 -type d -name "*${os}*" | + \awk -F/ '{print $(NF-1)}' | sort +} + +function _k4_setup_list_packages() { + # List the available packages and their version for a given OS and release. + # Both of them are assumed to have been sanitized before + local os=$1 + local res=$2 + find "${SCRIPT_BASE_DIR}"/releases/"$rel"/*"${os}"*/ -maxdepth 2 -mindepth 2 -not -path '*/\.*' -type d | awk -F/ '{if ($NF ~ /develop/) printf "%s develop", $(NF-1); else {split($(NF),arr,"-"); printf "%s ", $(NF-1); printf "%s", arr[1]; for (i=2; i