collect phar deps via pear during build
[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 file="build.properties" />
10
11   <property name="version-m"  value="0.4" />
12   <property name="version"    value="0.4.0" />
13   <property name="stability"  value="alpha" />
14   <property name="releasenotes" value="
15 Version 0.3.1 - 2012-09-27
16 --------------------------
17 * Check for OpenID package in SetupCheck
18 * Fix bug #24: setupcheck: verify geshi installation
19 * Fix bug #25: setupcheck: verify markdown
20
21 Version 0.3.0 - 2012-09-27
22 --------------------------
23
24 * Fix bug #10: error when nothing submitted [cweiske]
25 * Fix bug #11: do not index edit, delete and tool pages [cweiske]
26 * Fix bug #20: elasticsearch error on deletion [cweiske]
27 * Fix bug #22: Edited pastes not in 'recently created' [cweiske]
28 * Fix bug #23: 'work dir not found' on failed remote fork [cweiske]
29 * Implement request #5: Add OpenID authentication [jnovack]
30 * Implement request #9: autodetect file type [cweiske]
31 * Implement request #12: DOAP and rel='vcs-git' support [cweiske]
32 * Implement request #13: remote forking support [cweiske]
33 * Hide additional file fields by default, button to toggle their visibility
34   [cweiske]
35 * Markdown support [jnovack]
36 * Added nginx rewrite rules to README [skl]
37 " />
38   <property name="libdir"      value="${phing.dir}/lib"/>
39   <property name="zipfile"     value="${phing.project.name}-${version}.tar.bz2" />
40   <property name="pharfile"    value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
41   <property name="pkgfile"     value="${phing.project.name}-${version}.tgz" />
42   <property name="distfile"    value="dist/${zipfile}" />
43   <property name="distpkgfile" value="dist/pear/${pkgfile}" />
44   <property name="sfproject"   value="phorkie" />
45   <property name="sffilepath"  value="p/ph/phorkie/" />
46
47   <fileset id="fs.zip" dir=".">
48    <include name="data/**"/>
49    <include name="scripts/**"/>
50    <include name="src/**"/>
51    <include name="www/**"/>
52
53    <include name="ChangeLog"/>
54    <include name="LICENSE"/>
55    <include name="NEWS.rst"/>
56    <include name="README.rst"/>
57
58    <exclude name="**/.gitignore/"/>
59    <exclude name="data/config.php"/>
60   </fileset>
61
62   <fileset id="fs.phar" dir="${phing.dir}">
63    <include name="data/**"/>
64    <include name="lib/**"/>
65    <include name="scripts/**"/>
66    <include name="src/**"/>
67    <include name="www/**"/>
68
69    <include name="ChangeLog"/>
70    <include name="README.rst"/>
71
72    <exclude name="data/config.php"/>
73    <exclude name="**/.gitignore/"/>
74    <exclude name="**/.git/"/>
75   </fileset>
76
77   <fileset id="fs.doc" dir=".">
78    <include name="README.rst"/>
79    <include name="NEWS.rst"/>
80   </fileset>
81
82   <taskdef name="d51pearpkg2" classname="phing.tasks.ext.d51PearPkg2Task" />
83
84
85   <target name="phar" depends="collectdeps"
86           description="Create phar file for release"
87   >
88    <delete file="${pharfile}"/>
89    <exec command="php scripts/build-rewritemap.php" dir="${phing.dir}"/>
90    <pharpackage basedir="${phing.dir}"
91                 destfile="${pharfile}"
92                 stub="${phing.dir}/src/stub-phar.php"
93                 alias="phorkie.phar"
94    >
95     <fileset refid="fs.phar"/>
96    </pharpackage>
97
98    <exec executable="bzip2" dir="${phing.dir}/dist">
99     <arg value="-kf"/>
100     <arg file="${pharfile}"/>
101    </exec>
102   </target>
103
104
105   <target name="collectdeps" description="Copy package dependencies to lib/">
106    <delete dir="${libdir}"/>
107    <mkdir dir="${libdir}"/>
108
109    <!-- requires phing >= 2.8.0 -->
110    <copy todir="${libdir}">
111     <pearPackageFileset package="pear.php.net/Console_Getopt"/>
112     <pearPackageFileset package="pear.php.net/Date_HumanDiff"/>
113     <pearPackageFileset package="pear.geshi.org/geshi">
114      <!-- remove files that are probably not needed to save space in the .phar -->
115      <exclude name="geshi/arm.php"/>
116      <exclude name="geshi/autoit.php"/>
117      <exclude name="geshi/thinbasic.php"/>
118     </pearPackageFileset>
119     <pearPackageFileset package="pear.php.net/HTTP2"/>
120     <pearPackageFileset package="pear.php.net/HTTP_Request2"/>
121     <pearPackageFileset package="pear.php.net/MIME_Type"/>
122     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect"/>
123     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect" role="data"/>
124     <pearPackageFileset package="pear.michelf.com/Markdown"/>
125     <pearPackageFileset package="pear.php.net/Net_URL2"/>
126     <pearPackageFileset package="pear.php.net/OpenID"/>
127     <pearPackageFileset package="pear.php.net/Pager"/>
128     <pearPackageFileset package="pear.php.net/PEAR">
129      <include name="PEAR/Exception.php"/>
130      <include name="PEAR.php"/>
131      <include name="PEAR5.php"/>
132      <include name="OS/Guess.php"/>
133      <include name="System.php"/>
134     </pearPackageFileset>
135     <pearPackageFileset package="pear.php.net/Services_Libravatar"/>
136     <pearPackageFileset package="pear2.php.net/Services_Linkback"/>
137     <pearPackageFileset package="pear.php.net/System_Command"/>
138     <pearPackageFileset package="pear.twig-project.org/Twig"/>
139     <pearPackageFileset package="pear.php.net/VersionControl_Git"/>
140    </copy>
141   </target>
142
143
144   <target name="zip" depends="check"
145    description="Create zip file for release"
146    >
147     <!--
148       The release file is for end users, so it is safe to
149       remove anything developer-related.
150
151       Test your zip with: unzip -l phorkie-0.1.0.zip
152     -->
153     <echo msg="Creating distribution zip for phorkie ${version}"/>
154     <delete file="${distfile}" failonerror="false"/>
155     <tar compression="bzip2" destfile="${distfile}"
156          prefix="${phing.project.name}-${version}/"
157     >
158      <fileset refid="fs.zip"/>
159     </tar>
160   </target>
161
162
163
164   <target name="package" depends="check"
165    description="Creates the pear package"
166   >
167    <d51pearpkg2 dir="." baseinstalldir="/">
168      <name>phorkie</name>
169      <summary>Self-hosted pastebin software</summary>
170      <description>
171       Self-hosted pastebin software written in PHP.
172       Pastes are editable, may have multiple files and are stored in git repositories.
173      </description>
174      <channel>phorkie.sourceforge.net</channel>
175
176      <lead user="cweiske" name="Christian Weiske" email="cweiske@cweiske.de" />
177      <license>AGPL</license>
178
179      <version   release="${version}"   api="${version}" />
180      <stability release="${stability}" api="${stability}" />
181
182      <notes>${releasenotes}</notes>
183
184      <dependencies>
185        <php minimum_version="5.3.0" />
186        <pear minimum_version="1.9.0" />
187
188        <package name="Date_HumanDiff"
189                 channel="pear.php.net"
190                 minimum_version="0.4.0"
191                 />
192        <package name="HTTP_Request2"
193                 channel="pear.php.net"
194                 minimum_version="2.1.0"
195                 />
196        <package name="OpenID"
197                 channel="pear.php.net"
198                 minimum_version="0.3.3"
199                 />
200        <package name="Pager"
201                 channel="pear.php.net"
202                 minimum_version="2.4.8"
203                 />
204        <package name="Services_Libravatar"
205                 channel="pear.php.net"
206                 minimum_version="0.2.2"
207                 />
208        <package name="VersionControl_Git"
209                 channel="pear.php.net"
210                 minimum_version="0.4.4"
211                 />
212
213        <package name="geshi"
214                 channel="pear.geshi.org/geshi"
215                 minimum_version="1.0.0"
216                 />
217        <package name="Markdown"
218                 channel="pear.michelf.com"
219                 minimum_version="0.0.2"
220                 />
221        <package name="MIME_Type_PlainDetect"
222                 channel="zustellzentrum.cweiske.de"
223                 minimum_version="0.0.2"
224                 />
225        <package name="Twig"
226                 channel="pear.twig-project.org"
227                 minimum_version="1.6.0"
228                 />
229
230      </dependencies>
231
232      <!-- map directory (key) to role -->
233      <dirroles key="data">data</dirroles>
234      <dirroles key="scripts">data</dirroles>
235      <dirroles key="src">php</dirroles>
236      <dirroles key="www">www</dirroles>
237
238      <!-- do not add the following files to the package.
239           copied from excludes above -->
240      <ignore>**/.gitignore</ignore>
241      <ignore>build*</ignore>
242      <ignore>data/config.php</ignore>
243      <ignore>dist/**</ignore>
244      <ignore>*.properties</ignore>
245      <ignore>*.tgz</ignore>
246
247      <replacement path="www/www-header.php"
248       type="pear-config" from="@data_dir@" to="data_dir"
249       />
250
251
252    </d51pearpkg2>
253
254    <!-- time to fix the package.xml file since the task does not
255         allow everything we need:
256         - strip the base directory names like src, data and www
257         - remove that dumb baseinstalldir from files
258         - md5sums are generated automatically when packaging
259    -->
260    <!-- yes, we need to generate a 2nd file and move it back -->
261    <copy file="package.xml" tofile="package2.xml" overwrite="true">
262     <filterchain>
263      <replaceregexp>
264       <!-- remove md5sums -->
265       <regexp
266        pattern="md5sum=&quot;[a-z0-9]{32}&quot; "
267        replace=""
268        />
269       <!-- remove baseinstalldir for files -->
270       <regexp
271        pattern="&lt;file baseinstalldir=&quot;/&quot;"
272        replace="&lt;file"
273        />
274       <!-- install-as for different directories -->
275       <regexp
276        pattern="(&lt;file name=&quot;data/(.+?)&quot;)"
277        replace="\1 install-as=&quot;\2&quot;"
278        />
279       <regexp
280        pattern="(&lt;file name=&quot;doc/(.+?)&quot;)"
281        replace="\1 install-as=&quot;\2&quot;"
282        />
283       <regexp
284        pattern="(&lt;file name=&quot;tests/(.+?)&quot;)"
285        replace="\1 install-as=&quot;\2&quot;"
286        />
287       <regexp
288        pattern="(&lt;file name=&quot;www/(.+?)&quot;)"
289        replace="\1 install-as=&quot;phorkie/\2&quot;"
290        />
291       <regexp
292        pattern="(&lt;file name=&quot;src/(.+?)&quot;)"
293        replace="\1 install-as=&quot;\2&quot;"
294        />
295      </replaceregexp>
296     </filterchain>
297    </copy>
298    <move file="package2.xml" tofile="package.xml" overwrite="true" />
299
300    <!-- package up -->
301    <exec command="pear package" passthru="true" />
302    <move file="${pkgfile}" todir="dist/pear/" />
303
304    <delete file="package.xml" failonerror="true" />
305   </target>
306
307
308   <target name="build-docs" description="render documentation">
309    <rST format="html" uptodate="true">
310     <fileset refid="fs.doc"/>
311     <mapper type="regexp" from="^(.+?).rst$" to="dist/docs/\1.html"/>
312    </rST>
313   </target>
314
315   <target name="clean-docs" description="delete rendered documentation files">
316    <delete dir="dist/docs" includeemptydirs="yes"/>
317   </target>
318
319
320   <target name="release" depends="check,zip,package,deploy-sf"
321    description="Release the version on sourceforge"
322    >
323    <!-- meta-target -->
324   </target>
325
326
327   <!--
328   /home/frs/project/p/ph/phorkie/phorkie/v0.1/
329   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.0.zip
330   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.1.zip
331   https://sourceforge.net/apps/trac/sourceforge/wiki/Release%20files%20for%20download
332   -->
333   <target name="deploy-sf" depends="check,zip"
334    description="Upload release to sourceforge"
335    >
336     <delete dir="dist/deploy-sf" /><!-- make empty -->
337     <mkdir dir="dist/deploy-sf" />
338     <mkdir dir="dist/deploy-sf/v${version-m}" />
339     <copy file="${distfile}" tofile="dist/deploy-sf/v${version-m}/${zipfile}"/>
340     <!-- test
341     <exec command="rsync -av dist/deploy-sf/ /tmp/test/" escape="false" />
342     -->
343     <exec
344      command="rsync -av -e ssh dist/deploy-sf/ ${sfuser},${sfproject}@frs.sourceforge.net:/home/frs/project/${sffilepath}/${sfproject}/"
345      escape="false" checkreturn="false"
346      />
347     <!-- rsync always returns code 23 on sourceforge releases, so we
348          can't check return values -->
349   </target>
350
351
352   <target name="check"
353    description="Check variables"
354    >
355     <fail unless="version" message="Version not defined!" />
356     <fail unless="sfuser" message="Sourceforge username not defined!" />
357     <fail unless="sfproject" message="Sourceforge project name not defined!" />
358     <fail unless="sffilepath" message="Sourceforge project file path not defined!" />
359
360     <mkdir dir="dist" />
361   </target>
362
363 </project>