From b617bb7ecfdcdc5ef07ea8a19400211337483dea Mon Sep 17 00:00:00 2001 From: David Emschermann <d.emschermann@gsi.de> Date: Tue, 7 Jul 2020 23:19:20 +0200 Subject: [PATCH] Add revamped autoinstall script - 3rd trial --- autoinstall_framework.sh | 275 ++++++++++++++++++++++----------------- 1 file changed, 157 insertions(+), 118 deletions(-) diff --git a/autoinstall_framework.sh b/autoinstall_framework.sh index 8726da465b..e02c2e9bfb 100755 --- a/autoinstall_framework.sh +++ b/autoinstall_framework.sh @@ -1,113 +1,148 @@ #!/bin/bash # -## semi-automated script installing FairSoft, FairRoot and CbmRoot +## semi-automated script installing of FairSoft, FairRoot and CbmRoot # - +# usage: +# $ ./autoinstall_framework.sh +# for installation of all three or +# $ ./autoinstall_framework.sh --help +# to see a help file with possible user flags. +# +# 11.06.2020 - modification for robustness and to bring up to line with standard by Eoin Clerkin # 31.08.2018 - re-introduce old version # 24.05.2018 - switch to oct17p1 as dev version # 31.01.2017 - make ROOT6 the default # 17.12.2015 - split fairsoft directory into src and install # 01.12.2015 - add selection of root version -# 17.07.2015 - introduce option to compile dev settings +# 17.07.2015 - introduce option to compile dev settings # 02.06.2015 - introduce parameters for individual package selection # 13.03.2015 - initial version # by David Emschermann -#------------------------------------- -# usage: -# svn co https://subversion.gsi.de/cbmsoft/cbmroot/trunk $CBMSRCDIR -# cd $CBMSRCDIR -# ./autoinstall_framework.sh dev 0 0 1 -# or -# ./autoinstall_framework.sh 0 0 1 -# or -# ./autoinstall_framework.sh 1 1 1 -#------------------------------------- +exec &> >(tee -a .autoinstall_framework.log) # So the user can check up a complete log if he wishes. + -# choose your root verion +# choose your root version export ROOTVER=6 # put your desired variants here: export FSOFTDEV=jun19p2 -export FROOTDEV=v18.2.1 +export FROOTDEV=v18.4.0 -export FSOFTPRO=jun19p1 -export FROOTPRO=v18.2.0 +export FSOFTPRO=jun19p2 +export FROOTPRO=v18.2.1 -export FSOFTOLD=may18p1 -export FROOTOLD=v18.0.7 - -#------------------------------------- - -export NUMOFCPU=`cat /proc/cpuinfo | grep processor | wc -l` -export CBMSRCDIR=`pwd` - -#------------------------------------- +export FSOFTOLD=jun19p1 +export FROOTOLD=v18.2.0 # set default version to pro export FSOFTVER=$FSOFTPRO export FROOTVER=$FROOTPRO -# check if we want to run with GSI compiler -if [ $# -ge 1 ]; then - if [ "$1" == "gsi" ]; then - # use a different compiler from GSI - module use /cvmfs/it.gsi.de/modulefiles/ - module load compiler/gcc/4.9.2 - export CXX=g++ - shift - fi -fi -# check if we want to run with dev -if [ $# -ge 1 ]; then - if [ "$1" == "dev" ]; then - export FSOFTVER=$FSOFTDEV - export FROOTVER=$FROOTDEV - shift - elif [ "$1" == "old" ]; then - export FSOFTVER=$FSOFTOLD - export FROOTVER=$FROOTOLD - shift - fi -fi +SETUP_FAIRSOFT=0 && SETUP_FAIRROOT=0 && SETUP_CBMROOT=0; +[ $# -eq "0" ] && SETUP_FAIRSOFT=1 && SETUP_FAIRROOT=1 && SETUP_CBMROOT=1 : echo "Some Error has occurred" # Default behaviour with no flags, all three should be installed. + +while test $# -gt 0; do + case "$1" in + -y|-yes|--yes) + echo "Will update environment to new build after installation" + ANSWER="YES"; + shift;; + -n|-no|--no) + echo "In case someone wants to put in script." + ANSWER="NO"; + shift;; + -fs|-s|-fairsof|--fairsoft) + echo "*** FAIRSOFT to be installed" + SETUP_FAIRSOFT="1"; + shift;; + -fr|-r|-fairroot|--fairroot) + echo "*** FAIRROOT to be installed" + SETUP_FAIRROOT="1"; + shift;; + -cr|-c|-cbmroot|--cbmroot) + echo "*** CBMROOT to be installed" + SETUP_CBMROOT="1"; + shift;; + -d|--dev|-dev|dev) + echo "*** DEV VERSION specified" + export FSOFTVER=$FSOFTDEV + export FROOTVER=$FROOTDEV + shift;; + -o|--old|-old|old) + echo "*** OLD VERSION specified" + export FSOFTVER=$FSOFTOLD + export FROOTVER=$FROOTOLD + shift;; + 0|1) + # This unusual addition is to continue to provide back compatiability with previous versions of autoinstall_framework. + # It is important to keep this in case someone has hardcoded installation instructions somewhere and thus this should avoid breaking his program. + # In particular the old behaviour except 1, 2, or 3 numerical arguments whereby + # argument 1 greater or equal to 1 would install FAIR SOFT + # argument 2 greater or equal to 1 would install FAIR ROOT + # argument 3 greater or equal to 1 would install CBM ROOT + # ergo + # ./autobuild_framework dev 1 0 0 + # would install FAIR SOFT but not FAIR ROOT nor CBM ROOT. + + if [ $1 -gt 0 ]; + then + SETUP_FAIRSOFT="1"; + echo "FAIR SOFT flaged for install" + fi + + if [ ! -z $2 ]; # This combersome and longform if statement exist due to known issues regarding ampersands within bash cases. + then + if [ $2 -gt 0 ]; + then + SETUP_FAIRROOT="1"; + echo "FAIR ROOT flaged for install" + fi + fi + + if [ ! -z $3 ]; # This combersome and longform if statement exist due to known issues regarding ampersands within bash cases. + then + if [ $3 -gt 0 ]; + then + SETUP_CBMROOT="1"; + echo "CBMROOT flaged for install" + fi + fi + + # To prevent the pausing a script with maybe autoinstall_framework called the old way. + ANSWER="NO"; + + break;; + -h|-help|--help|*) + echo "Autoinstall_framework will install FairSoft, FairSoft, and CbmRoot packages" + echo "If no flags are specified, the program will install all three" + echo "otherwise the user may specify one or more to by calling the corresponding flags" + echo "-h, --help shows this brief help" + echo "-d, --dev Runs with dev" + echo "-o, --old Runs a old version" + echo "-fs, --fairsoft Installation of FairSoft" + echo "-fr, --fairroot Installation of FairRoot" + echo "-cr, --cbmroot Installation of CbmRoot" + echo "-y, --yes Automatically uses new envirnoment configuration post installation" + echo "-n, --no Answers No to automatic environment update" + echo "" + echo "Example case to install only FairRoot and CbmRoot (and not FairSoft)" + echo "./autoinstall_framework.sh -fr -cr" + exit 0;; + esac +done + +# My experience tells me that the default could be 2, even if there is only 1 processor, as 1 processing and 1 queued job normally is optimal Will leave it at 1 though. +export NUMOFCPU=`[ -f /proc/cpuinfo ] && grep -i processor /proc/cpuinfo | wc -l || echo 1` +export CBMSRCDIR=`pwd` + +#------------------------------------- echo FSOFTVER: $FSOFTVER echo FROOTVER: $FROOTVER -# install everything by default -SETUP_FAIRSOFT=1 -SETUP_FAIRROOT=1 -SETUP_CBMROOT=1 - -echo number of parameters: $# - -# handle parameters, if supplied -if [ $# -eq 1 ]; then - SETUP_FAIRSOFT=$1 - SETUP_FAIRROOT=0 - SETUP_CBMROOT=0 -fi -# handle parameters, if supplied -if [ $# -eq 2 ]; then - SETUP_FAIRSOFT=$1 - SETUP_FAIRROOT=$2 - SETUP_CBMROOT=0 -fi -# handle parameters, if supplied -if [ $# -eq 3 ]; then - SETUP_FAIRSOFT=$1 - SETUP_FAIRROOT=$2 - SETUP_CBMROOT=$3 -fi - -echo "Install Fairsoft:" $SETUP_FAIRSOFT -echo "Install Fairroot:" $SETUP_FAIRROOT -echo "Install Cbmroot :" $SETUP_CBMROOT -echo - -# exit - +#----------------------------------------------------------------------------------------------------------------- # ## FairSoft # @@ -117,21 +152,21 @@ if [ $SETUP_FAIRSOFT -ge 1 ]; then # check if sqlite3 is available if [ -f /usr/include/sqlite3.h ] ; then - echo - echo "Sqlite3 is available" - echo - else - echo + echo + echo "Sqlite3 is available" + echo + else + echo echo "Sqlite3 is not available" - echo + echo echo "On Debian, please install as follows:" echo "sudo apt install libsqlite3-dev" - echo + echo echo "On OpenSuSE, please install as follows:" echo "zypper install libsqlite3-0 sqlite3-devel" echo echo "afterwards, restart autoinstall_framework.sh" - echo + echo sleep 5 exit fi @@ -142,9 +177,6 @@ if [ $SETUP_FAIRSOFT -ge 1 ]; then git tag -l git checkout -b $FSOFTVER $FSOFTVER - #emacs -nw automatic.conf - #./configure.sh automatic.conf - if [ $ROOTVER -eq 6 ]; then sed s/build_root6=no/build_root6=yes/ automatic.conf > automatic1_root.conf else @@ -155,12 +187,12 @@ if [ $SETUP_FAIRSOFT -ge 1 ]; then echo " SIMPATH_INSTALL=$FSOFTINSTALLPATH/installation" >> automatic2_path.conf sed s/compiler=/compiler=gcc/ automatic2_path.conf > automatic3_gcc.conf ./configure.sh automatic3_gcc.conf - + cd $CBMSRCDIR echo done installing FairSoft fi - +#----------------------------------------------------------------------------------------------------------------- # ## FairRoot # @@ -178,7 +210,7 @@ if [ $SETUP_FAIRROOT -ge 1 ]; then echo PATH=$SIMPATH/bin:$PATH export PATH=$SIMPATH/bin:$PATH - + cd .. git clone https://github.com/FairRootGroup/FairRoot.git fairroot_src_$FROOTVER-fairsoft_${FSOFTVER}_root${ROOTVER} cd fairroot_src_$FROOTVER-fairsoft_${FSOFTVER}_root${ROOTVER} @@ -192,17 +224,18 @@ if [ $SETUP_FAIRROOT -ge 1 ]; then -DCMAKE_INSTALL_PREFIX=../../fairroot_$FROOTVER-fairsoft_${FSOFTVER}_root${ROOTVER} \ .. nice make install -j$NUMOFCPU - + cd $CBMSRCDIR echo done installing FairRoot fi - +#----------------------------------------------------------------------------------------------------------------- # ## CbmRoot # -if [ $SETUP_CBMROOT -ge 1 ]; then +if [ ${SETUP_CBMROOT} -eq "1" ]; +then echo "Setting up Cbmroot ..." # set SIMPATH @@ -222,15 +255,9 @@ if [ $SETUP_CBMROOT -ge 1 ]; then echo PATH=$SIMPATH/bin:$PATH export PATH=$SIMPATH/bin:$PATH - + cd .. -# if [ -d fieldmaps ]; then -# svn up fieldmaps -# else -# svn co https://subversion.gsi.de/cbmsoft/cbmroot/fieldmaps fieldmaps -# fi - - #svn co https://subversion.gsi.de/cbmsoft/cbmroot/trunk cbm_$CBMSRCDIR + cd $CBMSRCDIR mkdir build cd build @@ -240,19 +267,31 @@ if [ $SETUP_CBMROOT -ge 1 ]; then .. nice make -j$NUMOFCPU cd .. - -# cd input -# ln -s ../../fieldmaps/* . -# cd .. - - echo done installing CbmRoot - - echo - echo ". build/config.sh" - echo "export SIMPATH=$SIMPATH" - echo "export FAIRROOTPATH=$FAIRROOTPATH" +echo "done installing CbmRoot" + +[ -z $ANSWER ] && ( +cat << EOT +Since the system is now installed. Shall I switch to the new environment? +source build/config.sh +Reply Yes or Y for confirmation ???? +EOT +) && read ANSWER + +if (echo "$ANSWER" | sed -n '/^\(Y\|y\)/!{q10}') +then + echo "A yes detected." + echo "Environmental variables and paths updated" + source build/config.sh; +# export SIMPATH=$SIMPATH; +# export FAIRROOTPATH=$FAIRROOTPATH; fi + +fi + + +echo "Installation Complete" + ##################################################################################### -##################################################################################### + -- GitLab