Move off sourceforge
[phorkie.git] / build.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <project name="phorkie" default="zip" basedir=".">
3   <!--
4     phorkie phing build file.
5     This script should provide a one-stop tool for all administrative
6     tasks around phorkie, like creating a release version,
7     tagging a release
8   -->
9   <property name="version"    value="0.7.0" />
10   <property name="stability"  value="beta" />
11   <property name="releasenotes" value="
12 Version 0.7.0 - 2015-11-05
13 --------------------------
14 * Add support for elasticsearch 2.0
15 * Add text file detection for unknown file extensions
16 " />
17   <property name="libdir"      value="${phing.dir}/lib"/>
18
19   <property name="zipfile"     value="${phing.project.name}-${version}.tar.bz2" />
20   <property name="pharfile"    value="${phing.project.name}-${version}.phar" />
21   <property name="pkgfile"     value="${phing.project.name}-${version}.tgz" />
22
23   <property name="pharpath"    value="${phing.dir}/dist/${pharfile}" />
24   <property name="distfile"    value="dist/${zipfile}" />
25   <property name="distpkgfile" value="dist/pear/${pkgfile}" />
26
27   <fileset id="fs.zip" dir=".">
28    <include name="data/**"/>
29    <include name="scripts/**"/>
30    <include name="src/**"/>
31    <include name="www/**"/>
32
33    <include name="ChangeLog"/>
34    <include name="LICENSE"/>
35    <include name="NEWS.rst"/>
36    <include name="README.rst"/>
37
38    <exclude name="**/.git/"/>
39    <exclude name="**/.gitignore/"/>
40    <exclude name="data/cache/**"/>
41    <exclude name="data/config.php"/>
42    <exclude name="www/**/.phar"/>
43    <exclude name="www/repos"/>
44   </fileset>
45
46   <fileset id="fs.phar" dir="${phing.dir}">
47    <include name="data/**"/>
48    <include name="lib/**"/>
49    <include name="scripts/**"/>
50    <include name="src/**"/>
51    <include name="www/**"/>
52
53    <include name="ChangeLog"/>
54    <include name="README.rst"/>
55
56    <exclude name="**/.git/"/>
57    <exclude name="**/.gitignore/"/>
58    <exclude name="data/cache/**"/>
59    <exclude name="data/config.php"/>
60    <exclude name="www/**/.phar"/>
61    <exclude name="www/repos"/>
62   </fileset>
63
64   <fileset id="fs.doc" dir=".">
65    <include name="README.rst"/>
66    <include name="NEWS.rst"/>
67   </fileset>
68
69   <taskdef name="d51pearpkg2" classname="phing.tasks.ext.d51PearPkg2Task" />
70
71
72   <target name="phar" depends="preparedirs,collectdeps"
73           description="Create phar file for release"
74   >
75    <delete file="${pharpath}"/>
76    <exec command="php scripts/build-rewritemap.php" dir="${phing.dir}"/>
77    <pharpackage basedir="${phing.dir}"
78                 destfile="${pharpath}"
79                 stub="${phing.dir}/src/stub-phar.php"
80                 alias="phorkie.phar"
81    >
82     <fileset refid="fs.phar"/>
83    </pharpackage>
84
85    <exec executable="bzip2" dir="${phing.dir}/dist">
86     <arg value="-kf"/>
87     <arg file="${pharpath}"/>
88    </exec>
89   </target>
90
91
92   <target name="collectdeps" description="Copy package dependencies to lib/">
93    <delete dir="${libdir}"/>
94    <mkdir dir="${libdir}"/>
95
96    <!-- requires phing >= 2.8.0 -->
97    <copy todir="${libdir}">
98     <pearPackageFileset package="pear.php.net/Cache_Lite"/><!-- OpenID -->
99     <pearPackageFileset package="pear.php.net/Console_Getopt"/>
100     <pearPackageFileset package="pear.php.net/Crypt_DiffieHellman"/><!-- OpenID -->
101     <pearPackageFileset package="pear.php.net/Date_HumanDiff"/>
102     <pearPackageFileset package="pear.geshi.org/geshi">
103      <!-- remove files that are probably not needed to save space in the .phar -->
104      <exclude name="geshi/arm.php"/>
105      <exclude name="geshi/autoit.php"/>
106      <exclude name="geshi/thinbasic.php"/>
107     </pearPackageFileset>
108     <pearPackageFileset package="pear.php.net/HTTP2"/>
109     <pearPackageFileset package="pear.php.net/HTTP_Request2"/>
110     <pearPackageFileset package="pear.php.net/MIME_Type"/>
111     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect"/>
112     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect" role="data"/>
113     <pearPackageFileset package="pear.michelf.com/Markdown"/>
114     <pearPackageFileset package="pear.php.net/Net_URL2"/>
115     <pearPackageFileset package="pear.php.net/OpenID"/>
116     <pearPackageFileset package="pear.php.net/Pager"/>
117     <pearPackageFileset package="pear.php.net/PEAR">
118      <include name="PEAR/Exception.php"/>
119      <include name="PEAR.php"/>
120      <include name="PEAR5.php"/>
121      <include name="OS/Guess.php"/>
122      <include name="System.php"/>
123     </pearPackageFileset>
124     <pearPackageFileset package="pear.php.net/Services_Libravatar"/>
125     <pearPackageFileset package="pear2.php.net/PEAR2_Services_Linkback"/>
126     <pearPackageFileset package="pear.php.net/Services_Yadis"/>
127     <pearPackageFileset package="pear.php.net/System_Command"/>
128     <pearPackageFileset package="pear.twig-project.org/Twig"/>
129     <pearPackageFileset package="pear.php.net/Validate"/>
130     <pearPackageFileset package="pear.php.net/VersionControl_Git"/>
131    </copy>
132   </target>
133
134
135   <target name="zip" depends="preparedirs"
136    description="Create zip file for release"
137    >
138     <!--
139       The release file is for end users, so it is safe to
140       remove anything developer-related.
141
142       Test your zip with: unzip -l phorkie-0.1.0.zip
143     -->
144     <echo msg="Creating distribution zip for phorkie ${version}"/>
145     <delete file="${distfile}" failonerror="false"/>
146     <tar compression="bzip2" destfile="${distfile}"
147          prefix="${phing.project.name}-${version}/"
148     >
149      <fileset refid="fs.zip"/>
150     </tar>
151   </target>
152
153
154
155   <target name="pear" depends="check"
156    description="Creates the pear package"
157   >
158    <d51pearpkg2 dir="." baseinstalldir="/">
159      <name>phorkie</name>
160      <summary>Self-hosted pastebin software</summary>
161      <description>
162       Self-hosted pastebin software written in PHP.
163       Pastes are editable, may have multiple files and are stored in git repositories.
164      </description>
165      <channel>phorkie.sourceforge.net</channel>
166
167      <lead user="cweiske" name="Christian Weiske" email="cweiske@cweiske.de" />
168      <license>AGPL</license>
169
170      <version   release="${version}"   api="${version}" />
171      <stability release="${stability}" api="${stability}" />
172
173      <notes>${releasenotes}</notes>
174
175      <dependencies>
176        <php minimum_version="5.3.0" />
177        <pear minimum_version="1.9.0" />
178
179        <package name="Date_HumanDiff"
180                 channel="pear.php.net"
181                 minimum_version="0.4.0"
182                 />
183        <package name="HTTP_Request2"
184                 channel="pear.php.net"
185                 minimum_version="2.1.0"
186                 />
187        <package name="OpenID"
188                 channel="pear.php.net"
189                 minimum_version="0.3.3"
190                 />
191        <package name="Pager"
192                 channel="pear.php.net"
193                 minimum_version="2.4.8"
194                 />
195        <package name="PEAR2_Services_Linkback"
196                 channel="pear2.php.net"
197                 minimum_version="0.2.1"
198                 />
199        <package name="Services_Libravatar"
200                 channel="pear.php.net"
201                 minimum_version="0.2.2"
202                 />
203        <package name="VersionControl_Git"
204                 channel="pear.php.net"
205                 minimum_version="0.4.4"
206                 />
207
208        <package name="geshi"
209                 channel="pear.geshi.org/geshi"
210                 minimum_version="1.0.0"
211                 />
212        <package name="Markdown"
213                 channel="pear.michelf.com"
214                 minimum_version="0.0.2"
215                 />
216        <package name="MIME_Type_PlainDetect"
217                 channel="zustellzentrum.cweiske.de"
218                 minimum_version="0.0.2"
219                 />
220        <package name="Twig"
221                 channel="pear.twig-project.org"
222                 minimum_version="1.6.0"
223                 />
224
225      </dependencies>
226
227      <!-- map directory (key) to role -->
228      <dirroles key="data">data</dirroles>
229      <dirroles key="scripts">data</dirroles>
230      <dirroles key="src">php</dirroles>
231      <dirroles key="www">www</dirroles>
232
233      <!-- do not add the following files to the package.
234           copied from excludes above -->
235      <ignore>**/.gitignore</ignore>
236      <ignore>build*</ignore>
237      <ignore>data/config.php</ignore>
238      <ignore>dist/**</ignore>
239      <ignore>*.properties</ignore>
240      <ignore>*.tgz</ignore>
241
242      <replacement path="www/www-header.php"
243       type="pear-config" from="@data_dir@" to="data_dir"
244       />
245
246
247    </d51pearpkg2>
248
249    <!-- time to fix the package.xml file since the task does not
250         allow everything we need:
251         - strip the base directory names like src, data and www
252         - remove that dumb baseinstalldir from files
253         - md5sums are generated automatically when packaging
254    -->
255    <!-- yes, we need to generate a 2nd file and move it back -->
256    <copy file="package.xml" tofile="package2.xml" overwrite="true">
257     <filterchain>
258      <replaceregexp>
259       <!-- remove md5sums -->
260       <regexp
261        pattern="md5sum=&quot;[a-z0-9]{32}&quot; "
262        replace=""
263        />
264       <!-- remove baseinstalldir for files -->
265       <regexp
266        pattern="&lt;file baseinstalldir=&quot;/&quot;"
267        replace="&lt;file"
268        />
269       <!-- install-as for different directories -->
270       <regexp
271        pattern="(&lt;file name=&quot;data/(.+?)&quot;)"
272        replace="\1 install-as=&quot;\2&quot;"
273        />
274       <regexp
275        pattern="(&lt;file name=&quot;doc/(.+?)&quot;)"
276        replace="\1 install-as=&quot;\2&quot;"
277        />
278       <regexp
279        pattern="(&lt;file name=&quot;tests/(.+?)&quot;)"
280        replace="\1 install-as=&quot;\2&quot;"
281        />
282       <regexp
283        pattern="(&lt;file name=&quot;www/(.+?)&quot;)"
284        replace="\1 install-as=&quot;phorkie/\2&quot;"
285        />
286       <regexp
287        pattern="(&lt;file name=&quot;src/(.+?)&quot;)"
288        replace="\1 install-as=&quot;\2&quot;"
289        />
290      </replaceregexp>
291     </filterchain>
292    </copy>
293    <move file="package2.xml" tofile="package.xml" overwrite="true" />
294
295    <!-- package up -->
296    <exec command="pear package" passthru="true" />
297    <move file="${pkgfile}" todir="dist/pear/" />
298
299    <delete file="package.xml" failonerror="true" />
300   </target>
301
302
303   <target name="docs" description="render documentation">
304    <rST format="html" uptodate="true">
305     <fileset refid="fs.doc"/>
306     <mapper type="regexp" from="^(.+?).rst$" to="dist/docs/\1.html"/>
307    </rST>
308   </target>
309
310   <target name="clean-docs" description="delete rendered documentation files">
311    <delete dir="dist/docs" includeemptydirs="yes"/>
312   </target>
313
314
315   <target name="release" depends="check,zip,pear"
316    description="Package the new version"
317    >
318    <!-- meta-target -->
319   </target>
320
321
322   <target name="preparedirs">
323     <mkdir dir="dist" />
324   </target>
325
326   <target name="check" depends="preparedirs"
327    description="Check variables"
328    >
329     <fail unless="version" message="Version not defined!" />
330   </target>
331
332 </project>