comparison build.xml @ 28:c310ec097194

Add Linux support.
author David Barts <n5jrn@me.com>
date Fri, 25 Dec 2020 19:07:47 -0800
parents 9bf3d8de6904
children e90d290a9a8d
comparison
equal deleted inserted replaced
27:404eb7e57fe6 28:c310ec097194
24 <attribute name="target" /> 24 <attribute name="target" />
25 <![CDATA[ 25 <![CDATA[
26 "use strict"; 26 "use strict";
27 project.setProperty( attributes.get( "target" ), 27 project.setProperty( attributes.get( "target" ),
28 attributes.get( "value" ).toLowerCase() ); 28 attributes.get( "value" ).toLowerCase() );
29 ]]>
30 </scriptdef>
31
32 <!-- estimate disk usage -->
33 <scriptdef language="javascript" name="du">
34 <attribute name="path" />
35 <attribute name="target" />
36 <![CDATA[
37 "use strict";
38 var File = Java.type('java.io.File');
39 function du(fp) {
40 if (fp.isDirectory()) {
41 var files = fp.listFiles();
42 if (!files) return 0;
43 var total = 0;
44 for (var i=0; i<files.length; i++)
45 total += du(files[i]);
46 return total;
47 } else {
48 return fp.length();
49 }
50 }
51 var path = new File(attributes.get("path"));
52 project.setProperty(attributes.get("target"),
53 Math.round(du(path) / 1024) + "");
29 ]]> 54 ]]>
30 </scriptdef> 55 </scriptdef>
31 56
32 <!-- Define the properties used by the build --> 57 <!-- Define the properties used by the build -->
33 <property name="app.name" value="${ant.project.name}"/> 58 <property name="app.name" value="${ant.project.name}"/>
189 <arg file="${dist.home}/${mac.disk.image.filename}"/> 214 <arg file="${dist.home}/${mac.disk.image.filename}"/>
190 </exec> 215 </exec>
191 </sequential> 216 </sequential>
192 </target> 217 </target>
193 218
219 <target name="deb" depends="jar" description="Create Debian package.">
220 <fail message="Linux packages can only be built on Linux.">
221 <condition>
222 <not><os family="unix"/></not>
223 </condition>
224 </fail>
225 <sequential>
226 <mkdir dir="${dist.home}/data/usr/share/applications"/>
227 <copy file="${pf.home}/linux/deb/imageprep.desktop"
228 tofile="${dist.home}/data/usr/share/applications/imageprep.desktop"/>
229 <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/>
230 <copy file="${pf.home}/linux/icon_48x48.png"
231 tofile="${dist.home}/data/usr/share/icons/hicolor/48x48/apps/imageprep.png"/>
232 <mkdir dir="${dist.home}/data/usr/share/imageprep"/>
233 <copy file="${jar.name}" todir="${dist.home}/data/usr/share/imageprep"/>
234 <mkdir dir="${dist.home}/data/usr/share/doc/imageprep"/>
235 <copy todir="${dist.home}/data/usr/share/doc/imageprep">
236 <filelist dir="${basedir}" files="Readme.html,Readme.rst"/>
237 </copy>
238 <copy todir="${dist.home}/data/usr/share/doc/imageprep" encoding="UTF-8" overwrite="true">
239 <fileset file="${pf.home}/linux/deb/copyright"/>
240 <filterset>
241 <filter token="app.copyright" value="${app.copyright}"/>
242 </filterset>
243 </copy>
244 <gzip src="${pf.home}/linux/deb/changelog"
245 destfile="${dist.home}/data/usr/share/doc/imageprep/changelog.gz"/>
246 <mkdir dir="${dist.home}/data/usr/share/man/man1"/>
247 <gzip src="${pf.home}/linux/imageprep.1"
248 destfile="${dist.home}/data/usr/share/man/man1/imageprep.1.gz"/>
249 <mkdir dir="${dist.home}/data/usr/bin"/>
250 <copy todir="${dist.home}/data/usr/bin" encoding="UTF-8" overwrite="true">
251 <fileset file="${pf.home}/linux/imageprep"/>
252 <filterset>
253 <filter token="jar.filename" value="${lc.app.name}.jar"/>
254 </filterset>
255 </copy>
256 <chmod file="${dist.home}/data/usr/bin/imageprep" perm="755"/>
257 <du path="${dist.home}/data" target="deb.installed.size"/>
258 <mkdir dir="${dist.home}/control"/>
259 <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true">
260 <fileset file="${pf.home}/linux/deb/control"/>
261 <filterset>
262 <filter token="app.version" value="${app.version}"/>
263 <filter token="deb.installed.size" value="${deb.installed.size}"/>
264 </filterset>
265 </copy>
266 <copy todir="${dist.home}/control">
267 <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/>
268 </copy>
269 <chmod perm="755">
270 <filelist dir="${dist.home}/control" files="postinst,postrm"/>
271 </chmod>
272 <exec executable="${basedir}/make-debian-package" failonerror="true">
273 <arg value="${dist.home}"/>
274 <arg value="${lc.app.name}_${app.version}.deb"/>
275 </exec>
276 </sequential>
277 </target>
278
194 </project> 279 </project>