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