talk about search setup
[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.1" />
12   <property name="version"    value="0.1.0" />
13   <property name="stability"  value="alpha" />
14   <property name="releasenotes" value="
15 First release
16 " />
17   <property name="zipfile"     value="${phing.project.name}-${version}.zip" />
18   <property name="pkgfile"     value="${phing.project.name}-${version}.tgz" />
19   <property name="distfile"    value="dist/${zipfile}" />
20   <property name="distpkgfile" value="dist/pear/${pkgfile}" />
21   <property name="sfproject"   value="phorkie" />
22   <property name="sffilepath"  value="p/ph/phorkie/" />
23
24   <fileset id="fs.zip" dir=".">
25    <include name="data/**"/>
26    <include name="src/**"/>
27    <include name="www/**"/>
28    <include name="LICENSE"/>
29    <include name="README.rst"/>
30    <exclude name="**/.gitignore/"/>
31    <exclude name="data/config.php"/>
32   </fileset>
33
34   <fileset id="fs.doc" dir=".">
35    <include name="README.rst"/>
36   </fileset>
37
38   <taskdef name="rST" classname="phing.tasks.ext.rSTTask" />
39   <taskdef name="d51pearpkg2" classname="phing.tasks.ext.d51PearPkg2Task" />
40
41   <target name="zip" depends="check"
42    description="Create zip file for release"
43    >
44     <!--
45       The release file is for end users, so it is safe to
46       remove anything developer-related.
47
48       Test your zip with: unzip -l phorkie-0.1.0.zip
49     -->
50     <echo msg="Creating distribution zip for phorkie ${version}"/>
51     <delete file="${distfile}" failonerror="false"/>
52     <zip destfile="${distfile}" prefix="${phing.project.name}-${version}/">
53      <fileset refid="fs.zip"/>
54     </zip>
55   </target>
56
57
58
59   <target name="package" depends="check"
60    description="Creates the pear package"
61   >
62    <d51pearpkg2 dir="." baseinstalldir="/">
63      <name>phorkie</name>
64      <summary>Self-hosted pastebin software</summary>
65      <description>
66       Self-hosted pastebin software written in PHP.
67       Pastes are editable, may have multiple files and are stored in git repositories.
68      </description>
69      <channel>phorkie.sourceforge.net</channel>
70
71      <lead user="cweiske" name="Christian Weiske" email="cweiske@cweiske.de" />
72      <license>AGPL</license>
73
74      <version   release="${version}"   api="${version}" />
75      <stability release="${stability}" api="${stability}" />
76
77      <notes>${releasenotes}</notes>
78
79      <dependencies>
80        <php minimum_version="5.2.0" />
81        <pear minimum_version="1.9.0" />
82
83        <package name="Date_HumanDiff"
84                 channel="pear.php.net"
85                 minimum_version="0.1.0"
86                 />
87        <package name="VersionControl_Git"
88                 channel="pear.php.net"
89                 minimum_version="0.4.4"
90                 />
91        <package name="geshi"
92                 channel="mediawiki.googlecode.com/svn"
93                 minimum_version="1.0.0"
94                 />
95        <package name="Twig"
96                 channel="pear.twig-project.org"
97                 minimum_version="1.6.0"
98                 />
99
100      </dependencies>
101
102      <!-- map directory (key) to role -->
103      <dirroles key="www">www</dirroles>
104      <dirroles key="data">data</dirroles>
105      <dirroles key="src">php</dirroles>
106
107      <!-- do not add the following files to the package.
108           copied from excludes above -->
109      <ignore>**/.gitignore</ignore>
110      <ignore>**/.svn</ignore>
111      <ignore>build*</ignore>
112      <ignore>data/config.php</ignore>
113      <ignore>dist/**</ignore>
114      <ignore>*.properties</ignore>
115      <ignore>*.tgz</ignore>
116
117      <replacement path="www/www-header.php"
118       type="pear-config" from="@data_dir@" to="data_dir"
119       />
120
121
122    </d51pearpkg2>
123
124    <!-- time to fix the package.xml file since the task does not
125         allow everything we need:
126         - strip the base directory names like src, data and www
127         - remove that dumb baseinstalldir from files
128         - md5sums are generated automatically when packaging
129    -->
130    <!-- yes, we need to generate a 2nd file and move it back -->
131    <copy file="package.xml" tofile="package2.xml" overwrite="true">
132     <filterchain>
133      <replaceregexp>
134       <!-- remove md5sums -->
135       <regexp
136        pattern="md5sum=&quot;[a-z0-9]{32}&quot; "
137        replace=""
138        />
139       <!-- remove baseinstalldir for files -->
140       <regexp
141        pattern="&lt;file baseinstalldir=&quot;/&quot;"
142        replace="&lt;file"
143        />
144       <!-- install-as for different directories -->
145       <regexp
146        pattern="(&lt;file name=&quot;data/(.+?)&quot;)"
147        replace="\1 install-as=&quot;\2&quot;"
148        />
149       <regexp
150        pattern="(&lt;file name=&quot;doc/(.+?)&quot;)"
151        replace="\1 install-as=&quot;\2&quot;"
152        />
153       <regexp
154        pattern="(&lt;file name=&quot;tests/(.+?)&quot;)"
155        replace="\1 install-as=&quot;\2&quot;"
156        />
157       <regexp
158        pattern="(&lt;file name=&quot;www/(.+?)&quot;)"
159        replace="\1 install-as=&quot;phorkie/\2&quot;"
160        />
161       <regexp
162        pattern="(&lt;file name=&quot;src/(.+?)&quot;)"
163        replace="\1 install-as=&quot;\2&quot;"
164        />
165      </replaceregexp>
166     </filterchain>
167    </copy>
168    <move file="package2.xml" tofile="package.xml" overwrite="true" />
169
170    <!-- package up -->
171    <exec command="pear package" passthru="true" />
172    <move file="${pkgfile}" todir="dist/pear/" />
173
174    <delete file="package.xml" failonerror="true" />
175   </target>
176
177
178   <target name="build-docs" description="render documentation">
179    <rST format="html" uptodate="true">
180     <fileset refid="fs.doc"/>
181     <mapper type="regexp" from="^(.+?).rst$" to="dist/docs/\1.html"/>
182    </rST>
183   </target>
184
185   <target name="clean-docs" description="delete rendered documentation files">
186    <delete dir="dist/docs" includeemptydirs="yes"/>
187   </target>
188
189
190   <target name="release" depends="check,zip,package,deploy-sf"
191    description="Release the version on sourceforge"
192    >
193    <!-- meta-target -->
194   </target>
195
196
197   <!--
198   /home/frs/project/p/ph/phorkie/phorkie/v0.1/
199   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.0.zip
200   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.1.zip
201   https://sourceforge.net/apps/trac/sourceforge/wiki/Release%20files%20for%20download
202   -->
203   <target name="deploy-sf" depends="check,zip"
204    description="Upload release to sourceforge"
205    >
206     <delete dir="dist/deploy-sf" /><!-- make empty -->
207     <mkdir dir="dist/deploy-sf" />
208     <mkdir dir="dist/deploy-sf/v${version-m}" />
209     <copy file="${distfile}" tofile="dist/deploy-sf/v${version-m}/${zipfile}"/>
210     <!-- test
211     <exec command="rsync -av dist/deploy-sf/ /tmp/test/" escape="false" />
212     -->
213     <exec
214      command="rsync -av -e ssh dist/deploy-sf/ ${sfuser},${sfproject}@frs.sourceforge.net:/home/frs/project/${sffilepath}/${sfproject}/"
215      escape="false" checkreturn="false"
216      />
217     <!-- rsync always returns code 23 on sourceforge releases, so we
218          can't check return values -->
219   </target>
220
221
222   <target name="check"
223    description="Check variables"
224    >
225     <fail unless="version" message="Version not defined!" />
226     <fail unless="sfuser" message="Sourceforge username not defined!" />
227     <fail unless="sfproject" message="Sourceforge project name not defined!" />
228     <fail unless="sffilepath" message="Sourceforge project file path not defined!" />
229
230     <mkdir dir="dist" />
231   </target>
232
233 </project>