-
Notifications
You must be signed in to change notification settings - Fork 13
/
setup_project_with_framework.sh
109 lines (89 loc) · 2.68 KB
/
setup_project_with_framework.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
#! /bin/sh
# Bootstrap a CMSSW installation ready for a given framework version
# Usage: source setup_project_with_framework.sh [-j N] [-o NAME] [ -b BRANCH || --pr PULLREQUESTID ]
FRAMEWORK_GITHUB=https://github.com/cp3-llbb/Framework
# Default options
CORE=4
OUTPUT=""
# Parse command line
while [[ $# > 0 ]]
do
key="$1"
case $key in
-j|--core)
CORE="$2"
shift # past argument
;;
-o|--output)
OUTPUT="$2"
shift # past argument
;;
--pr)
GITREF="refs/pull/$2/head"
BRANCH="test-PR$2"
shift # past argument
;;
-b|--branch)
BRANCH="$2"
shift # past argument
;;
*)
# unknown option
echo "Usage: source setup_project_with_framework.sh [-j N] [-o NAME] [ -b BRANCH OR --pr PULLREQUESTID ]"
return 1
;;
esac
shift # past argument or value
done
## for messages
if [[ "${BRANCH}" == "${GITREF}" ]]; then
GITDESCR="branch ${BRANCH}"
else
GITDESCR="ref ${GITREF}:${BRANCH}"
fi
## Clone into a temporary directory, to make sure we get the correct architecture and release
TEMPDIR=$(mktemp -d)
FWKDIR_TMP="${TEMPDIR}/Framework"
git clone -o upstream "${FRAMEWORK_GITHUB}" "${FWKDIR_TMP}"
if [ -n "${GITREF}" ]; then
pushd "${FWKDIR_TMP}" &> /dev/null
( git fetch upstream "${GITREF}:${BRANCH}" && git checkout "${BRANCH}" ) || ( echo "Problem checking out ${GITDESCR}" && exit 1 ) || return 1
popd &> /dev/null
fi
CMSSW_ARCH=$(cat "${FWKDIR_TMP}/CMSSW.arch")
CMSSW_VERSION=$(cat "${FWKDIR_TMP}/CMSSW.release")
DEPENDENCIES="${FWKDIR_TMP}/bootstrap_jenkins.sh"
if [ -z "${OUTPUT}" ]; then
OUTPUT="${CMSSW_VERSION}"
fi
echo ""
echo "Setting up ${CMSSW_VERSION} (${CMSSW_ARCH}) for Framework ${GITDESCR} into ${OUTPUT}"
echo ""
# Setup CMS env if necessary
if [ -z "${CMS_PATH}" ]; then
source /cvmfs/cms.cern.ch/cmsset_default.sh
fi
scramv1 -a "${CMSSW_ARCH}" project -n "${OUTPUT}" CMSSW "${CMSSW_VERSION}"
pushd "${OUTPUT}/src" &> /dev/null
eval `scramv1 runtime -sh` # cmsenv
## install dependencies
source "${DEPENDENCIES}"
## move Framework to the right place
mkdir -p "cp3_llbb"
mv "${FWKDIR_TMP}" "cp3_llbb/"
rmdir "${TEMPDIR}"
# Configure git remotes
pushd "cp3_llbb/Framework" &> /dev/null
source first_setup.sh
popd &> /dev/null
echo ""
echo "Bootstrapping done. Launching build using ${CORE} cores"
echo ""
## compile
scram b -j${CORE}
## check out a few more
source "cp3_llbb/Framework/jenkins_postbuild.sh"
OUTPUT_FULL=$(pwd) ## absolute path, for final message
popd &> /dev/null
echo ""
echo "All done, your project area in ${OUTPUT_FULL} is ready"