Software installations as user
Frequently, research software as e.g. several different versions of Monte Carlo generators, experiment frameworks or e.g. CERN Root is installed best as user, requiring of course management of the individual environments. This can provide some headache, that is reduced with the following shell functions.
use
This functions eases the setup of the environments for installations, so that
the temptation/necessity to add default environments to .bashrc
is reduced.
export INIT_SCRIPT_DIR=$HOME/local/init_scripts
export LOADED_ENVIRONMENTS=""
use() {
if [ "$#" -ne 1 ]; then
echo "Use \$use environment to load an environment."
echo
echo "Available environments:"
for i in $( ls $INIT_SCRIPT_DIR)
do
echo ' '$i
done
echo
echo "Loaded environments:"
echo " "$LOADED_ENVIRONMENTS
fi
for i in "$@"
do
echo ' loading '$i '...'
source $INIT_SCRIPT_DIR/$i
export LOADED_ENVIRONMENTS=$i" "$LOADED_ENVIRONMENTS
done
}
export use
adding e.g. a file root
in the folder given in INIT_SCRIPT_DIR
with
contents
export ROOTSYS=$HOME/local/CERN_ROOT/
source $ROOTSYS/bin/thisroot.sh
will allow to activate the specific software by $use root
.
addbin, addld and addpy
These functions abbreviate the adding of new directories to the respective search paths, and thus writing the scripts for the use function.
addbin() {
export PATH="$1:$PATH" ; }
addld() {
export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH" ; }
addpy() {
export PYTHONPATH="$1:$PYTHONPATH" ;}
#export this functions for every shell
export addbin
export addld
export addpy
These can be used e.g. in the .bashrc
:
addbin $HOME/local/bin
addld $HOME/local/lib
addpy $HOME/local/lib/python2.7/site-packages