-
Notifications
You must be signed in to change notification settings - Fork 3
/
source-root.sh
executable file
·75 lines (56 loc) · 1.46 KB
/
source-root.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# This bash script is part of the MEGAlib & COSItools setup procedure.
# As such it is dual licenced under Apache 2.0 for COSItools and LGPL 3.0 for MEGAlib
#
# Development lead: Andreas Zoglauer
#
# Description:
# Source all ROOT-related environment variables
# Make this script work with zsh
if [ -n "$ZSH_VERSION" ]; then emulate -L ksh; fi
# Print some help
confhelp() {
echo ""
echo "This script sources all ROOT-related environment variables"
echo " "
echo "Usage: ./source-root.sh --path=[full path to the ROOT installation]";
echo " "
}
# Parse the command line
CMD=( "$@" )
__TMP_PATH=""
__TMP_HERE=$(pwd)
for C in "${CMD[@]}"; do
if [[ ${C} == *-p*=* ]]; then
__TMP_PATH=`echo ${C} | awk -F"=" '{ print $2 }'`
elif [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
echo ""
confhelp
exit 0
fi
done
# Perform sanity checks
# We require an absolute path
if [[ ${__TMP_PATH} != /* ]]; then
echo ""
echo "ERROR: The ROOT path must be an absolute path: ${__TMP_PATH}"
echo ""
return
fi
# The directory must exist
if [[ ! -d ${__TMP_PATH} ]]; then
echo ""
echo "ERROR: ROOT directory not found: ${__TMP_PATH}"
echo ""
return
fi
# Check if the ROOT setup script exists"
if [[ ! -f ${__TMP_PATH}/bin/thisroot.sh ]]; then
echo ""
echo "ERROR: Root environment script not found: ${__TMP_PATH}/bin/thisroot.sh"
echo ""
return
fi
# Finally source the ROOT setup:
source ${__TMP_PATH}/bin/thisroot.sh
return