forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-cmssw-ib-with-patch
executable file
·250 lines (229 loc) · 10.2 KB
/
build-cmssw-ib-with-patch
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/sh -ex
CMS_BOT_DIR=$(dirname $0)
case $CMS_BOT_DIR in /*) ;; *) CMS_BOT_DIR=$(pwd)/${CMS_BOT_DIR} ;; esac
echo DATE=`date`
ARCHITECTURE=$1
RELEASE_FORMAT=$2
REPOSITORY=$3
FORCE_FULL_IB=$4
RELEASE_LIST=$5
PACKAGE_NAME=cmssw
FORCE_PKGTOOLS_TAG=$6
USE_DEV_CMSPKG=$7
FORCE_BUILD_PATCH_RELEASE=$8
CMSSW_TOOL_CONF_ONLY=$9
DRY_RUN="${10}"
# Workspace is usually defined by jenkins. If not running in
# jenkins it will assume the current directory is the workspace.
WORKSPACE="${WORKSPACE-$PWD}"
WRKDIR=w
rm -rf $WORKSPACE/../build-cache &
cd $WORKSPACE
rm -rf ${WRKDIR}/SPECS
BUILD_JOBS=4
BUILD_NPROC=$(nproc)
case $ARCHITECTURE in
*_mic_*) export BUILD_ARCH=`echo $ARCHITECTURE | cut -f1,2 -d_` ;;
*_armv7hl_*) BUILD_JOBS=1; BUILD_NPROC=3 ;;
esac
RELEASE_NAME=`date +$RELEASE_FORMAT`
DAY=`date +%Y-%m-%d`
HOUR=`echo $RELEASE_NAME | sed -e's|.*-\([0-9][0-9]\)00|\1|'`
# RELEASE_QUEUE=`echo $RELEASE_NAME | sed -e 's/\(CMSSW_[0-9][0-9]*_[0-9][0-9]*\).*/\1_X/'`
RELEASE_QUEUE=`echo $RELEASE_NAME | sed -e 's/_X.*/_X/'`
# Hardcode special queues like SLHC one.
EXTRA_REPOS=""
case $RELEASE_NAME in
*SLHCDEV*) ;;
*SLHC*) RELEASE_QUEUE=${RELEASE_QUEUE}_SLHC ;;
*_DEVEL_X_*) EXTRA_REPOS="--extra-repositories cms.week0,cms.week1" ;;
esac
CMSDIST_REPO=cms-sw
PKGTOOLS_REPO=cms-sw
unset BUILD_PATCH_RELEASE
eval `cat $CMS_BOT_DIR/config.map | grep -v 'DISABLED=' | grep "SCRAM_ARCH=$ARCHITECTURE;" | grep "RELEASE_QUEUE=$RELEASE_QUEUE;"`
[ "X$BUILD_PATCH_RELEASE" = "X1" ] && FORCE_BUILD_PATCH_RELEASE=true
# We use git clone -b because this forces git to think that $CMSDIST_TAG, PKGTOOLS_TAG,
# are both branches. See below to handle the case in which they are actually tags.
[ "$FORCE_PKGTOOLS_TAG" != "" ] && PKGTOOLS_TAG=$FORCE_PKGTOOLS_TAG
USE_DEV=""
[ "$USE_DEV_CMSPKG" = "true" ] && USE_DEV="--use-dev"
for x in $PKGTOOLS_REPO/pkgtools@$PKGTOOLS_TAG $CMSDIST_REPO/cmsdist@$CMSDIST_TAG; do
REPO=`echo $x | cut -f1 -d@`
T=`echo $x | cut -f2 -d@`
P=`echo $REPO | cut -f2 -d/ | tr "[:lower:]" "[:upper:]"`
if [ ! -d $P ]; then
git clone -b $T git://github.com/$REPO.git $P
pushd $P
git remote add originrw [email protected]:$REPO.git
popd
fi
pushd $P
git fetch
git clean -fxd ; git reset --hard HEAD
git checkout $T
git merge --ff-only origin/$T
eval "${P}_HASH=`git rev-parse HEAD`"
popd
done
echo DATE=`date`
# If we use a tag, rather than a branch, we need to check-it out explicitly.
# We also store the HASH of both PKGTOOLS and CMSDIST to reuse them later on.
# ALL_PREVIOUS_RELEASES contains both IBs and fill releases and we use it
# to eventually skip the build if the same exact IB is already available.
# We disable the whole logic and build a full IB if FORCE_FULL_IB is not empty.
pushd CMSDIST
if [ ! "X$FORCE_FULL_IB" = Xtrue ]; then
PREVIOUS_RELEASES=`git show --pretty='%d' HEAD | tr '[ ,()]' '[\n ]' | grep -v $RELEASE_NAME | { grep "^\(IB\|REL\)/${RELEASE_QUEUE}_[0-9][^/]*/$ARCHITECTURE" || true; }`
ALL_PREVIOUS_RELEASES=`git show --pretty='%d' HEAD | tr '[ ,()]' '[\n ]' | grep -v $RELEASE_NAME | { grep "^ALL/${RELEASE_QUEUE}_[0-9][^/]*/$ARCHITECTURE" || true; }`
fi
# We checkout a few files from the default branch in any case.
DEFAULT_CMSDIST_URL="https://raw.githubusercontent.com/cms-sw/cmsdist/HEAD"
curl -L -s -k $DEFAULT_CMSDIST_URL/cmssw-ib.spec > cmssw-ib.spec
curl -L -s -k $DEFAULT_CMSDIST_URL/das-cache.file > das-cache.file
sed -i -e 's|Source: .*/buildLogAnalyzer.py|Source: https://raw.githubusercontent.com/cms-sw/cms-bot/master/buildLogAnalyzer.py|' cmssw-ib.spec
popd
CMS_TAG=""
if [ "X`PKGTOOLS/cmsBuild --help | grep tag=NAME`" != "X" ] ; then
case `uname -s` in
Darwin ) MD5_CMD=md5;;
* ) MD5_CMD=md5sum;;
esac
CMS_TAG="--tag `echo $RELEASE_QUEUE | $MD5_CMD | tr '0123456789' 'ghijklmnop' | cut -b1-6`"
fi
CMSBUILD_CMD="PKGTOOLS/cmsBuild $EXTRA_REPOS $USE_DEV --builders $BUILD_JOBS -j $BUILD_NPROC --repository $REPOSITORY --architecture $ARCHITECTURE --work-dir ${WRKDIR} $CMS_TAG"
PKGTOOLS_VER=$(echo $PKGTOOLS_TAG | cut -d- -f2)
if [ ${PKGTOOLS_VER} -gt 31 ] ; then
CMSBUILD_CMD="$CMSBUILD_CMD --delete-build-directory"
fi
PYTHONPATH= $CMSBUILD_CMD --debug build SCRAMV1
# Decide if we already have a release which uses the same CMSDIST.
pushd ${WRKDIR}
if [ "$CMSSW_TOOL_CONF_ONLY" != "true" ] ; then
for previous in $PREVIOUS_RELEASES; do
previous=`echo $previous | cut -f2 -d/`
echo "Checking if we can install $previous"
set +e
CMSSW_RELEASE_BASE=`./common/cmspkg -a $ARCHITECTURE -f search cms+cmssw+$previous | grep 'cms[+]cmssw[+]' | cut -f1 -d\ | cut -f3 -d+ | grep -e "^$previous\$"`
set -e
if [ ! "X$CMSSW_RELEASE_BASE" = X ]; then
PACKAGE_NAME=cmssw-patch
perl -p -i -e "s/BuildRequires: cmssw/BuildRequires: cmssw-patch/" ../CMSDIST/cmssw-ib.spec
perl -p -i -e "s/%define baserelver[\s].*/%define baserelver $CMSSW_RELEASE_BASE/" ../CMSDIST/cmssw-patch-build.file
perl -p -i -e "s/%define baserelqueue[\s].*/%define baserelqueue $CMSSW_RELEASE_BASE/" ../CMSDIST/cmssw-patch-build.file
perl -p -i -e 's/CMSSW_ROOT/CMSSW_PATCH_ROOT/' ../CMSDIST/cmssw-ib.spec
perl -p -i -e 's/CMSSW_VERSION/CMSSW_PATCH_VERSION/' ../CMSDIST/cmssw-ib.spec
break
fi
done
fi
# This is done to decide wether or not we actually need to build a release or
# the same CMSDIST / PKGTOOLS / CMSSW tags were used to build an IB which
# is already available in the apt repository.
if [ "X$PACKAGE_NAME" = Xcmssw-patch -a "X$FORCE_BUILD_PATCH_RELEASE" != "Xtrue" ]; then
#AVAILABLE_RELEASES=`source $ARCHITECTURE/apt-init.sh; apt-cache search cms\\\+cmssw | grep ${RELEASE_QUEUE} | grep 'cms[+]cmssw\(-patch\|\)[+]' | cut -f1 -d\ | cut -f3 -d+`
AVAILABLE_RELEASES=`./common/cmspkg -a $ARCHITECTURE search cms+cmssw | grep ${RELEASE_QUEUE} | grep 'cms[+]cmssw\(-patch\|\)[+]' | cut -f1 -d\ | cut -f3 -d+`
for same_tag in $RELEASE_LIST; do
if [ "X`echo $ALL_PREVIOUS_RELEASES | grep $same_tag`" != X ] ; then
if [ "X`echo $AVAILABLE_RELEASES | grep $same_tag`" != "X" ] ; then
echo $same_tag uses the same CMSDIST, PKGTOOLS and CMSSW tag. Not building.
exit 0
fi
fi
done
fi
popd
echo DATE=`date`
case $ARCHITECTURE in
*mic*) CMSSW_RELEASE_BASE=""; PACKAGE_NAME=cmssw; CMSSW_TOOL_CONF=cmssw-mic-tool-conf ;;
*) CMSSW_TOOL_CONF=$PACKAGE_NAME-tool-conf ;;
esac
pushd CMSDIST
DEBUG_SUBPACKS="cmssw.spec coral.spec cmssw-patch.spec root.spec"
if [ "X$ENABLE_DEBUG" = X ]; then
perl -p -i -e 's/^[\s]*%define[\s]+subpackageDebug[\s]+./#subpackage debug disabled/' $DEBUG_SUBPACKS
fi
if [ ! "X$PACKAGE_NAME" = Xcmssw-patch ]; then
CMSSW_RELEASE_BASE=$RELEASE_NAME
fi
echo "### RPM cms dummy `date +%%s`\n%prep\n%build\n%install\n" > dummy.spec
perl -p -i -e "s/### RPM cms cmssw .*/### RPM cms cmssw $CMSSW_RELEASE_BASE/" cmssw.spec
perl -p -i -e "s/### RPM cms cmssw-ib .*/### RPM cms cmssw-ib $RELEASE_NAME/" cmssw-ib.spec
perl -p -i -e "s/### RPM cms cmssw-patch.*/### RPM cms cmssw-patch $RELEASE_NAME/" cmssw-patch.spec
popd
PYTHONPATH= $CMSBUILD_CMD --specs-only build $PACKAGE_NAME
TOOL_CONF_PACKAGES="cms-common local-cern-siteconf `grep '^%define \(build\|\)directpkgreqs' ${WRKDIR}/SPECS/cms/$PACKAGE_NAME/*/spec | grep -v '%{nil}' | sed 's|.*directpkgreqs[ \t]*||' | tr ' ' '\n' | cut -f2 -d/ | sort | uniq | tr '\n' ' '`"
echo DATE=`date`
EXTERNAL_FAILED=NO
PYTHONPATH= $CMSBUILD_CMD build $TOOL_CONF_PACKAGES || EXTERNAL_FAILED=YES
echo DATE=`date`
rm -rf ${WRKDIR}/tmp/pip*
if [ "X${EXTERNAL_FAILED}" = "XYES" ] ; then
if [ "${DRY_RUN}" != "" ] ; then exit 1 ; fi
BLD_PKGS=$(ls ${WRKDIR}/RPMS/${ARCHITECTURE}/ | grep '.rpm$' | cut -d+ -f2 | grep -v 'coral-debug')
if [ "X$BLD_PKGS" != "X" ] ; then PYTHONPATH= $CMSBUILD_CMD --sync-back upload ${BLD_PKGS} ; fi
rm -rf ${WRKDIR}/tmp
exit 1
fi
if [ "${DRY_RUN}" = "" ] ; then
if [ `ls ${WRKDIR}/RPMS/${ARCHITECTURE} | wc -l` -gt 0 ] ; then
PYTHONPATH= $CMSBUILD_CMD --sync-back upload $TOOL_CONF_PACKAGES
echo DATE=`date`
PYTHONPATH= $CMSBUILD_CMD deprecate-local $TOOL_CONF_PACKAGES
echo DATE=`date`
fi
fi
if [ "$CMSSW_TOOL_CONF_ONLY" = "true" ] ; then exit 0; fi
DEBUG_OPT=
case $RELEASE_NAME in
*_DEVEL_*) DEBUG_OPT="--debug" ;;
esac
export SCRAM_HOOKS_DEBUG=1
PYTHONPATH= $CMSBUILD_CMD $DEBUG_OPT -k -j `echo "$BUILD_NPROC + 1" | bc` build cmssw-ib
echo DATE=`date`
if [ "${DRY_RUN}" != "" ] ; then exit 0 ; fi
PYTHONPATH= $CMSBUILD_CMD --sync-back upload cmssw-ib
echo DATE=`date`
rm -rf ${WRKDIR}/tmp
pushd CMSDIST
# In case we do not have errors in the full release, or in case we are forcing the
# tagging we create an ALL tag and use IB if we discover it's a full release later on.
# In case we have errors, we use an ERR tag in case we discover it's a full release later on.
if [ "X$ALWAYS_TAG_CMSSW" != "X" ] || [ ! -e $WORKSPACE/${WRKDIR}/$ARCHITECTURE/cms/cmssw/$RELEASE_NAME/build-errors ]; then
GTAG="ALL/$RELEASE_NAME/$ARCHITECTURE"
if [ $(git tag | grep "^$GTAG$" | wc -l) -gt 0 ] ; then
git tag -d $GTAG
git push originrw :refs/tags/$GTAG
fi
git tag $GTAG $CMSDIST_HASH
git push originrw $GTAG || true
TAG_TYPE="IB"
else
TAG_TYPE="ERR"
fi
# Check if it is a full release and tag depending on wether it had ERRors or not.
if [ X$CMSSW_RELEASE_BASE = X$RELEASE_NAME ]; then
GTAG="$TAG_TYPE/$RELEASE_NAME/$ARCHITECTURE"
if [ $(git tag | grep "^$GTAG$" | wc -l) -gt 0 ] ; then
git tag -d $GTAG
git push originrw :refs/tags/$GTAG
fi
git tag $GTAG $CMSDIST_HASH
git push originrw $GTAG || true
fi
popd
if [ "X$DO_NOT_INSTALL" != "X" ] ; then exit 0 ; fi
echo CMSDIST_HASH=$CMSDIST_HASH > $WORKSPACE/buildprops
echo PKGTOOLS_HASH=$PKGTOOLS_HASH >> $WORKSPACE/buildprops
echo PACKAGE_NAME=$PACKAGE_NAME >> $WORKSPACE/buildprops
echo RELEASE_FORMAT=${RELEASE_FORMAT} >> $WORKSPACE/buildprops
echo CMSSW_RELEASE_BASE=$CMSSW_RELEASE_BASE >> $WORKSPACE/buildprops
echo RELEASE_QUEUE=${RELEASE_QUEUE} >> $WORKSPACE/buildprops
echo ENABLE_DEBUG=${ENABLE_DEBUG} >> $WORKSPACE/buildprops
echo DOCKER_IMG=${DOCKER_IMG} >> $WORKSPACE/buildprops
echo ARCHITECTURE=${ARCHITECTURE} >> $WORKSPACE/buildprops
for x in `echo $ADDITIONAL_TESTS | tr , '\n'`; do
echo "Creating property file $WORKSPACE/$x-properties."
cp $WORKSPACE/buildprops $WORKSPACE/$x-properties
done
echo DATE=`date`