File: build.xml

package info (click to toggle)
icinga-web 1.7.1%2Bdfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 83,496 kB
  • sloc: php: 252,926; xml: 142,251; sql: 8,190; sh: 1,039; makefile: 575; perl: 215; python: 194
file content (349 lines) | stat: -rw-r--r-- 11,909 bytes parent folder | download | duplicates (3)
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="ModuleInstaller" default="usage">
	<target name="usage">
		<echo>
*************************  Icinga Module Toolkit   ************************ 
Available targets: 
	- install-module:	Installs the current module
	- deploy-module: 	Deploys a module for distribution
	- remove-module:	Removes a module from this system
	- rollback:		Restores files that we're altered by install-module
	
	- export-cronk:		Exports a cronk for distribution
	- import-cronk:		Imports a cronk
***************************************************************************
		</echo>
	</target>
	<target name="install-module">
		<!-- define tasks -->
		
		<taskdef name="actionQueue" classname="bin.actionQueueTask" />
		<typedef name="icingaManifest" classname="bin.icingaManifest" />
		<taskdef name="moduleMetaPrinter" classname="bin.moduleMetaPrinterTask"/>	
		<taskdef name="dependencyChecker" classname="bin.dependencyCheckerTask" />
		<taskdef name="manifestDependencyChecker" classname="bin.dependencyCheckerTask"/>
		<taskdef name="xmlMergerChain" classname="bin.xmlMergerChainTask" />
		
		<actionQueue path="./"/>
		<!--  load defaults -->
		<property file="build.properties" />

		<echo msg="Module installation wizard for Icinga-web" />
		<icingaManifest id="manifest" file="manifest.xml" />
		<moduleMetaPrinter refid="manifest" />
		<!--  Confirmations -->
		<input propertyname="confirm" promptChar="?" defaultValue="y" validArgs="y,n">Do you want to install this module?</input>
		<if>
			<equals arg1="${confirm}" arg2="n" />
			<then>
				<fail message="Installation aborted by user." />
 			</then>
		</if>
		<input propertyname="PATH_Icinga" promptChar="?" defaultValue="${icinga.path}">Location of icinga-web</input>

		<!--  Check dependencies -->		
		<echo msg="Checking dependencies..." />
		<manifestDependencyChecker refid="manifest"/>
		
		<!-- Install module and additional -->		
		<echo>Installing to ${PATH_Icinga}</echo>
		<copy todir="${PATH_Icinga}">
			<filterchain>
				<filterreader classname="bin.saveCopyFilter"/>
			</filterchain>
			<fileset dir="src">
				<exclude name="snippets.dat"></exclude>
				<exclude name="routes.xml"></exclude>
				<include name="**" />
			</fileset>
		</copy>	
		
		<!-- install meta info for xml-removal -->
		<copy todir="${PATH_Icinga}/app/modules/${MODULE_Name}/.meta/xml">
			<fileset dir="etc/xml">
				<include name="*.xml"/>
			</fileset>
		</copy>
		<echo>Configuring XML files</echo>
		<xmlMergerChain  folder="etc/xml/"/>
		
		<!--  Doctrine models -->
		<echo>Copying Doctrine-Models</echo>
		<copy todir="${PATH_Icinga}/${PATH_AppKit}/database/models/">
			<fileset dir="etc/doctrine">
				<include name="**" />
			</fileset>
		</copy>
		
		<echo>Inserting snippets</echo>
		<!-- Inject snippets -->
		<taskdef name="snippetInjector" classname="bin.snippetInjectorTask" />
		<snippetInjector file="src/snippets.dat" />
		
		<!-- Set up Doctrine -->
		<taskdef name="doctrineDBBuilder" classname="bin.doctrineDBBuilderTask" />
		<input propertyname="confirm" promptChar="?" defaultValue="y" validargs="y,n">Create tables</input>
		<if>
			<equals arg1="${confirm}" arg2="y" />
			<then>
				<doctrineDBBuilder models="etc/doctrine" action="create" ini="db.ini"/>
 			</then>
		</if>
		
		<!--  Run SQL -->
		<taskdef name="sqlRunner" classname="bin.sqlRunnerTask" />
		<input propertyname="confirm" promptChar="?" defaultValue="y" validargs="y,n">Process sql queries?</input>
		<if>
			<equals arg1="${confirm}" arg2="y" />
			<then>
				<sqlRunner files="etc/sql" ini="db.ini"/>
 			</then>
		</if>		
		
		<property name="buildAdditional" value="false" />
		<available file="additional.xml" property="buildAdditional" value="true" />
		<if>
			<equals arg1="${buildAdditional}" arg2="1" />
			<then>
				<phing phingfile="additional.xml" inheritAll="true" />
			</then>
		</if>
		
		<echo>Clearing cache</echo>
		<delete dir="${PATH_Icinga}/app/cache/config" />	
		
		<property name="buildAdditional" value="false" />
		<available file="additional.xml" property="buildAdditional" value="true" />
		<if>
			<equals arg1="${buildAdditional}" arg2="1" />
			<then>
				<phing phingfile="additional.xml" inheritAll="true" />
			</then>
		</if>
	
	</target>

	
	<!-- 
		Target for deploying modules
	 -->
	<target name="deploy-module">
		<!-- define tasks -->
		<typedef name="icingaManifest" classname="bin.icingaManifest" />
		<taskdef name="fileSelector" classname="bin.fileSelectorTask"/>	
		<taskdef name="snippetExtractor" classname="bin.snippetExtractorTask" />
		<taskdef name="xmlExtractor" classname="bin.xmlExtractorTask" />
		<!--  load defaults -->
		<property file="build.properties" />
		
		<!--  fetch manifest -->	
		<input propertyname="coreDir" >Module directory (containing manifest.xml) : </input>
		<echo msg="Searching for manifest file at : ${coreDir}" />
		<icingaManifest id="manifest" file="${coreDir}/manifest.xml" />
		
		<!-- fetch files -->
		<fileSelector refid="manifest" source="Module" propertyName="module"/>
	 	<fileSelector refid="manifest" source="Doctrine" propertyName="models"/>
		<fileSelector refid="manifest" source="SQL" propertyName="sqlRoutines"/>

		<!-- Copy agavi module and config to src -->
		<phingcall target="structure-create" />
		
		<echo>Saving module Data...</echo>		
		<copy todir="${MODULE_Name}/src">
			<fileset refid="module" />
			<mapper classname="bin.manifestMapper" from="manifest"/>
		</copy>
		
		<echo>Saving doctrine Models...</echo>	
		<copy todir="${MODULE_Name}/etc/doctrine">
			<fileset refid="models" />
			<mapper classname="bin.manifestMapper" from="manifest"/>
		</copy>
		
		<echo>Saving SQL-routines...</echo>	
		<copy todir="${MODULE_Name}/etc/sql">
			<fileset refid="sqlRoutines" />
			<mapper classname="bin.manifestMapper" from="manifest"/>
		</copy>
		
		<echo>Extracting snippets...</echo>
		<snippetExtractor refid="manifest" toFile="${MODULE_Name}/src/snippets.dat" />
		
		<!--  Extract XML entries -->
		<xmlExtractor refid="manifest" path="${MODULE_Name}/etc/xml" />
		
		<!-- Creating Manifest -->
		<copy file="${coreDir}/manifest.xml" tofile="${MODULE_Name}/manifest.xml"/>
		
		<!-- Deploying installer -->
		<copy file="build.xml" tofile="${MODULE_Name}/build.xml"/>
		<copy todir="${MODULE_Name}/bin">
			<fileset dir="./bin">
				<include name="**" />
			</fileset>
		</copy>
		<copy file="etc/db.ini" todir="${MODULE_Name}/" />
		<copy file="build.properties" todir="${MODULE_Name}/" />
		<!-- Packing -->
		<copy todir="${MODULE_Name}" >
			<fileset dir="./scripts">
				<include name="*.sh"/>
			</fileset>
		</copy>
		<tar basedir="${MODULE_Name}/." destfile="${MODULE_Name}_module.tar" compression="gzip" />
		
	</target>
	
	<!-- 
		Module deletion wizard 
	
	-->
	<target name="remove-module">
		<typedef name="icingaManifest" classname="bin.icingaManifest" />
		<taskdef name="xmlRemover" classname="bin.xmlRemoverTask" />
		<taskdef name="fileSelector" classname="bin.fileSelectorTask"/>
		<taskdef name="moduleMetaPrinter" classname="bin.moduleMetaPrinterTask"/>		
		<property file="build.properties" />
		
		<echo>Module Deletion Wizard</echo>
		<input propertyname="PATH_Icinga" promptChar="?" defaultValue="${icinga.path}">Location of icinga-web</input>
		<input propertyname="MODULE_Name" promptChar="?">Module name</input>

		<!--
				Check if module exists and let the user confirm the removal
		 -->
		<property name="module_exists" value="false"></property>
		<available file="${PATH_Icinga}/app/modules/${MODULE_Name}/manifest.xml" property="module_exists" value="true"/>
		<if>
			<equals arg1="${module_exists}" arg2="1"/>
			<then>
				<icingaManifest id="manifest" file="${PATH_Icinga}/app/modules/${MODULE_Name}/manifest.xml" />
				<moduleMetaPrinter refid="manifest" />
				<!--  Confirmations -->
				<input propertyname="confirm" promptChar="?" defaultValue="y" validArgs="y,n">Do you want to deinstall this module?</input>
				<if>
					<equals arg1="${confirm}" arg2="n" />
					<then>
						<fail message="Deinstallation aborted by user." />
		 			</then>
				</if>
			</then>
			<else>
				<fail message="${module_exists} Module does not exist. No Manifest found at ${PATH_Icinga}/app/modules/${MODULE_Name}/manifest.xml" />
			</else>
		</if>

		<!-- 
			remove XML entries
		 -->
		<xmlRemover refid="manifest" path="${PATH_Icinga}/app/modules/${MODULE_Name}/.meta/xml"></xmlRemover>

		<!-- 
			Remove Database entries			
		 -->
		<taskdef name="doctrineDBBuilder" classname="bin.doctrineDBBuilderTask" />
		<input propertyname="confirm" promptChar="?" defaultValue="y" validargs="y,n">Remove tables</input>
		<if>
			<equals arg1="${confirm}" arg2="y" />
			<then>
				<echo>Removing tables</echo>
				<doctrineDBBuilder models="${PATH_Icinga}/app/modules/${MODULE_Name}/lib/.models.cfg" action="delete" ini="db.ini"/>
 			</then>
		</if>
		
		<!-- 
			Finally remove files
		 -->
		<echo>Removing files</echo>
		<delete dir="${PATH_Icinga}/app/modules/${MODULE_Name}" />
	
		<fileSelector refid="manifest" source="Module" propertyName="module"/>
		<delete>
			<fileset refid="module"/>
		</delete>		
		
		<echo>Clearing cache</echo>
		<delete dir="${PATH_Icinga}/app/cache/config" />
	</target>

	<target name="export-cronk">
		<taskdef name="settingsExtractor" classname="bin.settingsExtractorTask"/>
		<taskdef name="cronkMetaExtractor" classname="bin.cronkMetaExtractorTask"/>

		<echo>Cronk-export wizard</echo>
		<input propertyname="cronkName" promptChar="?">Name of the cronk</input>
		
		<phingcall target="cronk-structure-create" />
		
		<settingsExtractor file="app/modules/Cronks/config/cronks.xml" useAbsolute="true" setting="" parameter="${cronkName}" toFile="${cronkName}/src/cronks"></settingsExtractor>
		<cronkMetaExtractor file="${cronkName}/src/cronks.xml"></cronkMetaExtractor>		
		
		<echo>Saving Action</echo>	
		<copy todir="${cronkName}/src/">
			<fileset refid="cronkAction" />
		</copy>
		
		<echo>Saving templates</echo>	
		<copy todir="${cronkName}/xml/">
			<fileset refid="cronkTemplates" />
		</copy>
		
		<copy file="build.xml" tofile="${cronkName}/build.xml">
			<filterchain>
				<replacetokens begintoken="##" endtoken="##">
					<token key="CRONKNAME" value="${cronkName}" />		
				</replacetokens>
			</filterchain>
		</copy>
		<copy todir="${cronkName}/bin">
			<fileset dir="./bin">
				<include name="cronkMetaExtractorTask.php" />
				<include name="settingsInjectorTask.php" />
			</fileset>
		</copy>
	</target>
	
	<target name="import-cronk">
		<taskdef name="settingsInjector" classname="bin.settingsInjectorTask"/>
		<taskdef name="cronkMetaExtractor" classname="bin.cronkMetaExtractorTask"/>

		<echo>Cronk-import wizard</echo>
		<input propertyname="PATH_Icinga" promptChar="?" defaultValue="/usr/local/icinga-web">Location of icinga-web</input>
		
		<settingsInjector source="src/cronks.xml" cfg="${PATH_Icinga}/app/modules/Cronks/config/cronks.xml" settingsToImport="/##CRONKNAME##"/>		
		<copy todir="${PATH_Icinga}/app/modules/Cronks/">
			<fileset dir="./src">
				<include name="**"/>
				<exclude name="cronks.xml" />
			</fileset>
		</copy>
		<copy todir="${PATH_Icinga}/app/data/xml/">
			<fileset dir="./xml">
				<include name="*.xml"></include>
			</fileset>
		</copy>
	</target>
	
	
	<target name="cronk-structure-create" >
		<mkdir dir="${cronkName}"/>
		<mkdir dir="${cronkName}/src"/>	
		<mkdir dir="${cronkName}/xml"/>	
	</target>
	
	<target name="structure-create">
		<mkdir dir="${MODULE_Name}"/>
		<mkdir dir="${MODULE_Name}/src"/>
		<mkdir dir="${MODULE_Name}/doc"/>
		<mkdir dir="${MODULE_Name}/etc/"/>
		<mkdir dir="${MODULE_Name}/etc/doctrine"/>
		<mkdir dir="${MODULE_Name}/etc/sql"/>
		<mkdir dir="${MODULE_Name}/etc/xml"/>
	</target>
		
	<target name="rollback">
		<taskdef name="actionQueue" classname="bin.actionQueueTask" />
		<actionQueue path="./" restore="true"/>
	</target>
</project>