diff build.xml @ 35:bcbc92ffe0d0

Makes a .deb file at long last, but Duke still shows up as an icon in the dock.
author David Barts <n5jrn@me.com>
date Thu, 30 Apr 2020 21:22:30 -0700
parents d175593317a8
children aa9ab6cbaa26
line wrap: on
line diff
--- a/build.xml	Wed Apr 29 21:49:21 2020 -0700
+++ b/build.xml	Thu Apr 30 21:22:30 2020 -0700
@@ -32,6 +32,30 @@
     ]]>
   </scriptdef>
 
+  <scriptdef language="javascript" name="du">
+    <attribute name="path" />
+    <attribute name="target" />
+    <![CDATA[
+      "use strict";
+      var File = Java.type('java.io.File');
+      function du(fp) {
+        if (fp.isDirectory()) {
+          var files = fp.listFiles();
+          if (!files) return 0;
+          var total = 0;
+          for(var i=0; i<files.length; i++)
+            total += du(files[i]);
+          return total;
+        } else {
+          return fp.length();
+        }
+      }
+      var path = new File(attributes.get("path"));
+      project.setProperty(attributes.get("target"),
+        Math.round(du(path) / 1024) + "");
+    ]]>
+  </scriptdef>
+
   <!-- Define the properties used by the build -->
   <property name="app.name"      value="${ant.project.name}"/>
   <property name="app.version"   value="1.03"/>
@@ -198,164 +222,54 @@
   <target name="winapp" depends="jar" description="Create app bundle.">
     <!-- not finished -->
   </target>
-  
-  <target name="gunk">
-    <sequential>
-      <mkdir dir="${dist.home}/classes/package-files/linux/deb"/>
-      <copy todir="${dist.home}/classes/package-files/linux/deb">
-        <fileset file="${pf.home}/linux/deb/control"/>
-      </copy>
-      <exec executable="ls">
-        <arg value="-ld"/>
-        <arg value="${dist.home}/classes/package-files/linux/deb"/>
-      </exec>
-    </sequential>
-  </target>
 
   <target name="deb" depends="jar" description="Create Debian package.">
     <sequential>
-      <mod:calculatesize realsizeproperty="deb.installed.size">
-        <fileset file="${jar.name}"/>
-      </mod:calculatesize>
-      <mkdir dir="${dist.home}/classes/package-files/linux/deb"/>
-      <copy todir="${dist.home}/classes/package-files/linux/deb" encoding="UTF-8"
-            overwrite="true">
+      <mkdir dir="${dist.home}/data/usr/share/applications"/>
+      <copy file="${pf.home}/linux/deb/jpegwasher.desktop"
+        tofile="${dist.home}/data/usr/share/applications/jpegwasher.desktop"/>
+      <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/>
+      <copy file="${pf.home}/linux/icon_48x48.png"
+        tofile="${dist.home}/data/usr/share/icons/hicolor/48x48/apps/jpegwasher.png"/>
+      <mkdir dir="${dist.home}/data/usr/share/jpegwasher"/>
+      <copy file="${jar.name}" todir="${dist.home}/data/usr/share/jpegwasher"/>
+      <mkdir dir="${dist.home}/data/usr/share/doc/jpegwasher"/>
+      <copy todir="${dist.home}/data/usr/share/doc/jpegwasher">
+        <filelist dir="${basedir}" files="Readme.html,Readme.rst"/>
+        <fileset file="${pf.home}/linux/deb/copyright"/>
+      </copy>
+      <gzip src="${pf.home}/linux/deb/changelog"
+        destfile="${dist.home}/data/usr/share/doc/jpegwasher/changelog.gz"/>
+      <mkdir dir="${dist.home}/data/usr/share/man/man1"/>
+      <gzip src="${pf.home}/linux/jpegwasher.1"
+        destfile="${dist.home}/data/usr/share/man/man1/jpegwasher.1.gz"/>
+      <mkdir dir="${dist.home}/data/usr/bin"/>
+      <copy todir="${dist.home}/data/usr/bin" encoding="UTF-8" overwrite="true">
+        <fileset file="${pf.home}/linux/jpegwasher"/>
+        <filterset>
+          <filter token="jar.filename" value="${lc.app.name}.jar"/>
+        </filterset>
+      </copy>
+      <chmod file="${dist.home}/data/usr/bin/jpegwasher" perm="755"/>
+      <du path="${dist.home}/data" target="deb.installed.size"/>
+      <mkdir dir="${dist.home}/control"/>
+      <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true">
         <fileset file="${pf.home}/linux/deb/control"/>
         <filterset>
           <filter token="app.version" value="${app.version}"/>
           <filter token="deb.installed.size" value="${deb.installed.size}"/>
         </filterset>
       </copy>
-      <copy todir="${dist.home}/classes/package-files/linux">
-        <filelist dir="${pf.home}/linux" files="jpegwasher,jpegwasher.1"/>
-        <filterset>
-          <filter token="jar.filename" value="${lc.app.name}.jar"/>
-        </filterset>
-      </copy>
-      <mkdir dir="${dist.home}/doc"/>
-      <copy todir="${dist.home}/doc">
-        <filelist dir="${basedir}" files="Readme.html,Readme.rst"/>
-      </copy>
-      <copy todir="${dist.home}">
-        <filelist dir="${basedir}" files="${jar.name}"/>
+      <copy todir="${dist.home}/control">
+        <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/>
       </copy>
-      <property name="deb.file" value="${dist.home}/${lc.app.name}_${app.version}.deb"/>
-      <mod:deb destfile="${deb.file}"
-               tempDir="${dist.home}/classes/deb"
-               deleteTempFiles="false"
-               includeMd5sums="true">
-        <controlfileset file="${dist.home}/classes/package-files/linux/deb/control"/>
-        <controlfileset dir="${dist.home}/classes/package-files/linux/deb"
-                        includes="postinst,postrm" mode="755"/>
-        <datafileset file="." fullpath="usr/"/>
-        <datafileset file="." fullpath="usr/bin/"/>
-        <datafileset file="${dist.home}/classes/package-files/linux/jpegwasher"
-                     fullpath="usr/bin/jpegwasher" mode="755"/>
-        <datafileset file="." fullpath="usr/lib/"/>
-        <datafileset file="." fullpath="usr/lib/menu/"/>
-        <datafileset file="${dist.home}/classes/package-files/linux/deb/jedit"
-                     fullpath="usr/lib/menu/jedit"/>
-        <datafileset file="." fullpath="usr/share/"/>
-        <datafileset file="." fullpath="usr/share/applications/"/>
-        <datafileset file="${dist.home}/classes/package-files/linux/deb/jedit.desktop"
-                     fullpath="usr/share/applications/jedit.desktop"/>
-        <datafileset file="." fullpath="usr/share/doc/"/>
-        <datafileset file="." fullpath="usr/share/doc/JpegWasher/"/>
-        <datafileset dir="${dist.home}/doc" includes="*.html,*.rst"
-                     prefix="usr/share/doc/JpegWasher/"/>
-        <datafileset file="." fullpath="usr/share/JpegWasher/"/>
-        <datafileset dir="${dist.home}"
-                     includes="doc/**,keymaps/**,macros/**,modes/**,properties/**,startup/**,${jar.name}"
-                     prefix="usr/share/JpegWasher/"/>
-        <datafileset file="." fullpath="/usr/share/JpegWasher/jars"/>
-        <datafileset file="${jar.name}"
-          fullpath="/usr/share/JpegWasher/jars/${lc.app.name}.jar"/>
-        <datafileset file="."
-                     fullpath="usr/share/man/"/>
-        <datafileset file="."
-                     fullpath="usr/share/man/man1/"/>
-        <datafileset file="${dist.home}/classes/package-files/linux/jpegwasher.1"
-                     fullpath="usr/share/man/man1/jpegwasher.1"/>
-      </mod:deb>
-      <length property="deb.size" file="${deb.file}"/>
-      <checksum file="${deb.file}" algorithm="MD5" property="deb.md5"/>
-      <checksum file="${deb.file}" algorithm="SHA1" property="deb.sha1"/>
-      <checksum file="${deb.file}" algorithm="SHA-256" property="deb.sha256"/>
-      <copy todir="${dist.home}" encoding="UTF-8" overwrite="true">
-        <fileset file="${pf.home}/linux/deb/Packages"/>
-        <filterset>
-          <filter token="app.version" value="${app.version}"/>
-          <filter token="deb.installed.size" value="${deb.installed.size}"/>
-          <filter token="deb.repository.file" value="${deb.file}"/>
-          <filter token="deb.size" value="${deb.size}"/>
-          <filter token="deb.md5" value="${deb.md5}"/>
-          <filter token="deb.sha1" value="${deb.sha1}"/>
-          <filter token="deb.sha256" value="${deb.sha256}"/>
-        </filterset>
-      </copy>
-      <gzip src="${dist.home}/Packages" destfile="${dist.home}/Packages.gz"/>
-      <bzip2 src="${dist.home}/Packages" destfile="${dist.home}/Packages.bz2"/>
-      <length property="packages.size" file="${dist.home}/Packages"/>
-      <checksum file="${dist.home}/Packages"
-                algorithm="MD5" property="packages.md5"/>
-      <checksum file="${dist.home}/Packages"
-                algorithm="SHA1" property="packages.sha1"/>
-      <checksum file="${dist.home}/Packages"
-                algorithm="SHA-256" property="packages.sha256"/>
-      <length property="packages.gz.size"
-              file="${dist.home}/Packages.gz"/>
-      <checksum file="${dist.home}/Packages.gz"
-                algorithm="MD5" property="packages.gz.md5"/>
-      <checksum file="${dist.home}/Packages.gz"
-                algorithm="SHA1" property="packages.gz.sha1"/>
-      <checksum file="${dist.home}/Packages.gz"
-                algorithm="SHA-256" property="packages.gz.sha256"/>
-      <length property="packages.bz2.size"
-              file="${dist.home}/Packages.bz2"/>
-      <checksum file="${dist.home}/Packages.bz2"
-                algorithm="MD5" property="packages.bz2.md5"/>
-      <checksum file="${dist.home}/Packages.bz2"
-                algorithm="SHA1" property="packages.bz2.sha1"/>
-      <checksum file="${dist.home}/Packages.bz2"
-                algorithm="SHA-256" property="packages.bz2.sha256"/>
-      <script language="javascript">
-        <![CDATA[
-          "use strict";
-          var Calendar = Java.type('java.util.Calendar');
-          var File = Java.type('java.io.File');
-          var Formatter = Java.type('java.util.Formatter');
-          var Locale = Java.type('java.util.Locale');
-          var TimeZone = Java.type('java.util.TimeZone');
-          new Formatter(new File(project.getProperty("dist.home"), "Release"), "UTF-8", Locale.ENGLISH)
-            .format("Date: %1$ta, %1$td %1$tb %1$tY %1$tT %1$tZ\n",
-              Calendar.getInstance(TimeZone.getTimeZone("UTC")))
-            .format("MD5Sum:\n")
-            .format(" %s %16s %s\n", project.getProperty("packages.md5"),
-              project.getProperty("packages.size"), "Packages")
-            .format(" %s %16s %s\n", project.getProperty("packages.bz2.md5"),
-              project.getProperty("packages.bz2.size"), "Packages.bz2")
-            .format(" %s %16s %s\n", project.getProperty("packages.gz.md5"),
-              project.getProperty("packages.gz.size"), "Packages.gz")
-            .format("SHA1:\n")
-            .format(" %s %16s %s\n", project.getProperty("packages.sha1"),
-              project.getProperty("packages.size"), "Packages")
-            .format(" %s %16s %s\n", project.getProperty("packages.bz2.sha1"),
-              project.getProperty("packages.bz2.size"), "Packages.bz2")
-            .format(" %s %16s %s\n", project.getProperty("packages.gz.sha1"),
-              project.getProperty("packages.gz.size"), "Packages.gz")
-            .format("SHA256:\n")
-            .format(" %s %16s %s\n", project.getProperty("packages.sha256"),
-              project.getProperty("packages.size"), "Packages")
-            .format(" %s %16s %s\n", project.getProperty("packages.bz2.sha256"),
-              project.getProperty("packages.bz2.size"), "Packages.bz2")
-            .format(" %s %16s %s\n", project.getProperty("packages.gz.sha256"),
-              project.getProperty("packages.gz.size"), "Packages.gz")
-            .close();
-        ]]>
-        <!-- gpg reads from tty, so can't be used inside ant -->
-      </script>
-      <echo message="Use gpg(1) to sign the Release file, if desired:"/>
-      <echo message="    gpg --sign ${dist.home}/Release"/>
+      <chmod perm="755">
+        <filelist dir="${dist.home}/control" files="postinst,postrm"/>
+      </chmod>
+      <exec executable="${basedir}/make-debian-package">
+        <arg value="${dist.home}"/>
+        <arg value="${lc.app.name}_${app.version}.deb"/>
+      </exec>
     </sequential>
   </target>