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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
#!/usr/bin/env bash
SCRIPTDIR=$( dirname $0 )
echo "SCRIPTDIR: ${SCRIPTDIR}"
source ${SCRIPTDIR}/syncUpdateUtils.shsource
function sendPromoteMail ()
{
# this buildeclipse.shsource file is to ease local builds to override some variables.
# It should not be used for production builds.
source buildeclipse.shsource 2>/dev/null
SITE_HOST=${SITE_HOST:-download.eclipse.org}
echo " Starting sendPromoteMail"
eclipseStream=$1
if [[ -z "${eclipseStream}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide eclipseStream as first argumnet, for this function $(basename $0)"
return 1;
fi
echo " eclipseStream: ${eclipseStream}"
buildId=$2
if [[ -z "${buildId}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide buildId as second argumnet, for this function $(basename $0)"
return 1;
fi
echo " buildId: ${buildId}"
BUILD_TECH=$3
if [[ -z "${BUILD_TECH}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide BUILD_TECH as third argumnet, for this function $(basename $0)"
return 1;
fi
echo " BUILD_TECH: ${BUILD_TECH}"
eclipseStreamMajor=${eclipseStream:0:1}
buildType=${buildId:0:1}
echo " buildType: ${buildType}"
# ideally, the user executing this mail will have this special file in their home directory,
# that can specify a custom 'from' variable, but still you must use your "real" ID that is subscribed
# to the wtp-dev mailing list
# set from="\"Your Friendly WTP Builder\" <real-subscribed-id@real.address>"
# correction ... doesn't work. Seems the subscription system set's the "from" name, so doesn't work when
# sent to mail list (just other email addresses)
# espeically handy if send from one id (e.g. "david_williams)
export MAILRC=~/.e4Buildmailrc
# common part of URL and file path
# varies by build stream
# examples of end result:
# http://download.eclipse.org/eclipse/downloads/drops4/N20120415-2015/
# /home/data/httpd/download.eclipse.org/eclipse/downloads/drops4/N20120415-2015
mainPath=$( dlToPath "$eclipseStream" "$buildId" "$BUILD_TECH" )
echo " mainPath: $mainPath"
if [[ "$mainPath" == 1 ]]
then
printf "\n\n\t%s\n\n" "ERROR: mainPath could not be computed."
return 1
fi
downloadURL=http://${SITE_HOST}/${mainPath}/${buildId}/
if [[ "${BUILD_TECH}" == "CBI" ]]
then
# 4.3.0 Build: I20120411-2034
SUBJECT="${eclipseStream} ${buildType}-Build: ${buildId}"
else
# 4.3.0 Build: I20120411-2034
SUBJECT="PDE based ${eclipseStream} ${buildType}-Build: ${buildId}"
fi
# override in buildeclipse.shsource if doing local tests
TO=${TO:-"platform-releng-dev@eclipse.org"}
# for initial testing, only to me -- change to PDE, after switch over
if [[ "${BUILD_TECH}" == "PDE" ]]
then
TO="david_williams@us.ibm.com"
fi
# make sure reply to goes back to the list
# I'm not positive this is required for mailing list?
# does anything "from" list, automatically get reply-to: list?
#REPLYTO="platform-releng-dev@eclipse.org"
#we could? to "fix up" TODIR since it's in file form, not URL
# URLTODIR=${TODIR##*${DOWNLOAD_ROOT}}
message1="\n\n\tDownload:\n\t${downloadURL}\n\n\n\tSoftware site repository:\n\thttp://${SITE_HOST}/eclipse/updates/${eclipseStreamMajor}.${eclipseStreamMinor}-${buildType}-builds"
message2="\n\n\tDownload:\n\t${downloadURL}\n\n\n\tSoftware site repository:\n\thttp://${SITE_HOST}/eclipse/updates/${eclipseStreamMajor}.${eclipseStreamMinor}-${buildType}-buildspdebased"
if [[ "${BUILD_TECH}" == "CBI" ]]
then
echo -e ${message1} | mail -s "${SUBJECT}" "${TO}"
else
echo -e ${message2} | mail -s "${SUBJECT}" "${TO}"
fi
echo "mail sent for $eclipseStream $buildType-build $buildId"
return 0
}
# start tests function
function startTests()
{
echo "startTests()"
eclipseStreamMajor=$1
buildType=$2
eclipseStream=$3
buildId=$4
BUILD_TECH=$5
EBUILDER_HASH=$6
if [[ -z "${EBUILDER_HASH}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide builder (or aggregator) hash as fourth argumnet, for this function $(basename $0)"
return 1;
fi
echo "eclipseStreamMajor: $eclipseStreamMajor"
echo "buildType: $buildType"
echo "eclipseStream: $eclipseStream"
echo "buildId: $buildId"
echo "BUILD_TECH: $BUILD_TECH"
echo "EBUILDER_HASH: $EBUILDER_HASH"
if [[ "${BUILD_TECH}" == 'CBI' ]]
then
buildRoot=/shared/eclipse/builds/${eclipseStreamMajor}${buildType}
eclipsebuilder=eclipse.platform.releng.aggregator/production/testScripts
dlFromPath=$( dlFromPath $eclipseStream $buildId $BUILD_TECH )
echo "DEBUG CBI dlFromPath: $dlFromPath"
buildDropDir=${buildRoot}/siteDir/$dlFromPath/${buildId}
echo "DEBGUG CBI buildDropDir: $buildDropDir"
builderDropDir=${buildDropDir}/${eclipsebuilder}
echo "DEBUG: CBI builderDropDir: ${builderDropDir}"
else
buildRoot=/shared/eclipse/eclipse${eclipseStreamMajor}${buildType}
buildDir=${buildRoot}/build
supportDir=${buildDir}/supportDir
eclipsebuilder=org.eclipse.releng.eclipsebuilder
builderDir=${supportDir}/$eclipsebuilder
# assumed in fixed location, for now, for PDE builds
builderDropDir=/shared/eclipse/sdk/promotion
echo "DEBUG: PDE builderDropDir for PDE: ${builderDropDir}"
dlFromPath=$( dlFromPath $eclipseStream $buildId $BUILD_TECH )
echo "DEBUG: PDE dlFromPath: $dlFromPath"
buildDropDir=${buildRoot}/siteDir/$dlFromPath/${buildId}
echo "DEBUG: PDE builderDropDir: ${builderDropDir}"
fi
# finally, execute
${builderDropDir}/startTests.sh ${eclipseStream} ${buildId} ${BUILD_TECH} ${EBUILDER_HASH}
}
# this funtion currently just synchs up the whole local repo
# with the whole remote repo ... so, important to use --delete and
# provides an easy way to "fix" the remote repo by fixing the local one first.
function syncRepoSite ()
{
eclipseStream=$1
if [[ -z "${eclipseStream}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide eclipseStream as first argumnet, for this function $(basename $0)" >&2
return 1;
fi
buildType=$2
if [[ -z "${buildType}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide buildType as second argumnet, for this function $(basename $0)" >&2
return 1;
fi
BUILD_TECH=$3
if [[ -z "${BUILD_TECH}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide BUILD_TECH as third argumnet, for this function $(basename $0)" >&2
return 1;
fi
# contrary to intuition (and previous behavior, bash 3.1) do NOT use quotes around right side of expression.
if [[ "${eclipseStream}" =~ ([[:digit:]]*)\.([[:digit:]]*)\.([[:digit:]]*) ]]
then
eclipseStreamMajor=${BASH_REMATCH[1]}
eclipseStreamMinor=${BASH_REMATCH[2]}
eclipseStreamService=${BASH_REMATCH[3]}
else
echo "eclipseStream, $eclipseStream, must contain major, minor, and service versions, such as 4.2.0" >&2
return 1
fi
fromDir=$(updateSiteOnBuildDir "$eclipseStream" "$buildId" "$BUILD_TECH")
toDir=$(updateSiteOnDL "$eclipseStream" "$buildId" "$BUILD_TECH")
#toDir="/home/data/httpd/download.eclipse.org/eclipse/updates/4.3-builds"
if [[ -n "${fromDir}" && -d "${fromDir}" && -n "${toDir}" && -d "${toDir}" ]]
then
rsync --recursive "${fromDir}" "${toDir}"
RC=$?
else
RC=9
fi
if [[ $RC != 0 ]]
then
echo "ERROR: rsync failed. RC: $RC" >&2
echo " In syncRepoSite" >&2
echo "fromDir: $fromDir" >&2
echo "toDir: $toDir" >&2
return $RC
fi
# update composite!
# add ${buildId} to {toDir}
# runAntRunner requires basebuilder to be installed at drop site, so we'll check here if it exists yet,
# and if not, fetch it.
dropFromBuildDir=$( dropFromBuildDir "$eclipseStream" "$buildId" "$BUILD_TECH" )
basebuilderDir="${dropFromBuildDir}/org.eclipse.releng.basebuilder"
if [[ -d $basebuilderDir ]]
then
echo "INFO: basebuilder directory found to exist already, so not re-fetched"
else
# assume ant is on the path
ant -f ${SCRIPTDIR}/getBaseBuilder.xml -DWORKSPACE=$dropFromBuildDir
fi
${SCRIPTDIR}/runAntRunner.sh ${buildId} ${eclipseStream} ${SCRIPTDIR}/addToComposite.xml addToComposite -Drepodir=${toDir} -Dcomplocation=${buildId}
RC=$?
return $RC
}
# this is the single script to call that "does it all" to promote build
# to update site, drop site, update index page on downlaods, and send mail to list.
# it requires four arguments
# eclipseStream (e.g. 4.2 or 3.8)
# buildId (e.g. N20120415-2015)
# BUILD_TECH (CBI or PDE)
# EBUILDER_HASH (SHA1 HASH or branch of eclipse builder to used
if [[ $# != 4 ]]
then
# usage:
scriptname=$(basename $0)
printf "\n\t%s\n" "This script, $scriptname requires four arguments, in order: "
printf "\t\t%s\t%s\n" "eclipseStream" "(e.g. 4.2.2 or 3.8.2) "
printf "\t\t%s\t%s\n" "buildId" "(e.g. N20120415-2015) "
printf "\t\t%s\t%s\n" "BUILD_TECH" "(e.g. PDE or CBI) "
printf "\t\t%s\t%s\n" "EBUILDER_HASH" "(SHA1 HASH for eclipe builder used) "
printf "\t%s\n" "for example,"
printf "\t%s\n\n" "./$scriptname 4.2 N N20120415-2015 CBI master"
exit 1
fi
echo "Starting $0"
# = = = = = = = = = argument checks
eclipseStream=$1
if [[ -z "${eclipseStream}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide eclipseStream as first argumnet, for this function $(basename $0)"
exit 1
fi
echo "eclipseStream: $eclipseStream"
buildId=$2
if [[ -z "${buildId}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide buildId as second argumnet, for this function $(basename $0)"
exit 1
fi
echo "buildId: $buildId"
BUILD_TECH=$3
if [[ -z "${BUILD_TECH}" ]]
then
printf "\n\n\t%s\n\n" "ERROR: Must provide BUILD_TECH as third argumnet, for this function $(basename $0)"
exit 1
fi
echo "BUILD_TECH: $BUILD_TECH"
#TODO: asssume master for now, if unspecified. But should tighten up to through error as scripts get finished.
EBUILDER_HASH=$4
if [[ -z "${EBUILDER_HASH}" ]]
then
printf "\n\n\t%s\n\n" "WARNING: Must provide builder (or aggregator) hash as fourth argumnet, for this function, $0"
#printf "\n\n\t%s\n\n" "ERROR: Must provide builder (or aggregator) hash as fourth argumnet, for this function, $0"
#exit 1;
fi
echo "EBUILDER_HASH: $EBUILDER_HASH"
eclipseStreamMajor=${eclipseStream:0:1}
buildType=${buildId:0:1}
echo "buildType: $buildType"
# contrary to intuition (and previous behavior, bash 3.1) do NOT use quotes around right side of expression.
if [[ "${eclipseStream}" =~ ([[:digit:]]*)\.([[:digit:]]*)\.([[:digit:]]*) ]]
then
eclipseStreamMajor=${BASH_REMATCH[1]}
eclipseStreamMinor=${BASH_REMATCH[2]}
eclipseStreamService=${BASH_REMATCH[3]}
else
echo "eclipseStream, $eclipseStream, must contain major, minor, and service versions, such as 4.2.0"
exit 1
fi
echo "eclipseStream: $eclipseStream"
echo "eclipseStreamMajor: $eclipseStreamMajor"
echo "eclipseStreamMinor: $eclipseStreamMinor"
echo "eclipseStreamService: $eclipseStreamService"
echo "BUILD_TECH: $BUILD_TECH"
echo "buildType: $buildType"
# = = = = = = = = =
# compute dirctiory on build machine
dropFromBuildDir=$( dropFromBuildDir "$eclipseStream" "$buildId" "$BUILD_TECH" )
echo "dropFromBuildDir: $dropFromBuildDir"
if [[ ! -d "${dropFromBuildDir}" ]]
then
echo "ERROR: the expected dropFromBuildDir (drop directory) did not exist"
echo " drop directory: ${dropFromBuildDir}"
exit 1
fi
SCRIPTDIR=$( dirname $0 )
echo "SCRIPTDIR: ${SCRIPTDIR}"
${SCRIPTDIR}/getEBuilder.sh "${BUILD_TECH}" "${EBUILDER_HASH}" "${dropFromBuildDir}"
syncRepoSite "$eclipseStream" "$buildType" "$BUILD_TECH"
rccode=$?
if [[ $rccode != 0 ]]
then
printf "\n\n\t%s\n\n" "ERROR: something went wrong putting repo on download site. Rest of promoting build halted."
exit 1
fi
syncDropLocation "$eclipseStream" "$buildId" "$BUILD_TECH" "${EBUILDER_HASH}"
rccode=$?
if [[ $rccode != 0 ]]
then
printf "\n\n\t%s\n\n" "ERROR occurred during promotion to download server, so halted promotion and did not send mail."
exit 1
fi
# if update to downloads succeeded, start the unit tests on Hudson
startTests $eclipseStreamMajor $buildType $eclipseStream $buildId $BUILD_TECH ${EBUILDER_HASH}
sendPromoteMail "$eclipseStream" "$buildId" "$BUILD_TECH"
rccode=$?
if [[ $rccode != 0 ]]
then
printf "\n\n\t%s\n\n" "ERROR occurred during sending final mail to list"
exit 1
fi
exit 0
|