-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.xml
292 lines (282 loc) · 15.5 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
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="zm-ldap-utilities" default="jar">
<import file="../zm-zcs/ant-global.xml"/>
<property name="service.webapp.dir" location="${jetty.webapps.dir}/service"/>
<property name="zimbra.webapp.dir" location="${jetty.webapps.dir}/zimbra"/>
<property name="zimbra-admin.webapp.dir" location="${jetty.webapps.dir}/zimbraAdmin"/>
<property name="attr.config.dir" location="../zm-mailbox/store/conf"/>
<property name="config.dir" location="conf"/>
<property name="warfilename" value="service.war"/>
<property name="warfile" location="${build.dir}/${warfilename}"/>
<condition property="production.suffix" value=".production" else="">
<isset property="is-production"/>
</condition>
<condition property="war.web.xml" value="${config.dir}/web.xml${production.suffix}">
<not>
<isset property="war.web.xml"/>
</not>
</condition>
<!-- properties used for generating and testing LDAP changes -->
<property name="ldap.config.dir" location="conf/ldap"/>
<property name="slapd.config.dir" value="${ldap.config.dir}/config"/>
<condition property="slapd.config.src" value="${slapd.config.dir}/cn=config.ldif">
<isset property="is-production"/>
</condition>
<condition property="slapd.config.src" value="${slapd.config.dir}/cn=config.ldif.dev">
<not>
<isset property="is-production"/>
</not>
</condition>
<property name="slapd.conf.src" value="${ldap.config.dir}/slapd.conf${production.suffix}"/>
<property name="slapd.conf.dir" value="conf"/>
<property name="slapd.etc.dir" value="common/etc/openldap"/>
<property name="ldapmodify" value="${zimbra.home.dir}/common/bin/ldapmodify"/>
<property name="ldapdelete" value="${zimbra.home.dir}/common/bin/ldapdelete"/>
<property name="build-dist" value="${build.dir}/dist"/>
<!-- classpath for running utilities -->
<path id="run.class.path">
<path refid="class.path"/>
<pathelement location="${build.classes.dir}"/>
</path>
<target name="stop-webserver">
<exec executable="zmmailboxdctl">
<arg value="stop"/>
</exec>
</target>
<target name="start-webserver">
<exec executable="zmmailboxdctl">
<arg value="start"/>
</exec>
</target>
<target name="restart-webserver">
<exec executable="zmmailboxdctl">
<arg value="restart"/>
</exec>
</target>
<target name="stop-zimbra">
<exec executable="zmcontrol">
<arg value="stop"/>
</exec>
</target>
<target name="start-zimbra">
<exec executable="zmcontrol">
<arg value="start"/>
</exec>
</target>
<target name="make-dirs">
<!-- take advantage of the fact that mkdir uses File.mkdirs() and creates inbetween dirs -->
<echo>Creating dirs under ${base.dir}</echo>
<mkdir dir="${base.dir}/${slapd.conf.dir}"/>
<mkdir dir="${base.dir}/${slapd.etc.dir}/schema"/>
<mkdir dir="${base.dir}/bin"/>
<mkdir dir="${base.dir}/conf/msgs"/>
<mkdir dir="${base.dir}/db"/>
<mkdir dir="${base.dir}/lib/ext"/>
<mkdir dir="${base.dir}/lib/jars"/>
<mkdir dir="${base.dir}/lib/jars-ant"/>
<mkdir dir="${base.dir}/libexec"/>
<mkdir dir="${build.dir}/dist"/>
</target>
<target name="build-init" description="Creates directories required for compiling">
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.dir}/data"/>
<antcall target="make-dirs">
<param name="base.dir" value="${dist.dir}"/>
</antcall>
</target>
<target name="generate-buildinfo" depends="build-init">
<mkdir dir="${build.dir}/buildinfo/com/zimbra/cs/util"/>
<echo file="${build.dir}/buildinfo/com/zimbra/cs/util/BuildInfoGenerated.java">
package com.zimbra.cs.util;
class BuildInfoGenerated {
public static final String MAJORVERSION = "${zimbra.buildinfo.majorversion}";
public static final String MINORVERSION = "${zimbra.buildinfo.minorversion}";
public static final String MICROVERSION = "${zimbra.buildinfo.microversion}";
public static final String RELCLASS = "${zimbra.buildinfo.relclass}";
public static final String RELNUM = "${zimbra.buildinfo.relnum}";
public static final String BUILDNUM = "${zimbra.buildinfo.buildnum}";
public static final String VERSION = "${zimbra.buildinfo.version}";
public static final String TYPE = "${zimbra.buildinfo.type}";
public static final String RELEASE = "${zimbra.buildinfo.release}";
public static final String DATE = "${DSTAMP}-${TSTAMP}";
public static final String HOST = "${zimbra.buildinfo.host}";
}
</echo>
<javac includeantruntime="false" destdir="${build.classes.dir}" debug="true" target="${javac.target}" srcdir="${build.dir}/buildinfo"/>
</target>
<target name="generate-getters" depends="compile,resolve" description="generate methods for attributes in zimbra-attrs.xml">
<antcall target="generate-getter">
<param name="getter.class" value="account"/>
<param name="getter.output" value="ZAttrAccount.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="calendarResource"/>
<param name="getter.output" value="ZAttrCalendarResource.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="cos"/>
<param name="getter.output" value="ZAttrCos.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="domain"/>
<param name="getter.output" value="ZAttrDomain.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="server"/>
<param name="getter.output" value="ZAttrServer.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="ucService"/>
<param name="getter.output" value="ZAttrUCService.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="globalConfig"/>
<param name="getter.output" value="ZAttrConfig.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="distributionList"/>
<param name="getter.output" value="ZAttrDistributionList.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="group"/>
<param name="getter.output" value="ZAttrDynamicGroup.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="shareLocator"/>
<param name="getter.output" value="ZAttrShareLocator.java"/>
</antcall>
<antcall target="generate-getter">
<param name="getter.class" value="alwaysOnCluster"/>
<param name="getter.output" value="ZAttrAlwaysOnCluster.java"/>
</antcall>
<antcall target="generate-provisioning"/>
</target>
<target name="generate-getter">
<ivy:cachepath pathid="class.path"/>
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateGetters -c ${getter.class} -i ${attr.config.dir}/attrs -r ${src.java.dir}/com/zimbra/cs/account/${getter.output}"/>
</java>
</target>
<target name="generate-provisioning">
<ivy:cachepath pathid="class.path"/>
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateProvisioning -i ${attr.config.dir}/attrs -r ${common.src.java.dir}/com/zimbra/common/account/ZAttrProvisioning.java"/>
</java>
</target>
<target name="jar" depends="generate-buildinfo,compile" description="Creates the jar file">
<antcall target="zimbra-jar">
<param name="implementation.title" value="Zimbra Server"/>
</antcall>
</target>
<target name="clean" description="Deletes classes from build directories">
<delete dir="${build.dir}"/>
</target>
<target name="undeploy">
<antcall target="stop-webserver"/>
<delete>
<fileset dir="${common.jars.dir}" includes="zm-store*.jar,zimbrastore*.jar"/>
<fileset dir="${service.webapp.dir}/WEB-INF/lib/" includes="zm-store*.jar,zimbrastore*.jar"/>
<fileset dir="${zimbra.webapp.dir}/WEB-INF/lib/" includes="zm-store*.jar,zimbrastore*.jar"/>
<fileset dir="${zimbra-admin.webapp.dir}/WEB-INF/lib/" includes="zm-store*.jar,zimbrastore*.jar"/>
</delete>
</target>
<target name="deploy" depends="jar,set-dev-version,undeploy">
<copy file="${build.dir}/${jar.file}" tofile="${common.jars.dir}/zimbrastore.jar"/>
<!-- have to use zimbrastore.jar until https://bugzilla.zimbra.com/show_bug.cgi?id=106076 is fixed -->
<copy file="${build.dir}/${jar.file}" todir="${service.webapp.dir}/WEB-INF/lib/"/>
<copy file="${build.dir}/${jar.file}" todir="${zimbra.webapp.dir}/WEB-INF/lib/"/>
<copy file="${build.dir}/${jar.file}" todir="${zimbra-admin.webapp.dir}/WEB-INF/lib/"/>
<antcall target="start-webserver"/>
</target>
<target name="copy-war">
<delete dir="${jetty.home.dir}/webapps/service"/>
<delete file="${jetty.home.dir}/webapps/${warfilename}"/>
<copy file="${warfile}" todir="${jetty.home.dir}/webapps"/>
<mkdir dir="${jetty.home.dir}/webapps/service"/>
<chmod file="${jetty.home.dir}/webapps/service" perm="o+rwx"/>
<chmod file="${jetty.home.dir}/webapps/service" perm="g+rx"/>
<chmod file="${jetty.home.dir}/webapps/service" perm="o-rwx"/>
<unzip dest="${jetty.home.dir}/webapps/service" src="${jetty.home.dir}/webapps/${warfilename}"/>
<delete file="${jetty.home.dir}/webapps/${warfilename}"/>
</target>
<target name="generate-ldap-config" depends="resolve">
<dependset>
<srcfileset dir="${attr.config.dir}/attrs" includes="*.xml"/>
<targetfileset dir="${build.dir}/ldap-config" includes="*"/>
</dependset>
<delete dir="${build.dir}/attrs"/>
<delete dir="${build.dir}/ldap-config"/>
<mkdir dir="${build.dir}/attrs"/>
<copy todir="${build.dir}/attrs" overwrite="true" preservelastmodified="true">
<fileset dir="${attr.config.dir}/attrs" includes="*.xml"/>
</copy>
<mkdir dir="${build.dir}/ldap-config"/>
<mkdir dir="${build.dir}/ldap-config/config"/>
<mkdir dir="${build.dir}/ldap-config/schema"/>
<mkdir dir="${build.dir}/ldap-config/config/cn=config"/>
<!-- Zimbra schema for pre OpenLDAP 2.4 - uses zimbra.schema-template, should eventually retire zimbra.schema-template and only use zimbra-ocs.xml -->
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateLdapSchema -i ${build.dir}/attrs -t ${ldap.config.dir}/zimbra.schema-template -o ${build.dir}/ldap-config/schema/zimbra.schema"/>
</java>
<!-- Zimbra schema for OpenLDAP 2.4 - use zimbra-ocs.xml -->
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateSchemaLdif -i ${build.dir}/attrs -o ${build.dir}/ldap-config/schema/zimbra.ldif"/>
</java>
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateGlobalConfigLdif -i ${build.dir}/attrs -o ${build.dir}/ldap-config/zimbra_globalconfig.ldif"/>
</java>
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateDefaultCOSLdif -i ${build.dir}/attrs -o ${build.dir}/ldap-config/zimbra_defaultcos.ldif"/>
</java>
<java classname="com.zimbra.cs.account.AttributeManagerUtil" fork="true" classpathref="run.class.path" failonerror="true">
<sysproperty key="zimbra.version" value="${zimbra.buildinfo.all}"/>
<arg line="-a generateDefaultExternalCOSLdif -i ${build.dir}/attrs -o ${build.dir}/ldap-config/zimbra_defaultexternalcos.ldif"/>
</java>
<copy todir="${build.dir}/ldap-config" file="${config.dir}/ldap/zimbra.ldif"/>
<copy todir="${build.dir}/ldap-config" file="${config.dir}/ldap/zimbra_mimehandlers.ldif"/>
<copy todir="${build.dir}/ldap-config/schema" file="${config.dir}/ldap/amavisd.schema"/>
<copy todir="${build.dir}/ldap-config/schema" file="${config.dir}/ldap/amavisd.ldif"/>
<copy todir="${build.dir}/ldap-config/schema" file="${config.dir}/ldap/opendkim.ldif"/>
<copy todir="${build.dir}/ldap-config/config" file="${slapd.config.src}"/>
<copy todir="${build.dir}/ldap-config/config/cn=config" file="${slapd.config.dir}/cn=config/cn=module{0}.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config" file="${slapd.config.dir}/cn=config/cn=schema.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config" file="${slapd.config.dir}/cn=config/olcDatabase={0}config.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config" file="${slapd.config.dir}/cn=config/olcDatabase={-1}frontend.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config" file="${slapd.config.dir}/cn=config/olcDatabase={1}monitor.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config/" file="${slapd.config.dir}/cn=config/olcDatabase={2}mdb.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config/olcDatabase={2}mdb" file="${slapd.config.dir}/cn=config/olcDatabase={2}mdb/olcOverlay={0}dynlist.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config/olcDatabase={2}mdb" file="${slapd.config.dir}/cn=config/olcDatabase={2}mdb/olcOverlay={1}unique.ldif"/>
<copy todir="${build.dir}/ldap-config/config/cn=config/olcDatabase={2}mdb" file="${slapd.config.dir}/cn=config/olcDatabase={2}mdb/olcOverlay={2}noopsrch.ldif"/>
<!--schema -->
</target>
<target name="update-ldap-schema" depends="generate-ldap-config">
<antcall target="stop-zimbra"/>
<copy todir="${zimbra.home.dir}/conf/attrs" overwrite="true">
<fileset dir="${build.dir}/attrs"/>
</copy>
<!-- copy generated ldif files
<copy todir="${zimbra.home.dir}/${slapd.etc.dir}/zimbra/" file="${build.dir}/ldap-config/zimbra_globalconfig.ldif" overwrite="true"/>
<copy todir="${zimbra.home.dir}/${slapd.etc.dir}/zimbra/" file="${build.dir}/ldap-config/zimbra_defaultcos.ldif" overwrite="true"/>
<copy todir="${zimbra.home.dir}/${slapd.etc.dir}/zimbra/" file="${build.dir}/ldap-config/zimbra_defaultexternalcos.ldif" overwrite="true"/>
<copy todir="${zimbra.home.dir}/${slapd.etc.dir}/zimbra/schema/" file="${build.dir}/ldap-config/zimbra.schema" overwrite="true"/>
<copy todir="${zimbra.home.dir}/${slapd.etc.dir}/zimbra/schema/" file="${build.dir}/ldap-config/schema/zimbra.ldif" overwrite="true"/> -->
<!-- apply ldap schema changes -->
<exec executable="/opt/zimbra/libexec/zmldapschema"/>
<antcall target="start-zimbra"/>
</target>
<target name="build-dist" depends="generate-ldap-config">
<copy todir="${build-dist}" overwrite="true">
<fileset dir="${build.dir}/ldap-config"/>
</copy>
</target>
<target name="init-unittest" description="Setup the SOAP test files in /opt/zimbra">
<copy todir="${zimbra.home.dir}/unittest" overwrite="true">
<fileset dir="data/unittest" includes="**"/>
</copy>
</target>
</project>