forked from TreeMaker/TreeMaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·175 lines (157 loc) · 4.76 KB
/
setup.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash -e
CMSSWVER=CMSSW_10_2_21
FORK=TreeMaker
BRANCH=Run2_2017
ACCESS=ssh
CORES=8
NAME=""
DIR="${PWD}"
BATCH=""
DEBUG="false"
usage(){
EXIT=$1
echo "setup.sh [options]"
echo ""
echo "-f [fork] clone from specified fork (default = ${FORK})"
echo "-b [branch] clone specified branch (default = ${BRANCH})"
echo "-B configure some settings for checkout within batch setups (default = ${BATCH})"
echo "-c [version] use specified CMSSW version (default = ${CMSSWVER})"
echo "-a [protocol] use protocol to clone (default = ${ACCESS}, alternative = https)"
echo "-j [cores] run CMSSW compilation on # cores (default = ${CORES})"
echo "-n [name] name of the CMSSW directory (default = ${CMSSWVER})"
echo "-d [dir] project installation area for the CMSSW directory (default = ${DIR})"
echo "-D print additional debug statements (default = ${DEBUG})"
echo "-h display this message and exit"
exit $EXIT
}
# process options
while getopts "f:b:Ba:j:n:d:c:Dh" opt; do
case "$opt" in
f) FORK=$OPTARG
;;
b) BRANCH=$OPTARG
;;
B) BATCH=--upstream-only
;;
c) CMSSWVER=$OPTARG
;;
a) ACCESS=$OPTARG
;;
j) CORES=$OPTARG
;;
n) NAME=$OPTARG
;;
d) DIR=$OPTARG
;;
D) DEBUG="true"
;;
h) usage 0
;;
esac
done
# check options
if [ "$ACCESS" = "ssh" ]; then
ACCESS_GITLAB=ssh://[email protected]:7999/
ACCESS_CMSSW=--ssh
elif [ "$ACCESS" = "https" ]; then
ACCESS_GITHUB=https://github.com/
ACCESS_GITLAB=https://gitlab.cern.ch/
ACCESS_CMSSW=--https
else
usage 1
fi
# make sure that scram is available in a batch situation when an interactive terminal might not be available
if [[ -n "$BATCH" ]]; then
echo "WARNING: Non-interactive shell found!"
if [[ -n "${HOME}" ]] && [[ -f "${HOME}/.bashrc" ]]; then
echo "Sourcing the ${HOME}/.bashrc file"
source ${HOME}/.bashrc
elif [[ -f "~/.bashrc" ]]; then
echo "Sourcing the ~/.bashrc file"
source ~/.bashrc
fi
if [[ -f "/cvmfs/cms.cern.ch/cmsset_default.sh" ]]; then
echo -e "cms.cern.ch is accessible\n\t==> source /cvmfs/cms.cern.ch/cmsset_default.sh\n"
source /cvmfs/cms.cern.ch/cmsset_default.sh
elif [[ -f "/opt/cms/cmsset_default.sh" ]]; then
echo -e "cmsset_default.sh is locally accessible\n\t==> source /opt/cms/cmsset_default.sh\n"
source /opt/cms/cmsset_default.sh
fi
fi
# get CMSSW release
if [[ "$CMSSWVER" == "CMSSW_10_2_"* ]]; then
GCC_VERSION=gcc700
else
echo "Unsupported CMSSW version: $CMSSWVER"
exit 1
fi
if [[ `uname -r` == *"el6"* ]]; then
SLC_VERSION="slc6"
elif [[ `uname -r` == *"el7"* ]]; then
SLC_VERSION="slc7"
elif [[ -f "/etc/redhat-release" ]]; then
VERSION_TMP=`awk -F'[ .]' '{print $4}' "/etc/redhat-release"`
POSSIBLE_VERSIONS=( 6 7 )
if [[ "${POSSIBLE_VERSIONS[@]} " =~ " ${VERSION_TMP}" ]]; then
SLC_VERSION="slc${VERSION_TMP}"
else
echo "WARNING::Unknown SLC version. Defaulting to SLC6."
SLC_VERSION="slc6"
fi
else
echo "WARNING::Unknown SLC version. Defaulting to SLC6."
SLC_VERSION="slc6"
fi
export SCRAM_ARCH=${SLC_VERSION}_amd64_${GCC_VERSION}
# cmsrel
SCRAM_PROJECT_OPTIONS=""
if [ "$DIR" != "${PWD}" ]; then
SCRAM_PROJECT_OPTIONS="$SCRAM_PROJECT_OPTIONS --dir ${DIR}"
fi
if [ "$NAME" != "" ]; then
SCRAM_PROJECT_OPTIONS="$SCRAM_PROJECT_OPTIONS --name ${NAME}"
else
NAME=${CMSSWVER}
fi
SCRAM_PROJECT_OPTIONS="$SCRAM_PROJECT_OPTIONS ${CMSSWVER}"
if [[ "${DEBUG}" == "true" ]]; then
set -x
fi
scram project ${SCRAM_PROJECT_OPTIONS}
cd ${DIR}/${NAME}/src
# cmsenv
eval `scramv1 runtime -sh`
git cms-init $ACCESS_CMSSW $BATCH
git config gc.auto 0
# batch git config
if [[ -n "$BATCH" ]]; then
if [[ "${DEBUG}" == "true" ]]; then
echo "Dumping the git configuration before adding to it"
git config --global -l
fi
git config --global --add user.name "TreeMaker GitHub"
git config --global --add user.email "[email protected]"
git config --global --add user.github "TreeMaker"
fi
if [[ "${DEBUG}" == "true" ]]; then
echo "Dumping the git configuration"
git config --global -l
fi
# CMSSW patches
if [[ "$CMSSWVER" == "CMSSW_10_2_"* ]]; then
git cms-merge-topic -u $ACCESS_CMSSW TreeMaker:BoostedDoubleSVTaggerV4-WithWeightFiles-v1_from-CMSSW_10_2_7
git cms-merge-topic -u $ACCESS_CMSSW TreeMaker:storeJERFactorIndex10220
git cms-merge-topic -u $ACCESS_CMSSW TreeMaker:AddJetAxis1_1027
git cms-merge-topic -u $ACCESS_CMSSW TreeMaker:DeepAK8v2_10221
fi
# outside repositories
git clone ${ACCESS_GITHUB}TreeMaker/JetToolbox.git JMEAnalysis/JetToolbox -b jetToolbox_94X
git clone ${ACCESS_GITHUB}kpedro88/CondorProduction.git Condor/Production
git clone ${ACCESS_GITHUB}${FORK}/TreeMaker.git -b ${BRANCH}
# compile
scram b -j ${CORES}
# extra setup
cd TreeMaker/Production/test/condorSub/
python $CMSSW_BASE/src/Condor/Production/python/linkScripts.py
set +x