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