1 | <?xml version="1.0"?>
|
---|
2 |
|
---|
3 | <!-- ======================================================================
|
---|
4 | July 2006
|
---|
5 |
|
---|
6 | Greenstone3 building build and install script
|
---|
7 |
|
---|
8 | So far I have just moved the gs3build related targets out of main
|
---|
9 | greenstone 3 build.xml and put them in here. It needs tidying up to
|
---|
10 | make it useful.
|
---|
11 | kjdon
|
---|
12 | ====================================================================== -->
|
---|
13 | <project name="gs3build" default="usage" basedir=".">
|
---|
14 |
|
---|
15 | <!-- ============= Base dirs for each package and component ============ -->
|
---|
16 | <property name="mysql.home" value="${packages.home}/mysql"/>
|
---|
17 |
|
---|
18 | <!-- can be set in build.properties if need be -->
|
---|
19 | <property name="mysql.datadir" value="./data"/>
|
---|
20 |
|
---|
21 | <!-- ==================== Compilation Control Options ==================== -->
|
---|
22 |
|
---|
23 | <!--
|
---|
24 |
|
---|
25 | These properties control option settings on the Javac compiler when it
|
---|
26 | is invoked using the <javac> task.
|
---|
27 |
|
---|
28 | compile.debug Should compilation include the debug option?
|
---|
29 |
|
---|
30 | compile.deprecation Should compilation include the deprecation option?
|
---|
31 |
|
---|
32 | compile.optimize Should compilation include the optimize option?
|
---|
33 |
|
---|
34 | -->
|
---|
35 |
|
---|
36 | <property name="compile.debug" value="true"/>
|
---|
37 | <property name="compile.deprecation" value="true"/>
|
---|
38 | <property name="compile.optimize" value="true"/>
|
---|
39 |
|
---|
40 |
|
---|
41 | <target name="prepare" depends="prepare-mysql"/>
|
---|
42 |
|
---|
43 | <!-- this sets up some initial properties -->
|
---|
44 | <target name="init">
|
---|
45 | <condition property="java.too.old">
|
---|
46 | <or>
|
---|
47 | <equals arg1="1.1" arg2="${ant.java.version}"/>
|
---|
48 | <equals arg1="1.2" arg2="${ant.java.version}"/>
|
---|
49 | <equals arg1="1.3" arg2="${ant.java.version}"/>
|
---|
50 | </or>
|
---|
51 | </condition>
|
---|
52 | <fail if="java.too.old" message="You need Java 1.4 or greater to run Greenstone 3"/>
|
---|
53 | <available file="${packages.home}/mysql/bin" property="mysql.present"/>
|
---|
54 | <condition property="mysql.islocal">
|
---|
55 | <or>
|
---|
56 | <not>
|
---|
57 | <isset property="mysql.installed.path"/>
|
---|
58 | </not>
|
---|
59 | <equals arg1="" arg2="${mysql.installed.path}"/>
|
---|
60 | </or>
|
---|
61 | </condition>
|
---|
62 | </target>
|
---|
63 |
|
---|
64 | <target name="prepare-collections" depends="init">
|
---|
65 | <property name="collect.dir" value="${web.home}/sites/localsite/collect"/>
|
---|
66 | <!-- gs3mgdemo -->
|
---|
67 | <unzip src="${collect.dir}/gs3mgdemo/import.zip"
|
---|
68 | dest="${collect.dir}/gs3mgdemo"/>
|
---|
69 | <unzip src="${collect.dir}/gs3mgdemo/archives.zip"
|
---|
70 | dest="${collect.dir}/gs3mgdemo"/>
|
---|
71 | <unzip src="${collect.dir}/gs3mgdemo/index/index.zip"
|
---|
72 | dest="${collect.dir}/gs3mgdemo/index"/>
|
---|
73 | <delete file="${collect.dir}/gs3mgdemo/import.zip"/>
|
---|
74 | <delete file="${collect.dir}/gs3mgdemo/archives.zip"/>
|
---|
75 | <delete file="${collect.dir}/gs3mgdemo/index/index.zip"/>
|
---|
76 | </target>
|
---|
77 |
|
---|
78 | <target name="configure-web" depends="init,get-mysql-reader-password,get-mysql-admin-password"
|
---|
79 |
|
---|
80 | <!-- just in case these haven't been defined, we need something to write to
|
---|
81 | the file -->
|
---|
82 | <property name="mysql.admin.password" value=" "/>
|
---|
83 | <property name="mysql.reader.password" value=" "/>
|
---|
84 | <filter token="mysql.port" value="${mysql.port}"/>
|
---|
85 | <filter token="mysql.server" value="${mysql.server}"/>
|
---|
86 | <filter token="mysql.admin.pword" value="${mysql.admin.password}"/>
|
---|
87 | <filter token="mysql.reader.pword" value="${mysql.reader.password}"/>
|
---|
88 | </target>
|
---|
89 |
|
---|
90 | <!-- ======================= Mysql Targets =========================== -->
|
---|
91 |
|
---|
92 | <!-- this is one target that we only want to run once. -->
|
---|
93 | <target name="prepare-mysql" depends="init,init-mysql-vars,install-mysql,start-mysql,setup-mysql,stop-mysql-no-password-force"/>
|
---|
94 |
|
---|
95 | <target name="init-mysql-vars">
|
---|
96 | <condition property="mysql.islocal.linux">
|
---|
97 | <and>
|
---|
98 | <isset property="mysql.islocal"/>
|
---|
99 | <isset property="current.os.isunixnotmac"/>
|
---|
100 | </and>
|
---|
101 | </condition>
|
---|
102 | <condition property="mysql.islocal.mac">
|
---|
103 | <and>
|
---|
104 | <isset property="mysql.islocal"/>
|
---|
105 | <isset property="current.os.ismac"/>
|
---|
106 | </and>
|
---|
107 | </condition>
|
---|
108 | <condition property="mysql.islocal.windows">
|
---|
109 | <and>
|
---|
110 | <isset property="mysql.islocal"/>
|
---|
111 | <isset property="current.os.iswindows"/>
|
---|
112 | </and>
|
---|
113 | </condition>
|
---|
114 | <condition property="mysql.islocal.usepassword">
|
---|
115 | <and>
|
---|
116 | <isset property="mysql.islocal"/>
|
---|
117 | <isset property="mysql.use.passwords"/>
|
---|
118 | <equals arg1="yes" arg2="${mysql.use.passwords}"/>
|
---|
119 | </and>
|
---|
120 | </condition>
|
---|
121 | <condition property="mysql.islocal.usepassword.windows">
|
---|
122 | <and>
|
---|
123 | <isset property="mysql.islocal.usepassword"/>
|
---|
124 | <isset property="current.os.iswindows"/>
|
---|
125 | </and>
|
---|
126 | </condition>
|
---|
127 | <condition property="mysql.islocal.usepassword.unix">
|
---|
128 | <and>
|
---|
129 | <isset property="mysql.islocal.usepassword"/>
|
---|
130 | <isset property="current.os.isunix"/>
|
---|
131 | </and>
|
---|
132 | </condition>
|
---|
133 | <condition property="mysql.islocal.nopassword">
|
---|
134 | <and>
|
---|
135 | <isset property="mysql.islocal"/>
|
---|
136 | <or>
|
---|
137 | <not>
|
---|
138 | <isset property="mysql.use.passwords"/>
|
---|
139 | </not>
|
---|
140 | <equals arg1="no" arg2="${mysql.use.passwords}"/>
|
---|
141 | </or>
|
---|
142 | </and>
|
---|
143 | </condition>
|
---|
144 | </target>
|
---|
145 |
|
---|
146 | <target name="configure-mysql" depends="init,init-mysql-vars,start-mysql,set-mysql-account-passwords,stop-mysql" description="sets up the mysql account passwords"/>
|
---|
147 |
|
---|
148 | <target name="get-mysql-root-password" depends="init,init-mysql-vars" if="mysql.islocal.usepassword" unless="mysql.root.password">
|
---|
149 | <echo>Enter password in the Java popup. (If you do not have a window server running, please set the mysql.root.password in the build.properties file.)</echo>
|
---|
150 | <getuserandpassword message="Please specify a password for the root mysql user: this is to secure your database." username="root" pwordproperty="mysql.root.password"/>
|
---|
151 | </target>
|
---|
152 |
|
---|
153 | <target name="get-mysql-root-password-windows" depends="init,init-mysql-vars" if="mysql.islocal.usepassword.windows" unless="mysql.root.password">
|
---|
154 | <echo>(Enter password in the Java popup)</echo>
|
---|
155 | <getuserandpassword message="Please enter the mysql root password" username="root" pwordproperty="mysql.root.password"/>
|
---|
156 | </target>
|
---|
157 |
|
---|
158 | <target name="get-mysql-reader-password" depends="init,init-mysql-vars" if="mysql.islocal.usepassword" unless="mysql.reader.password" >
|
---|
159 | <echo>Enter password in the Java popup. (If you do not have a window server running, please set the mysql.reader.password in the build.properties file.)</echo>
|
---|
160 | <getuserandpassword message="Please specify the password for the gsdl3reader mysql user: this is used by greenstone" username="gsdl3reader" pwordproperty="mysql.reader.password"/>
|
---|
161 | </target>
|
---|
162 |
|
---|
163 | <target name="get-mysql-admin-password" depends="init,init-mysql-vars" if="mysql.islocal.usepassword" unless="mysql.admin.password" >
|
---|
164 | <echo>Enter password in the Java popup. (If you do not have a window server running, please set the mysql.admin.password in the build.properties file.)</echo>
|
---|
165 | <getuserandpassword message="Please specify the password for the gsdl3admin mysql user: this is used by greenstone" username="gsdl3admin" pwordproperty="mysql.admin.password"/>
|
---|
166 | </target>
|
---|
167 |
|
---|
168 | <target name="install-mysql" depends="init,init-mysql-vars,install-mysql-linux,install-mysql-windows,install-mysql-mac"/>
|
---|
169 |
|
---|
170 | <!-- install the database : linux-->
|
---|
171 | <target name="install-mysql-linux" depends="init,init-mysql-vars" if="mysql.islocal.linux" unless="mysql.present">
|
---|
172 | <get src="http://www.greenstone.org/gs3files/mysql-standard-4.1.15-pc-linux-gnu-i686.tar.gz"
|
---|
173 | dest="${packages.home}/mysql-standard-4.1.15-pc-linux-gnu-i686.tar.gz"
|
---|
174 | usetimestamp="true"/>
|
---|
175 | <untar src="${packages.home}/mysql-standard-4.1.15-pc-linux-gnu-i686.tar.gz"
|
---|
176 | dest="${packages.home}"
|
---|
177 | compression="gzip"/>
|
---|
178 | <move todir="${packages.home}/mysql">
|
---|
179 | <fileset dir="${packages.home}/mysql-standard-4.1.15-pc-linux-gnu-i686"/>
|
---|
180 | </move>
|
---|
181 | <!-- file permissions are screwed up, so make executables executable -->
|
---|
182 | <chmod file="${mysql.home}/scripts/mysql_install_db" perm="a+x"/>
|
---|
183 | <chmod perm="a+x">
|
---|
184 | <fileset dir="${mysql.home}/bin" />
|
---|
185 | </chmod>
|
---|
186 | <mkdir dir="${mysql.home}/var/log/"/>
|
---|
187 | <chmod file="${mysql.home}/var/" perm="777" type="dir"/>
|
---|
188 | <chmod file="${mysql.home}/var/log/" perm="777" type="dir"/>
|
---|
189 |
|
---|
190 | <exec executable="${mysql.home}/scripts/mysql_install_db" dir="${mysql.home}">
|
---|
191 | <arg value="--datadir=${mysql.datadir}"/>
|
---|
192 | <arg value="--basedir=."/>
|
---|
193 | <arg value="--user=root"/>
|
---|
194 | <arg value="--force"/>
|
---|
195 | </exec>
|
---|
196 | </target>
|
---|
197 |
|
---|
198 | <!-- install the database : mac-->
|
---|
199 | <target name="install-mysql-mac" depends="init,init-mysql-vars" if="mysql.islocal.mac" unless="mysql.present">
|
---|
200 | <get src="http://www.greenstone.org/gs3files/mysql-standard-4.1.15-apple-darwin7.9.0-powerpc.tar.gz"
|
---|
201 | dest="${packages.home}/mysql-standard-4.1.15-apple-darwin7.9.0-powerpc.tar.gz"
|
---|
202 | usetimestamp="true"/>
|
---|
203 | <untar src="${packages.home}/mysql-standard-4.1.15-apple-darwin7.9.0-powerpc.tar.gz"
|
---|
204 | dest="${packages.home}"
|
---|
205 | compression="gzip"/>
|
---|
206 | <move todir="${packages.home}/mysql">
|
---|
207 | <fileset dir="${packages.home}/mysql-standard-4.1.15-apple-darwin7.9.0-powerpc"/>
|
---|
208 | </move>
|
---|
209 | <!-- file permissions are screwed up, so make executables executable -->
|
---|
210 | <chmod file="${mysql.home}/scripts/mysql_install_db" perm="a+x"/>
|
---|
211 | <chmod perm="a+x">
|
---|
212 | <fileset dir="${mysql.home}/bin" />
|
---|
213 | </chmod>
|
---|
214 | <mkdir dir="${mysql.home}/var/log/"/>
|
---|
215 | <chmod file="${mysql.home}/var/" perm="777" type="dir"/>
|
---|
216 | <chmod file="${mysql.home}/var/log/" perm="777" type="dir"/>
|
---|
217 | <exec executable="${mysql.home}/scripts/mysql_install_db" dir="${mysql.home}">
|
---|
218 | <arg value="--datadir=${mysql.datadir}"/>
|
---|
219 | <arg value="--basedir=."/>
|
---|
220 | <!--<arg value="- -user=root"/>
|
---|
221 | <arg value="- -force"/>-->
|
---|
222 | </exec>
|
---|
223 | </target>
|
---|
224 |
|
---|
225 | <!-- install the database : windows -->
|
---|
226 | <target name="install-mysql-windows" depends="init,init-mysql-vars" if="mysql.islocal.windows" unless="mysql.present">
|
---|
227 | <get src="http://www.greenstone.org/gs3files/mysql-noinstall-4.1.15-win32.zip"
|
---|
228 | dest="${packages.home}/mysql-noinstall-4.1.15-win32.zip"
|
---|
229 | usetimestamp="true"/>
|
---|
230 | <!-- can we run the installer?? -->
|
---|
231 | <unzip src="${packages.home}/mysql-noinstall-4.1.15-win32.zip"
|
---|
232 | dest="${packages.home}"/>
|
---|
233 | <move todir="${packages.home}/mysql">
|
---|
234 | <fileset dir="${packages.home}/mysql-4.1.15-win32"/>
|
---|
235 | </move>
|
---|
236 | </target>
|
---|
237 |
|
---|
238 | <target name="setup-mysql" depends="init" if="mysql.islocal">
|
---|
239 | <!-- setup the gsdl3 accounts -->
|
---|
240 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
241 | <arg value="--user=root"/>
|
---|
242 | <arg value="--execute=GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@localhost"/>
|
---|
243 | </exec>
|
---|
244 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
245 | <arg value="--user=root"/>
|
---|
246 | <arg value="--execute=GRANT SELECT ON *.* TO gsdl3reader@localhost"/>
|
---|
247 | </exec>
|
---|
248 | <!--<exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
249 | <arg value="- -user=root"/>
|
---|
250 | <arg value="- -execute=GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@'%';"/>
|
---|
251 | </exec>-->
|
---|
252 |
|
---|
253 | <!-- remove the anonymous user -->
|
---|
254 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
255 | <arg value="--user=root"/>
|
---|
256 | <arg value="--execute=delete from mysql.user where Host='localhost' and User='';"/>
|
---|
257 | </exec>
|
---|
258 | <!-- load in the demo collection database -->
|
---|
259 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
260 | <arg value="--user=root"/>
|
---|
261 | <arg value="--execute=create database localsite_gs3mgdemo;"/>
|
---|
262 | </exec>
|
---|
263 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}"
|
---|
264 | input="${web.home}/sites/localsite/collect/gs3mgdemo/mysqldatadump.sql">
|
---|
265 | <arg value="--user=root"/>
|
---|
266 | <arg value="localsite_gs3mgdemo"/>
|
---|
267 | </exec>
|
---|
268 | </target>
|
---|
269 |
|
---|
270 | <target name="set-mysql-account-passwords" depends="init,init-mysql-vars,get-mysql-root-password,get-mysql-reader-password,get-mysql-admin-password" if="mysql.islocal.usepassword">
|
---|
271 | <exec executable="${mysql.home}/bin/mysql" dir="${mysql.home}">
|
---|
272 | <arg value="--user=root"/>
|
---|
273 | <arg value="--execute=set password for 'root'@'localhost' = PASSWORD('${mysql.root.password}'); set password for 'gsdl3reader'@'localhost' = PASSWORD('${mysql.reader.password}'); set password for 'gsdl3admin'@'localhost' = PASSWORD('${mysql.admin.password}'); flush privileges;"/>
|
---|
274 | </exec>
|
---|
275 | </target>
|
---|
276 |
|
---|
277 | <target name="start-mysql" depends="init,init-mysql-vars" if="mysql.islocal"
|
---|
278 | description="Startup only mysql">
|
---|
279 | <echo>Starting up the mysql server</echo>
|
---|
280 | <exec executable="${mysql.home}/bin/mysqld_safe" dir="${mysql.home}"
|
---|
281 | spawn="true" os="${os.linux},${os.mac}">
|
---|
282 | <arg value="--datadir=${mysql.datadir}"/>
|
---|
283 | <arg value="--basedir=."/>
|
---|
284 | <arg value="--pid_file=gsdl3.pid"/>
|
---|
285 | <arg value="--socket=/tmp/mysql.sock"/>
|
---|
286 | <arg value="--port=${mysql.port}"/>
|
---|
287 | <arg value="--err-log=./var/log/mysql.log"/>
|
---|
288 | </exec>
|
---|
289 | <exec executable="${mysql.home}/bin/mysqld" dir="${mysql.home}" spawn="true" os="${os.windows}">
|
---|
290 | <arg value="--port=${mysql.port}"/>
|
---|
291 | </exec>
|
---|
292 | <sleep seconds="2"/>
|
---|
293 | </target>
|
---|
294 |
|
---|
295 | <target name="stop-mysql" depends="init,init-mysql-vars,stop-mysql-use-password-unix,stop-mysql-use-password-windows,stop-mysql-no-password" if="mysql.islocal"
|
---|
296 | description="Shutdown only mysql">
|
---|
297 | <echo>MYSQL database server shutdown successfully</echo>
|
---|
298 | </target>
|
---|
299 |
|
---|
300 | <target name="stop-mysql-no-password" depends="init" if="mysql.islocal.nopassword">
|
---|
301 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
302 | failonerror="true" os="${os.linux},${os.mac}">
|
---|
303 | <arg value="--user=root"/>
|
---|
304 | <arg value="--socket=/tmp/mysql.sock"/>
|
---|
305 | <arg value="shutdown"/>
|
---|
306 | </exec>
|
---|
307 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
308 | failonerror="true" os="${os.windows}">
|
---|
309 | <arg value="--user=root"/>
|
---|
310 | <arg value="shutdown"/>
|
---|
311 | </exec>
|
---|
312 | </target>
|
---|
313 |
|
---|
314 | <target name="stop-mysql-no-password-force" depends="init" if="mysql.islocal">
|
---|
315 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
316 | failonerror="true" os="${os.linux},${os.mac}">
|
---|
317 | <arg value="--user=root"/>
|
---|
318 | <arg value="--socket=/tmp/mysql.sock"/>
|
---|
319 | <arg value="shutdown"/>
|
---|
320 | </exec>
|
---|
321 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
322 | failonerror="true" os="${os.windows}">
|
---|
323 | <arg value="--user=root"/>
|
---|
324 | <arg value="shutdown"/>
|
---|
325 | </exec>
|
---|
326 | </target>
|
---|
327 |
|
---|
328 | <target name="stop-mysql-use-password-unix" depends="init" if="mysql.islocal.usepassword.unix">
|
---|
329 | <echo>At the password prompt, enter the mysql root password.</echo>
|
---|
330 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
331 | failonerror="true" os="${os.linux},${os.mac}">
|
---|
332 | <arg value="--user=root"/>
|
---|
333 | <arg value="-p"/>
|
---|
334 | <arg value="--socket=/tmp/mysql.sock"/>
|
---|
335 | <arg value="shutdown"/>
|
---|
336 | </exec>
|
---|
337 | </target>
|
---|
338 |
|
---|
339 | <target name="stop-mysql-use-password-windows" depends="init,get-mysql-root-password-windows" if="mysql.islocal.usepassword.windows">
|
---|
340 | <!-- on windows it doesn't work unless the password is specified here -->
|
---|
341 | <exec executable="${mysql.home}/bin/mysqladmin" dir="${mysql.home}"
|
---|
342 | failonerror="true" os="${os.windows}">
|
---|
343 | <arg value="--user=root"/>
|
---|
344 | <arg value="-p${mysql.root.password}"/>
|
---|
345 | <arg value="shutdown"/>
|
---|
346 | </exec>
|
---|
347 | </target>
|
---|
348 |
|
---|
349 | <target name="restart-mysql" description="Shutdown and restart only mysql" depends="init,stop-mysql,start-mysql"/>
|
---|
350 |
|
---|
351 | <target name="prepare-for-dist-2" depends="init">
|
---|
352 | <antcall target="prepare-mysql"/>
|
---|
353 | <delete file="${packages.home}/mysql-standard-4.1.15-pc-linux-gnu-i686.tar.gz"/>
|
---|
354 | <delete file="${packages.home}/mysql-standard-4.1.15-apple-darwin7.9.0-powerpc.tar.gz"/>
|
---|
355 | <delete file="${packages.home}/mysql-noinstall-4.1.15-win32.zip"/>
|
---|
356 | <delete dir="${packages.home}/mysql/sql-bench"/>
|
---|
357 | <delete dir="${packages.home}/mysql/tests"/>
|
---|
358 | <delete dir="${packages.home}/mysql/mysql-test"/>
|
---|
359 | <delete file="${packages.home}/mysql/var/log/mysql.log"/>
|
---|
360 | </target>
|
---|