changeset 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
files Makefile.linux build.xml make-debian-package package-files/linux/deb/changelog package-files/linux/deb/control package-files/linux/deb/copyright package-files/linux/deb/jpegwasher.desktop package-files/linux/deb/postinst package-files/linux/icon_48x48.png package-files/linux/jpegwasher
diffstat 10 files changed, 149 insertions(+), 154 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.linux	Wed Apr 29 21:49:21 2020 -0700
+++ b/Makefile.linux	Thu Apr 30 21:22:30 2020 -0700
@@ -5,7 +5,10 @@
 
 .PHONY: all checkenv
 
-all: checkenv $(BDIR)/libjni.so $(BDIR)/libexiv2.so
+all: mkdirs checkenv $(BDIR)/libjni.so $(BDIR)/libexiv2.so
+
+mkdirs:
+	@[ -d "$(BDIR)" ] || mkdir -p "$(BDIR)"
 
 checkenv:
 	@if [ -z "$(JRE_HOME)" ]; then \
--- 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>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make-debian-package	Thu Apr 30 21:22:30 2020 -0700
@@ -0,0 +1,57 @@
+#!/bin/bash
+# A v. 2.0 Debian package is nothing but an ar(1) archive that contains
+# three members:
+# 1. A debian-binary file containing the string "2.0" and a newline,
+# 2. A compressed tar archive with a name of control,
+# 3. A compressed tar archive with a name of data.
+# (See https://en.wikipedia.org/wiki/Deb_%28file_format%29.) Make one.
+#
+# There are other ways to do this, but they tend to be so complex and
+# badly-documented that I found it easier to just roll my own.
+
+# Name executed as
+myname="${0##*/}"
+
+# We must specify a single directory name, nothing else.
+if [ $# -ne 2 ]
+then
+    1>&2 echo "$myname: expecting directory and output file"
+    exit 2
+fi
+
+# Change to the directory, die if we can't
+cd "$1" || exit 2
+
+# Do some sanity checks.
+for i in data control
+do
+    if [ ! -d "$i" ]
+    then
+        1>&2 echo "$myname: '$1/$i', no such directory"
+        exit 2
+    fi
+done
+
+# If there is no debian-binary file, make one.
+dbin="debian-binary"
+if [ ! -e "$dbin" ]
+then
+    1>&2 echo "$myname: warning - '$dbin' does not exist, creating it"
+    echo "2.0" > "$dbin" || exit 1
+fi
+
+# Remember where we are, and bail on errors
+set -e
+
+# Process data
+cd data
+find . -type f -print0 | xargs -0 md5sum > ../control/md5sums
+tar -c -z --owner=0 --group=0 -f ../data.tar.gz *
+
+# Process control
+cd ../control
+tar -c -z --owner=0 --group=0 -f ../control.tar.gz *
+
+# Finally, make deb file
+cd ..
+ar r "$2" "$dbin" control.tar.gz data.tar.gz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package-files/linux/deb/changelog	Thu Apr 30 21:22:30 2020 -0700
@@ -0,0 +1,7 @@
+jpegwasher (1.03) unstable; urgency=low
+
+  * 1.03 First Debian package for JpegWasher.
+
+ -- David Barts <opensource@bartsent.com>  Thu, 30 Apr 2020 13:16:43 -0700
+
+# This comment to make lintian happy.
--- a/package-files/linux/deb/control	Wed Apr 29 21:49:21 2020 -0700
+++ b/package-files/linux/deb/control	Thu Apr 30 21:22:30 2020 -0700
@@ -2,10 +2,12 @@
 Version: @app.version@
 Architecture: all
 Section: contrib/graphics
-Homepage: http://www.jedit.org/
+Homepage: http://notyouraveragetechie.com/JpegWasher.html
 Recommends: default-jre | openjdk-8-jre
 Build-depends: default-jdk | openjdk-8-jdk, ant
 Suggests: default-jdk | openjdk-8-jdk
 Priority: optional
 Installed-Size: @deb.installed.size@
 Description: Removes privacy-compromising metadata from digital photos.
+ This dummy line here to make lintian happy.
+Maintainer: David Barts <opensource@bartsent.com>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package-files/linux/deb/copyright	Thu Apr 30 21:22:30 2020 -0700
@@ -0,0 +1,13 @@
+    Copyright © 2020, David W. Barts.
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    See: /usr/share/common-licenses/GPL-3
--- a/package-files/linux/deb/jpegwasher.desktop	Wed Apr 29 21:49:21 2020 -0700
+++ b/package-files/linux/deb/jpegwasher.desktop	Thu Apr 30 21:22:30 2020 -0700
@@ -4,11 +4,10 @@
 GenericName=Privacy for your photos
 Comment=Removes privacy-compromising metadata
 Exec=jpegwasher
-Icon=/usr/share/jpegwasher/doc/jpegwasher.png
+Icon=jpegwasher
 Terminal=false
 Type=Application
 Categories=Graphics;Photography;Security;
 StartupNotify=true
-MimeType=image/jpeg;
 StartupWMClass=jpegwasher
 Keywords=Metadata;Remove;JPEG;Privacy
--- a/package-files/linux/deb/postinst	Wed Apr 29 21:49:21 2020 -0700
+++ b/package-files/linux/deb/postinst	Thu Apr 30 21:22:30 2020 -0700
@@ -1,3 +1,3 @@
 #!/bin/sh
 set -e
-if [ "$1" = "configure" ] && [ -x /usr/bin/update-menus ]; then update-menus ; fi
+if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi
Binary file package-files/linux/icon_48x48.png has changed
--- a/package-files/linux/jpegwasher	Wed Apr 29 21:49:21 2020 -0700
+++ b/package-files/linux/jpegwasher	Thu Apr 30 21:22:30 2020 -0700
@@ -22,4 +22,4 @@
 ANTIALIAS_ALL="-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true"
 
 # Launch application.
-exec "${JAVA}" ${ANTIALIAS_ALL} -jar "/usr/share/JpegWasher/jars/@jar.filename@"
+exec "${JAVA}" ${ANTIALIAS_ALL} -jar "/usr/share/jpegwasher/@jar.filename@"