blob: bcb6db85830bda08a09892956e6eb95b7075793d (
plain)
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
|
<!--
Copyright (c) 2011 Gunnar Wagenknecht 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:
Gunnar Wagenknecht - initial API and implementation
-->
<project name="build-gyrex-repository" default="main" >
<description>Builds the final Gyrex repository</description>
<!-- define builder home dir -->
<dirname file="${ant.file.build-gyrex-repository}" property="builder"/>
<!-- load local build specific properties -->
<!-- (we allow custom local properties file via -Dbuild.local.properties=... -->
<property name="build.local.properties" location="${builder}/../../build.local.properties"/>
<property file="${build.local.properties}" />
<!-- load project build properties -->
<property name="build.project.properties" location="${builder}/../../build.properties"/>
<property file="${build.project.properties}" />
<!-- load default build properties -->
<property name="build.default.properties" location="${builder}/../../common/build.default.properties"/>
<property file="${build.default.properties}" />
<!-- set default for common build scripts -->
<property name="commonBuildScripts" location="../../common"/>
<!-- import common build helpers -->
<import file="${commonBuildScripts}/buildhelpers.xml" />
<!-- ==================================================================================
target: main
depends on: 'builder.prepare' to inherit common builder behavior
================================================================================== -->
<target name="main" description="Builds the Gyrex Repository" depends="builder.prepare">
<!-- print build information -->
<echo message="Gyrex Repository build: ${buildLabel}"/>
<!--
The final repository generation is somewhat dump. It relies on everything being
published by previous PDE Build configs into the build repository. We should
verify this being ok with the PDE Build guru.
-->
<!-- that's the location we mirror everything too -->
<mkdir dir="${buildDirectory}/${archiveNamePrefix}-${buildId}-repo"/> <!-- required by makeurl -->
<makeurl property="resultRepoLocationUrl" file="${buildDirectory}/${archiveNamePrefix}-${buildId}-repo"/>
<!-- at this time we capture everything that is in the build repository -->
<p2.mirror source="file:${buildDirectory}/buildRepo" log="${buildDirectory}/${archiveNamePrefix}-${buildId}-repo.log" ignoreErrors="true">
<destination compressed="true" name="${p2.repo.name.prefix} (Build ${buildId})" location="${resultRepoLocationUrl}"/>
</p2.mirror>
<zip destfile="${buildDirectory}/${buildLabel}/${archiveNamePrefix}-${buildId}-repo.zip" filesonly="false" whenempty="skip" update="true">
<zipfileset dir="${buildDirectory}/${archiveNamePrefix}-${buildId}-repo" includes="**/**" excludes="" />
</zip>
<!-- generate additional publishing files (html pages & stuff) -->
<antcall target="generateAddtionalFilesToPublish"/>
<!-- publish to eclipse.org downloads area -->
<antcall target="publishToDownloadArea"/>
</target>
<!-- generates additional publishing files -->
<target name="generateAddtionalFilesToPublish">
<fail unless="publishRepoStream" message="property publishRepoStream not set"/>
<fail unless="publishRepoBasePath" message="property publishRepoBasePath not set"/>
<!-- give the build type a better name -->
<condition property="buildTypeName" value="Release"><equals arg1="${buildType}" arg2="R"/></condition>
<condition property="buildTypeName" value="Stable Build"><equals arg1="${buildType}" arg2="S"/></condition>
<condition property="buildTypeName" value="Integration Build"><equals arg1="${buildType}" arg2="I"/></condition>
<property name="buildTypeName" value="Build"/>
<!-- generate build index html -->
<copy file="${builder}/template-eclipse.org/build-index.html" tofile="${buildDirectory}/${buildLabel}/index.html">
<filterset>
<filter token="BUILD_TYPE" value="${buildTypeName}"/>
<filter token="BUILD_ID" value="${buildId}"/>
<filter token="BUILD_LABEL" value="${buildLabel}"/>
<filter token="BUILD_PATH" value="${publishRepoBasePath}/${buildLabel}"/>
<filter token="SERVER_ARCHIVE_PREFIX" value="${archiveNamePrefix}"/>
<filter token="REPO_ARCHIVE_PREFIX" value="${archiveNamePrefix}"/>
</filterset>
</copy>
<!-- copy p2.index file -->
<copy file="${builder}/template-eclipse.org/p2.index" tofile="${buildDirectory}/${buildLabel}/p2.index"/>
</target>
<!-- publish bits to download area -->
<target name="publishToDownloadArea" unless="skipPublish">
<!-- check if we have *local* access on eclipse.org -->
<condition property="publishToDownloadAreaIsPossible">
<and>
<!-- composite repo location must exist -->
<available file="${publishBaseDirectory}" type="dir"/>
<!-- build type must be allowed for publishing -->
<or>
<equals arg1="${buildType}" arg2="S"/>
<equals arg1="${buildType}" arg2="R"/>
<!-- note, we do publish those as well but we also need to clean-up old builds regulary -->
<equals arg1="${buildType}" arg2="I"/>
<equals arg1="${buildType}" arg2="M"/>
</or>
</and>
</condition>
<!-- mirror repo -->
<antcall target="mirrorToPublishTarget"/>
<!-- copy artifacts -->
<antcall target="copyArtifactsToPublishTarget"/>
<!-- fix file permissions -->
<antcall target="fixFilePermissionsOfPublishTarget"/>
</target>
<!-- mirrors p2 repository to download area -->
<target name="mirrorToPublishTarget" if="publishToDownloadAreaIsPossible">
<fail unless="resultRepoLocationUrl" message="property resultRepoLocationUrl not set"/>
<fail unless="publishBaseDirectory" message="property publishBaseDirectory not set"/>
<fail unless="publishRepoStream" message="property publishRepoStream not set"/>
<fail unless="publishRepoBasePath" message="property publishRepoBasePath not set"/>
<fail unless="publishRepoIndexGeneratorUrl" message="property publishRepoIndexGeneratorUrl not set"/>
<!-- generate all the relevant urls -->
<mkdir dir="${buildDirectory}/publishRepoTemplate"/>
<mkdir dir="${publishBaseDirectory}${publishRepoBasePath}"/>
<mkdir dir="${publishBaseDirectory}${publishRepoBasePath}/${buildLabel}"/>
<makeurl property="templateRepoUrl" file="${buildDirectory}/publishRepoTemplate"/>
<makeurl property="publishBuildRepoUrl" file="${publishBaseDirectory}${publishRepoBasePath}/${buildLabel}"/>
<makeurl property="publishCompositeRepoUrl" file="${publishBaseDirectory}${publishRepoBasePath}"/>
<!-- generate template with proper mirror urls -->
<copy file="${builder}/template-eclipse.org/artifacts.xml" tofile="${buildDirectory}/publishRepoTemplate/artifacts.xml">
<filterset>
<filter token="REPO_NAME" value="${p2.repo.name.prefix} (Build ${buildId})"/>
<filter token="REPO_PATH" value="${publishRepoBasePath}/${buildLabel}"/>
</filterset>
</copy>
<!-- mirror to target (but only the bits that really changed) -->
<p2.mirror log="${buildDirectory}/${buildLabel}/publish-repo.log" ignoreErrors="true">
<source location="${resultRepoLocationUrl}"/>
<destination compressed="true" name="${p2.repo.name.prefix} (Build ${buildId})" location="${publishBuildRepoUrl}" append="true" format="${resultRepoLocationUrl}" kind="metadata"/>
<destination compressed="true" name="${p2.repo.name.prefix} (Build ${buildId})" location="${publishBuildRepoUrl}" append="true" format="${templateRepoUrl}" kind="artifact"/>
<comparator comparator="org.eclipse.equinox.p2.repository.tools.jar.comparator" comparatorLog="${buildDirectory}/${buildLabel}/publish-repo-compare.log">
<!-- compare against the existing composite to not mirror duplicate bits -->
<repository location="${publishCompositeRepoUrl}" />
</comparator>
<!-- mirror only what's defined in features -->
<slicingoptions followStrict="true" latestversiononly="true"/>
</p2.mirror>
<!-- add to composite repo -->
<p2.composite.repository failonexists="false">
<repository location="${publishCompositeRepoUrl}" name="${p2.repo.name.prefix} (${publishRepoStream} builds)" description="Composite repository with references to all ${publishRepoStream} builds." compressed="true"/>
<add>
<repository location="${buildLabel}" kind="M" />
<repository location="${buildLabel}" kind="A" />
</add>
</p2.composite.repository>
<!-- generate composite repo index html using our helper online php -->
<unjar src="${publishBaseDirectory}${publishRepoBasePath}/compositeContent.jar" dest="${buildDirectory}/publishRepoTemplate" overwrite="true"/>
<available file="${buildDirectory}/publishRepoTemplate/compositeContent.xml" property="compositeContentXmlAvailable"/>
<fail unless="compositeContentXmlAvailable" message="compositeContent.xml not available"/>
<delete file="${publishBaseDirectory}${publishRepoBasePath}/index.html" failonerror="false"/>
<property name="generatePublishRepoIndexCommand" value="cat '${buildDirectory}/publishRepoTemplate/compositeContent.xml' | curl -X POST -H 'Content-type: text/xml' -o '${publishBaseDirectory}${publishRepoBasePath}/index.html' -d @- '${publishRepoIndexGeneratorUrl}?buildType=${buildType}&repoPath=${publishRepoBasePath}'"/>
<echo message="Generating repository index.html using: ${generatePublishRepoIndexCommand}"/>
<exec executable="/bin/bash">
<arg value="-c"/>
<arg value="${generatePublishRepoIndexCommand}"/>
</exec>
<available file="${publishBaseDirectory}${publishRepoBasePath}/index.html" property="repoIndexHtmlGenerated"/>
<fail unless="repoIndexHtmlGenerated" message="index.html generation failed"/>
</target>
<!-- copy artifacts to download area -->
<target name="copyArtifactsToPublishTarget" if="publishToDownloadAreaIsPossible">
<fail unless="publishRepoStream" message="property publishRepoStream not set"/>
<fail unless="publishRepoBasePath" message="property publishRepoBasePath not set"/>
<!-- copy everything from build label directory -->
<copy todir="${publishBaseDirectory}${publishRepoBasePath}/${buildLabel}" includeemptydirs="false">
<fileset dir="${buildDirectory}/${buildLabel}"/>
</copy>
</target>
<!-- fix file permissions in download area -->
<target name="fixFilePermissionsOfPublishTarget" if="publishToDownloadAreaIsPossible">
<fail unless="publishBaseDirectory" message="property publishBaseDirectory not set"/>
<fail unless="publishRepoBasePath" message="property publishRepoBasePath not set"/>
<fail unless="buildLabel" message="property buildLabel not set"/>
<!-- set proper group writable -->
<!-- (note doesn't work because the builder isn't in that group)
<exec executable="/bin/bash">
<arg value="-c"/>
<arg value="chgrp technology.gyrex -R '${publishBaseDirectory}${publishRepoBasePath}'"/>
</exec>
-->
<!-- update file permissions to ensure group writable -->
<exec executable="/bin/bash">
<arg value="-c"/>
<arg value="chmod g+w -R '${publishBaseDirectory}${publishRepoBasePath}'"/>
</exec>
</target>
</project>
|