-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.xml
365 lines (338 loc) · 18.3 KB
/
build.xml
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
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="appserver-io-dist/debian" basedir="." default="dependencies-init">
<!-- Readin enviroment properties to env property -->
<property environment="env" />
<!-- Generate a timestamp to time.stamp property -->
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd-HHmmss"/>
</tstamp>
<!-- Read in build property files -->
<property file="${basedir}/build.properties"/>
<property file="${basedir}/buildfiles/${target-os.major.version}/build.default.properties"/>
<property file="${basedir}/buildfiles/generic/build.default.properties"/>
<!-- Set directory properties -->
<property name="src.dir" value="${basedir}/src" />
<property name="target.dir" value="${basedir}/target" />
<property name="build.dir" value="${basedir}/build" />
<property name="tests.dir" value="${basedir}/tests" />
<property name="temp.dir" value="${basedir}/tmp" />
<property name="reports.dir" value="${basedir}/reports" />
<!-- initialize the library specific properties -->
<property name="codepool" value="vendor"/>
<!-- initialize the directory where we can find the real build files -->
<property name="dependency.dir" value ="${basedir}/${codepool}" />
<property name="package.dir" value="${dependency.dir}/package" />
<property name="package.remote-location" value="https://github.com/appserver-io-dist/package.git" />
<!-- ==================================================================== -->
<!-- Import the local tests/*files -->
<!-- ==================================================================== -->
<import file="tests/${target-os.major.version}/test.xml" optional="true" />
<import file="tests/generic/test.xml" optional="true" />
<!-- ==================================================================== -->
<!-- Import the package build files if they are present -->
<!-- ==================================================================== -->
<import file="${package.dir}/common.xml" optional="true" />
<!-- ==================================================================== -->
<!-- Building up runtime package name and URL here, to get additional -->
<!-- data from the generic dist package first. -->
<!-- ==================================================================== -->
<property name="appserver.runtime.package" value="${build.name.prefix}runtime_${appserver.runtime.version}-${appserver.runtime.build}.deb${target-os.major.version}_${os.architecture}" />
<property name="appserver.runtime.url" value="https://github.com/appserver-io-php/runtime/releases/download/${appserver.runtime.version}/${appserver.runtime.package}.tar.gz" />
<!-- ==================================================================== -->
<!-- Cleans the target directories -->
<!-- ==================================================================== -->
<target name="clean">
<delete dir="${target.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
<delete dir="${temp.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
</target>
<!-- ==================================================================== -->
<!-- Cleans the build directories -->
<!-- ==================================================================== -->
<target name="clean-build" depends="prepare-build">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${build.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Cleans the reports directories -->
<!-- ==================================================================== -->
<target name="clean-reports" depends="prepare-reports">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${reports.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Prepares the target dir -->
<!-- ==================================================================== -->
<target name="prepare" depends="clean">
<mkdir dir="${target.dir}" />
<mkdir dir="${temp.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the reports environment -->
<!-- ==================================================================== -->
<target name="prepare-reports">
<mkdir dir="${reports.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the build environment -->
<!-- ==================================================================== -->
<target name="prepare-build">
<mkdir dir="${build.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Checks if the package helper libary is present -->
<!-- ==================================================================== -->
<target name="package-library-present">
<!-- check for the existence of the most central file of the package library -->
<available file="${package.dir}/common.xml" property="package-library.present" />
</target>
<!-- ==================================================================== -->
<!-- Loads all dependencies needed for the execution of build targets. -->
<!-- Not to be confused with the loading of dependencies needed for the -->
<!-- built packages! -->
<!-- ==================================================================== -->
<target name="dependencies-init" depends="package-library-present" unless="package-library.present">
<!-- create the target dir -->
<mkdir dir="${dependency.dir}" />
<!-- clone the latest version of our package library -->
<exec dir="${dependency.dir}" executable="git">
<arg line="clone ${package.remote-location}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Propagates the recent build to the official release sites, updates -->
<!-- release lists, etc.. Not to be mistaken for the "publish" target -->
<!-- ==================================================================== -->
<target name="release" description="Propagates the recent build to the official release sites, updates release lists, etc..">
<echo message="Now starting release cycle"/>
</target>
<!-- ==================================================================== -->
<!-- Publishes the recent build to any snapshot hubs, etc.. Not to be -->
<!-- mistaken for the "release" target -->
<!-- ==================================================================== -->
<target name="publish" description="Publishes the recent build to any snapshot hubs, etc..">
<echo message="Now starting publish cycle"/>
<!-- upload the build artifacts to the snapshot hub -->
<antcall target="copy-to-hub" />
</target>
<!-- ==================================================================== -->
<!-- Will provide the appserver.src.version property if not defined -->
<!-- already -->
<!-- ==================================================================== -->
<target name="get-appserver-src-version">
<!-- we have to get the source first -->
<antcall target="get-appserver-src" />
<!-- get lastest tag version -->
<exec dir="${temp.dir}/appserver-src" executable="git" outputProperty="appserver.src.version">
<arg line="describe --abbrev=0 --tags" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will split the github tag into a semver version (e.g. 1.0.0) and a -->
<!-- suffix (e.g. beta) -->
<!-- ==================================================================== -->
<target name="prepare-src-version-parts" depends="get-appserver-src-version">
<!-- filter the version string -->
<filter-version param="${appserver.src.version}" />
<property name="appserver.src.semver" value="${RESULT_VERSION}" />
<condition property="appserver.src.suffix" value="+${RESULT_BUILD-NUMBER}">
<not>
<equals arg1="${RESULT_BUILD-NUMBER}" arg2="" />
</not>
</condition>
<property name="appserver.src.suffix" value="${RESULT_BUILD-NUMBER}" />
</target>
<!-- ==================================================================== -->
<!-- Creates a DEB package with the appserver sources -->
<!-- ==================================================================== -->
<target name="create-appserver-dist-deb" depends="prepare-src-version-parts" description="Creates a DEB package with appserver sources">
<!-- prepare the dist creation -->
<antcall target="prepare-appserver-dist" />
<!-- copy packaging build files to target -->
<copy todir="${target.dir}/src">
<fileset dir="${src.dir}/generic/dist">
<include name="**/*"/>
<exclude name="DEBIAN/**"/>
</fileset>
</copy>
<copy todir="${target.dir}/src">
<fileset dir="${src.dir}/generic/dist">
<include name="DEBIAN/**"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- overwrite the generic files with the version sepcific ones, do not fail if there are none -->
<copy todir="${target.dir}/src" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${src.dir}/${target-os.major.version}/dist">
<include name="**/*"/>
<exclude name="DEBIAN/**"/>
</fileset>
</copy>
<copy todir="${target.dir}/src" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${src.dir}/${target-os.major.version}/dist">
<include name="DEBIAN/**"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- set the permissions of the install script -->
<chmod perm="755" file="${target.dir}/src/DEBIAN/postinst" />
<chmod perm="755" file="${target.dir}/src/DEBIAN/prerm" />
<!-- create the .deb file -->
<exec dir="${target.dir}" executable="dpkg-deb" failonerror="true">
<arg line="--build ${target.dir}/src ${build.dir}/${build.name.prefix}dist_${appserver.src.semver}-${build.number}${appserver.src.suffix}~deb${target-os.major.version}_${os.architecture}.${build.name.ext}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Creates a DEB package for the appserver runtime -->
<!-- ==================================================================== -->
<target name="create-appserver-runtime-deb" depends="prepare">
<!-- get runtime in specific version as tar.gz -->
<get src="${appserver.runtime.url}" dest="${temp.dir}/${appserver.runtime.package}.tar.gz"/>
<untar src="${temp.dir}/${appserver.runtime.package}.tar.gz" dest="${target.dir}/opt" compression="gzip" />
<mkdir dir="${target.dir}/opt" />
<exec executable="tar">
<arg value="-xzf"/>
<arg value="${temp.dir}/${appserver.runtime.package}.tar.gz"/>
<arg value="-p"/>
<arg value="-C"/>
<arg value="${target.dir}/opt"/>
</exec>
<!-- copy packaging build files to target -->
<copy todir="${target.dir}">
<fileset dir="${src.dir}/generic/runtime">
<include name="**/*"/>
<exclude name="DEBIAN/**"/>
</fileset>
</copy>
<copy todir="${target.dir}">
<fileset dir="${src.dir}/generic/runtime">
<include name="DEBIAN/**"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- overwrite the generic files with the version sepcific ones, do not fail if there are none -->
<copy todir="${target.dir}" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${src.dir}/${target-os.major.version}/runtime">
<include name="**/*"/>
<exclude name="DEBIAN/**"/>
</fileset>
</copy>
<copy todir="${target.dir}" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${src.dir}/${target-os.major.version}/runtime">
<include name="DEBIAN/**"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- create the .deb file -->
<exec dir="${target.dir}" executable="dpkg-deb" failonerror="true">
<arg line="--build ${target.dir} ${build.dir}/${appserver.runtime.package}.${build.name.ext}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will prepare the environment to run a vagrant box in -->
<!-- ==================================================================== -->
<target name="prepare-build-environment" depends="prepare, clean-build, clean-reports">
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}">
<include name="build.*"/>
<include name="buildfiles/**"/>
<include name="${codepool}/**"/>
</fileset>
</copy>
<!-- expand the properties within our box configuration -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}/buildfiles/generic">
<include name="Vagrantfile"/>
<include name="provision.sh"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- overwrite the generic files with the version sepcific ones, do not fail if there are none -->
<copy todir="${temp.dir}" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${basedir}/buildfiles/${target-os.major.version}">
<include name="Vagrantfile"/>
<include name="provision.sh"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- prepare a tmp dir for work within the VM -->
<mkdir dir="${temp.dir}/tmp" />
</target>
<!-- ==================================================================== -->
<!-- Will prepare the environment to run a testing vagrant box in -->
<!-- ==================================================================== -->
<target name="prepare-test-environment" depends="prepare, clean-reports">
<!-- copy the basic build files -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}">
<include name="build.*"/>
<include name="buildfiles/**"/>
<include name="${codepool}/**"/>
</fileset>
</copy>
<copy todir="${temp.dir}/tests" failonerror="true">
<fileset dir="${basedir}/tests">
<include name="*/**"/>
<exclude name="*/provision.sh"/>
</fileset>
</copy>
<!-- expand the properties within our box configuration -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${tests.dir}/generic">
<include name="provision.sh"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- overwrite the generic files with the version sepcific ones, do not fail if there are none -->
<copy todir="${temp.dir}" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${tests.dir}/${target-os.major.version}">
<include name="provision.sh"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- expand the properties within our box configuration -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}/buildfiles/generic">
<include name="Vagrantfile"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- overwrite the generic files with the version sepcific ones, do not fail if there are none -->
<copy todir="${temp.dir}" overwrite="true" failonerror="false" quiet="true">
<fileset dir="${basedir}/buildfiles/${target-os.major.version}">
<include name="Vagrantfile"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- prepare a tmp dir for work within the VM -->
<mkdir dir="${temp.dir}/tmp" />
</target>
<!-- ==================================================================== -->
<!-- Creates all DEB packages locally -->
<!-- ==================================================================== -->
<target name="local-build" depends="prepare, prepare-build, create-appserver-dist-deb, create-appserver-runtime-deb">
<!-- nothing to do here -->
</target>
</project>