-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.xml
216 lines (194 loc) · 9.4 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
<!--
Copyright (c) Intel Corporation
Copyright (c) 2017
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="vmidcDeployMgr" default="build" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>a vmidc deploy tool</description>
<property name="image-format" value="vmdk_only" />
<target name="ovf" depends="build,ovfOnly,ovfCopy" description="build all and generate vmidc ovf" />
<target name="dockerimage" depends="build,dockerImageBuild,clean" description="build all and generate docker image in tar" />
<target name="build" depends="deleteJavaJre">
<echo>Ant version: ${ant.version}</echo>
<echo>Ant Java/JVM version: ${ant.java.version}</echo>
<echo>Java/JVM detail version: ${java.version}</echo>
<exec executable="mvn">
<arg value="-version" />
</exec>
<exec executable="mvn" failonerror="true">
<arg value="clean" />
<arg value="install" />
<!-- Skip checkstyle see https://github.com/opensecuritycontroller/osc-core/issues/373 -->
<arg value="-Dcheckstyle.skip=true" if:true="${all}" />
<arg value="-Pall" if:true="${all}" />
</exec>
</target>
<target name="ovfOnly" depends="prodVersion" description="Runs ovfBuild and cleans up on error">
<waitfor maxwait="20" maxwaitunit="minute" checkevery="10" checkeveryunit="second">
<not>
<available file="/tmp/build_marker" />
</not>
</waitfor>
<touch file="/tmp/build_marker" />
<exec executable="schroot" resultproperty="ovf.result" dir="osc-server-bom/">
<arg value="-c" />
<arg value="centos" />
<arg value="--" />
<arg value="ant" />
<arg value="-Dimage-format=${image-format}" />
<arg value="-Dbranchname=${branchname}" />
<arg value="-DbuildNumber=${fullVersion}" />
<arg value="-DproductVersion=${releaseVersion}" />
</exec>
<delete file="/tmp/build_marker" />
</target>
<target name="ovfCopy" depends="prodVersion,createBuildDir,copyServerUpgradeBundle,copyPlugins,copyImages" description="Copy result files to build dir">
<copy file="osc-server-bom/OSC.ovf" tofile="Build${fullVersion}/OSC-${fullVersion}.ovf" />
<replace file="Build${fullVersion}/OSC-${fullVersion}.ovf" token="$OSC_VERSION" value="${releaseVersion}" />
<zip destfile="Build${fullVersion}/OSC-${releaseVersion}_Build${fullVersion}.zip">
<fileset dir="Build${fullVersion}" includes="**/*.vmdk **/*.ovf **/serverUpgradeBundle-*.zip" />
</zip>
</target>
<target name="createBuildDir">
<delete includeemptydirs="true">
<fileset dir="." includes="Build*/**" />
</delete>
<mkdir dir="Build${fullVersion}" />
</target>
<target name="copyServerUpgradeBundle">
<copy file="target/serverUpgradeBundle.zip" tofile="Build${fullVersion}/serverUpgradeBundle-${fullVersion}.zip" />
</target>
<target name="copyPlugins" if="${all}">
<copy tofile="Build${fullVersion}/SampleMgrPlugin.bar">
<fileset dir="${basedir}/../security-mgr-sample-plugin/target/" includes="SampleMgrPlugin*.bar" />
</copy>
<copy tofile="Build${fullVersion}/Panorama.bar">
<fileset dir="${basedir}/../osc-pan-plugin/target/" includes="Panorama*.bar" />
</copy>
<copy tofile="Build${fullVersion}/NscSdnControllerPlugin.bar">
<fileset dir="${basedir}/../sdn-controller-nsc-plugin/target/" includes="NscSdnControllerPlugin*.bar" />
</copy>
<copy tofile="Build${fullVersion}/NuageSdnControllerPlugin.bar">
<fileset dir="${basedir}/../osc-nuage-plugin/target/" includes="NuageSdnControllerPlugin*.bar" />
</copy>
<copy tofile="Build${fullVersion}/NeutronSfcSdnControllerPlugin.bar">
<fileset dir="${basedir}/../sdn-controller-nsfc-plugin/target/" includes="NeutronSfcSdnControllerPlugin*.bar" />
</copy>
</target>
<target name="checkImagesTocopy">
<condition property="isvmdkImage">
<OR>
<equals arg1="vmdk_only" arg2="${image-format}" />
<equals arg1="qcow2-vmdk" arg2="${image-format}" />
</OR>
</condition>
<condition property="isqcow2Image">
<OR>
<equals arg1="qcow2-only" arg2="${image-format}" />
<equals arg1="qcow2-vmdk" arg2="${image-format}" />
</OR>
</condition>
<condition property="israwImage">
<equals arg1="raw-only" arg2="${image-format}" />
</condition>
</target>
<target name="checkFileExist">
<available file="${basedir}/osc-server-bom/Sources/jre-8u131-linux-x64.tar.gz" property="isJavaJreExist"/>
</target>
<target name="copyImages" depends="vmdkImageCopy,qcow2ImageCopy,rawImageCopy" description="Checks image format and copy respective files" />
<target name="vmdkImageCopy" depends="checkImagesTocopy" if="isvmdkImage">
<move file="osc-server-bom/OSC_disk-0.vmdk" tofile="Build${fullVersion}/OSC_disk-0.vmdk" />
</target>
<target name="qcow2ImageCopy" depends="checkImagesTocopy" if="isqcow2Image">
<move file="osc-server-bom/OSC_disk-0.qcow2" tofile="Build${fullVersion}/OSC_disk-0.qcow2" />
</target>
<target name="rawImageCopy" depends="checkImagesTocopy" if="israwImage">
<move file="osc-server-bom/OSC_disk-0-raw.img" tofile="Build${fullVersion}/OSC_disk-0-raw.img" />
</target>
<target name="deleteJavaJre" depends="checkFileExist" if="isJavaJreExist">
<delete file="${basedir}/osc-server-bom/Sources/jre-8u131-linux-x64.tar.gz" />
</target>
<target name="prodVersion">
<!-- Full version examples: 1.0.0-SNAPSHOT-0-HASH, 1.0.0-0-HASH, 1.0.0-1-HASH, etc -->
<exec outputproperty="fullVersion" dir="." executable="sh">
<arg value="-c" />
<arg value="git describe --long | tr -d v" />
</exec>
<!-- Version examples: 1.0.0-SNAPSHOT, 1.0.0, etc -->
<exec outputproperty="releaseVersion" dir="." executable="sh">
<arg value="-c" />
<arg value="git describe --abbrev=0 | tr -d v" />
</exec>
<echo>Full Version: ${fullVersion}</echo>
<echo>Version: ${releaseVersion}</echo>
</target>
<target name="dockerImageBuild" depends="prodVersion,createBuildDir,copyAndUnzipServerUpgradeBundle,copyServerUpgradeBundle,copyPlugins,createDockerImage" description="Copy result files to build dir">
<zip destfile="Build${fullVersion}/OSC-${releaseVersion}_Build${fullVersion}.zip">
<fileset dir="Build${fullVersion}" includes="**/*.tar **/serverUpgradeBundle-*.zip" />
</zip>
</target>
<target name="checkServerUpgradeBundleExist">
<available file="docker/serverUpgradeBundle*.zip" property="isServerUpgradeBundleExist"/>
</target>
<target name="deleteOldServerUpgradeBundle" depends="checkServerUpgradeBundleExist" if="isServerUpgradeBundleExist">
<delete>
<fileset dir="docker/" includes="serverUpgradeBundle-*.zip" />
</delete>
</target>
<target name="copyAndUnzipServerUpgradeBundle" depends="deleteOldServerUpgradeBundle">
<copy file="target/serverUpgradeBundle.zip" tofile="docker/serverUpgradeBundle-${fullVersion}.zip" />
<exec executable="unzip" resultproperty="tar.result" dir="docker/">
<arg value="serverUpgradeBundle-${fullVersion}.zip" />
</exec>
</target>
<target name="clean" >
<delete file="docker/serverUpgradeBundle-${fullVersion}.zip"/>
<delete dir="docker/opt" />
</target>
<target name="createDockerImage" description="create docker image">
<exec executable="docker" resultproperty="tar.result">
<arg value="pull" />
<arg value="centos:latest" />
</exec>
<property environment="env"/>
<exec executable="docker" resultproperty="tar.result" dir="docker/">
<arg value="build" />
<arg value="--build-arg" if:set="env.https_proxy" />
<arg value="https_proxy=${env.https_proxy}" if:set="env.https_proxy" />
<arg value="--build-arg" if:set="env.http_proxy" />
<arg value="http_proxy=${env.http_proxy}" if:set="env.http_proxy" />
<arg value="-f" />
<arg value="Dockerfile-osc-base" />
<arg value="." />
<arg value="-t" />
<arg value="osc-base-image:osc-base" />
</exec>
<exec executable="docker" resultproperty="tar.result" dir="docker/">
<arg value="build" />
<arg value="--build-arg" if:set="env.https_proxy" />
<arg value="https_proxy=${env.https_proxy}" if:set="env.https_proxy" />
<arg value="--build-arg" if:set="env.http_proxy" />
<arg value="http_proxy=${env.http_proxy}" if:set="env.http_proxy" />
<arg value="-f" />
<arg value="Dockerfile" />
<arg value="." />
<arg value="-t" />
<arg value="osc-docker-image:osc" />
</exec>
<exec executable="docker" resultproperty="tar.result" dir="Build${fullVersion}/">
<arg value="image" />
<arg value="save" />
<arg value="-o" />
<arg value="osc-docker.tar" />
<arg value="osc-docker-image:osc" />
</exec>
</target>
</project>