-
Notifications
You must be signed in to change notification settings - Fork 55
/
publish.sh
330 lines (300 loc) · 10.2 KB
/
publish.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
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
#!/bin/sh
#*******************************************************************************
# Copyright (c) 2016, 2017 itemis AG and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Alexander Nyßen (itemis AG) - initial API and implementation
#*******************************************************************************
# Script may take 6-7 command line parameters:
# $1: Hudson job name: <name>
# $2: Hudson build id: <id>
# $3: Build type: i(ntegration), s(table), r(elease)
# $4: Whether to promote to an update-site: (y)es, (n)o
# $5: Whether to merge the site with an existing one: (y)es, (n)o
# $6: Whether to generate drop files: (y)es, (n)o
# $7: The release label used to label the drop files and (nested) update site, e.g. 3.10.0 or 3.10.1
# $8: An optional release label suffix to be appended to drop files and (nested) update site name, e.g. M1, RC1
if [ $# -eq 7 -o $# -eq 8 ];
then
jobName=$1
echo "jobName: $jobName"
buildId=$2
echo "buildId: $buildId"
buildType=$3
echo "buildType: $buildType"
site=$4
echo "site: $site"
merge=$5
echo "merge: $merge"
dropFiles=$6
echo "dropFiles: $dropFiles"
releaseLabel=$7
echo "releaseLabel: $releaseLabel"
if [ -n "$8" ];
then
releaseLabelSuffix=$8
echo "releaseLabelSuffix: $releaseLabelSuffix"
fi
else
if [ $# -ne 0 ];
then
exit 1
fi
fi
if [ -z "$jobName" ];
then
echo -n "Please enter the name of the Hudson job you want to promote:"
read jobName
fi
if [ -z "$buildId" ];
then
for i in $( find ~/.hudson/jobs/$jobName/builds -type l | sed 's!.*/!!' | sort)
do
echo -n "$i, "
done
echo "lastStable, lastSuccessful"
echo -n "Please enter the id of the $jobName build you want to promote:"
read buildId
fi
if [ "$buildId" = "lastStable" -o "$buildId" = "lastSuccessful" ];
then
# Reverse lookup the build id (in case lastSuccessful or lastStable was used)
for i in $(find ~/.hudson/jobs/$jobName/builds/ -type l)
do
if [ "$(readlink -f $i)" = "$(readlink -f ~/.hudson/jobs/$jobName/$buildId)" ];
then
buildId=${i##*/}
fi
done
echo "Reverse lookup (lastStable/lastSuccessful) yielded buildId: $buildId"
fi
# Determine the local update site we want to publish to
jobDir=$(readlink -f ~/.hudson/jobs/$jobName/builds/$buildId)
if [ ! -d $jobDir ];
then
echo "The specified buildId does not refer to an existing build: $buildId"
exit 1
fi
localUpdateSite=$jobDir/archive/update-site
echo "Publishing from local update site: $localUpdateSite"
# Select the build type
if [ -z "$buildType" ];
then
echo -n "Please select which type of build you want to publish to [i(integration), s(table), r(elease)]: "
read buildType
fi
echo "Publishing as $buildType build"
# check if we are going to promote to an update-site
if [ -z "$site" ];
then
echo -n "Do you want to promote to an remote update site? [(y)es, (n)o]:"
read site
fi
if [ "$site" != y -a "$site" != n ];
then
echo "Parameter site has to be 'y'(es) or 'n'(o) but was: $site"
exit 0
fi
echo "Promoting to remote update site: $site"
if [ "$site" = y ];
then
# Determine remote update site we want to promote to
case $buildType in
i|I) remoteSite=integration;;
s|S) remoteSite=milestones;;
r|R) remoteSite=releases;;
*)
echo "Parameter buildType has to be 'i'(ntegration), 's'(stable), or 'r'(elease), but was: $buildType"
exit 1 ;;
esac
remoteUpdateSiteBase="tools/gef/updates/$remoteSite"
remoteUpdateSite="/home/data/httpd/download.eclipse.org/$remoteUpdateSiteBase"
echo "Publishing to remote update-site: $remoteUpdateSite"
if [ -d "$remoteUpdateSite" ];
then
if [ -z "$merge" ];
then
echo -n "Do you want to merge with the existing update-site? [(y)es, (n)o]:"
read merge
fi
if [ "$merge" != y -a "$merge" != n ];
then
echo "Parameter merge has to be 'y'(es) or 'n'(o) but was: $merge"
exit 1
fi
else
merge=n
fi
echo "Merging with existing site: $merge"
fi
# check if we are going to create drop files
if [ -z "$dropFiles" ];
then
echo -n "Do you want to create drop files? [(y)es, (n)o]:"
read dropFiles
fi
if [ "$dropFiles" != y -a "$dropFiles" != n ];
then
echo "Parameter dropFiles has to be 'y'(es) or 'n'(o) but was: $dropFiles"
exit 1
fi
echo "Generating drop files: $dropFiles"
# Determine releaseLabel
if [ -z "$releaseLabel" ];
then
echo -n "Please enter release label (e.g. 3.10.0, 3.10.1M2):"
read releaseLabel
fi
# Prepare a temp directory
tmpDir="$jobName-publish-tmp"
rm -fr $tmpDir
mkdir -p $tmpDir
cd $tmpDir
# Download and prepare Eclipse SDK, which is needed to merge update site and postprocess repository
echo "Downloading eclipse to $PWD"
cp /home/data/httpd/download.eclipse.org/eclipse/downloads/drops4/R-4.7.1-201709061700/eclipse-SDK-4.7.1-linux-gtk-x86_64.tar.gz .
tar -xvzf eclipse-SDK-4.7.1-linux-gtk-x86_64.tar.gz
cd eclipse
chmod 700 eclipse
cd ..
if [ ! -d "eclipse" ];
then
echo "Failed to download an Eclipse SDK, being needed for provisioning."
exit 1
fi
# Prepare Eclipse SDK to provide WTP releng tools (used to postprocess repository, i.e set p2.mirrorsURL property)
echo "Installing WTP Releng tools"
./eclipse/eclipse -nosplash --launcher.suppressErrors -clean -debug -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/webtools/releng/repository/ -installIUs org.eclipse.wtp.releng.tools.feature.feature.group
# Clean up
echo "Cleaning up"
rm eclipse-SDK-4.6.2-linux-gtk-x86_64.tar.gz
# Generate drop files
if [ "$dropFiles" = y ];
then
# Prepare local update site (for drop files)
mkdir -p update-site
cp -R $localUpdateSite/* update-site/
echo "Copied $localUpdateSite to local directory update-site."
qualifiedVersion=$(find update-site/features/ -maxdepth 1 | grep "org.eclipse.gef.common.sdk")
qualifiedVersion=${qualifiedVersion%.jar}
qualifiedVersion=${qualifiedVersion#*_}
qualifier=${qualifiedVersion##*.}
dropDir="${releaseLabel}/$(echo $buildType | tr '[:lower:]' '[:upper:]')$qualifier"
localDropDir=drops/$dropDir
echo "Creating drop files in local directory $localDropDir"
mkdir -p $localDropDir
cd update-site
zip -r ../$localDropDir/GEF-Update-${releaseLabel}${releaseLabelSuffix}.zip features plugins artifacts.jar content.jar
md5sum ../$localDropDir/GEF-Update-${releaseLabel}${releaseLabelSuffix}.zip > ../$localDropDir/GEF-Update-${releaseLabel}${releaseLabelSuffix}.zip.md5
echo "Created GEF-Update-Site-${releaseLabel}${releaseLabelSuffix}.zip"
cd ..
# Cleanup local update site (for drop files generation)
rm -fr update-site
#generating build.cfg file to be referenced from downloads web page
echo "hudson.job.name=$jobName" > $localDropDir/build.cfg
echo "hudson.job.id=$buildId (${jobDir##*/})" >> $localDropDir/build.cfg
echo "hudson.job.url=https://hudson.eclipse.org/gef/job/$jobName/$buildId" >> $localDropDir/build.cfg
remoteDropDir=/home/data/httpd/download.eclipse.org/tools/gef/downloads/drops/$dropDir
mkdir -p $remoteDropDir
cp -R $localDropDir/* $remoteDropDir/
fi
if [ "$site" = y ];
then
mkdir -p update-site
updateSiteLabel=${releaseLabel}${releaseLabelSuffix}_${jobName}_${buildId}
# Prepare composite local update site (transfer into composite if needed)
if [ "$merge" = y ];
then
# check if the remote site is a composite update site
echo "Merging existing site into local one."
if [ -e "$remoteUpdateSite/compositeArtifacts.xml" ];
then
cp -R $remoteUpdateSite/* update-site/
else
mkdir -p update-site/pre_${updateSiteLabel}
cp -R $remoteUpdateSite/* update-site/pre_${updateSiteLabel}/
fi
else
echo "Skipping merge operation."
fi
# move local update site below composite one
mkdir -p update-site/${updateSiteLabel}
cp -R $localUpdateSite/* update-site/${updateSiteLabel}/
cd update-site
children=$(find . -maxdepth 1 -type d -print | wc -l)
children=$(($children-1))
timestamp=$(date +%s000)
content="
<?xml version='1.0' encoding='UTF-8'?>
<?compositeMetadataRepository version='1.0.0'?>
<repository name='GEF ${remoteSite}' type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository' version='1.0.0'>
<properties size='1'>
<property name='p2.timestamp' value='${timestamp}'/>
</properties>
<children size='${children}'>
$(
for file in *; do
if [ -d $file ]; then
printf "<child location='${file}'/>"
fi
done
)
</children>
</repository>
"
echo $content > compositeContent.xml
artifact="
<?xml version='1.0' encoding='UTF-8'?>
<?compositeArtifactRepository version='1.0.0'?>
<repository name='GEF ${remoteSite}' type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository' version='1.0.0'>
<properties size='1'>
<property name='p2.timestamp' value='${timestamp}'/>
</properties>
<children size='${children}'>
$(
for file in *; do
if [ -d $file ]; then
printf "<child location='${file}'/>"
fi
done
)
</children>
</repository>
"
echo $artifact > compositeArtifacts.xml
cd ..
# Ensure p2.mirrorURLs property is used in update site
echo "Updating p2.mirrorURLs property."
./eclipse/eclipse -nosplash --launcher.suppressErrors -clean -debug -application org.eclipse.wtp.releng.tools.addRepoProperties -vmargs -DartifactRepoDirectory=$PWD/update-site/${updateSiteLabel} -Dp2MirrorsURL="http://www.eclipse.org/downloads/download.php?format=xml&file=/$remoteUpdateSiteBase/${updateSiteLabel}"
# Create p2.index file
if [ ! -e "update-site/p2.index" ];
then
echo "Creating p2.index file."
echo "version = 1" > update-site/p2.index
echo "metadata.repository.factory.order=compositeContent.xml,\!" >> update-site/p2.index
echo "artifact.repository.factory.order=compositeArtifacts.xml,\!" >> update-site/p2.index
fi
# Backup then clean remote update site
echo "Creating backup of remote update site."
if [ -d "$remoteUpdateSite" ];
then
if [ -d BACKUP ];
then
rm -fr BACKUP
fi
mkdir BACKUP
cp -R $remoteUpdateSite/* BACKUP/
rm -fr $remoteUpdateSite
fi
echo "Publishing contents of local update-site directory to remote update site $remoteUpdateSite"
mkdir -p $remoteUpdateSite
cp -R update-site/* $remoteUpdateSite/
fi
# Clean up
echo "Cleaning up"
rm -fr eclipse
rm -fr update-site