Package: mime-support
Severity: normal

Hi,

On 28/08/10 02:16, Charles Plessy wrote:
> By the way, wouldn't mime-support be a good candidate for declaring dpkg
> triggers?

I thought about that a while ago, and even prepared a patch for it.
I can't recall why I didn't submit it, but here it goes.

Regards,
Emilio


diff -Nru mime-support-3.44/debian/changelog mime-support-3.45/debian/changelog
--- mime-support-3.44/debian/changelog  2008-06-18 15:44:04.000000000 +0200
+++ mime-support-3.45/debian/changelog  2009-02-16 19:47:49.000000000 +0100
@@ -1,3 +1,10 @@
+mime-support (3.45) UNRELEASED; urgency=low
+
+  * Add dpkg triggers support to update-mime, and skip calls to it from
+    dpkg if they don't have --force.
+
+ -- Emilio Pozuelo Monfort <[email protected]>  Thu, 12 Feb 2009 14:19:15 +0100
+
 mime-support (3.44-1) unstable; urgency=medium
 
   * added new mime.types (closes: 485863, 485929, 472262)
diff -Nru mime-support-3.44/debian/postinst mime-support-3.45/debian/postinst
--- mime-support-3.44/debian/postinst   2008-06-05 14:33:36.000000000 +0200
+++ mime-support-3.45/debian/postinst   2009-02-16 19:20:06.000000000 +0100
@@ -1,5 +1,10 @@
 #! /bin/sh -e
 
+# dpkg triggers support for update-mime
+if [ "$1" = "triggered" ]; then
+    [ -x /usr/sbin/update-mime ] && update-mime --force
+    exit 0
+fi
 
 #if [ "$1" = "configure" ]; then
 #fi
@@ -18,5 +23,5 @@
 
 # Run the update program
 if [ -x /usr/sbin/update-mime ]; then
-    update-mime
+    update-mime --force
 fi
diff -Nru mime-support-3.44/debian/rules mime-support-3.45/debian/rules
--- mime-support-3.44/debian/rules      2008-06-05 14:39:42.000000000 +0200
+++ mime-support-3.45/debian/rules      2009-02-12 14:22:52.000000000 +0100
@@ -49,6 +49,7 @@
        install -m 755 debian/postinst          debian/tmp/DEBIAN/postinst
        install -m 755 debian/prerm             debian/tmp/DEBIAN/prerm
        install -m 644 debian/conffiles         debian/tmp/DEBIAN/conffiles
+       install -m 644 debian/triggers          debian/tmp/DEBIAN/triggers
        cd debian/tmp/usr/share/man; gzip -9fv */*
        cd debian/tmp/usr/share/doc/$(package); gzip -9v *
        cd debian/tmp/usr/share/doc/$(package); gunzip copyright.gz
diff -Nru mime-support-3.44/debian/triggers mime-support-3.45/debian/triggers
--- mime-support-3.44/debian/triggers   1970-01-01 01:00:00.000000000 +0100
+++ mime-support-3.45/debian/triggers   2009-02-12 14:20:39.000000000 +0100
@@ -0,0 +1 @@
+interest /usr/lib/mime/packages
diff -Nru mime-support-3.44/update-mime mime-support-3.45/update-mime
--- mime-support-3.44/update-mime       2008-01-01 16:59:30.000000000 +0100
+++ mime-support-3.45/update-mime       2009-02-16 19:20:36.000000000 +0100
@@ -15,6 +15,18 @@
 umask(022);
 
 
+# If the call comes from dpkg, only accept it if --force is passed
+# This is so that we don't get useless calls from packages' postinsts
+# that call update-mime due to dh_installmime adding that call for
+# when there was no triggers support.
+#
+# When this 'hack' is removed, mime-support's postinst should be updated
+# to not pass --force anymore in 'triggered'.
+
+if ("$ENV{'DPKG_RUNNING_VERSION'}" ne "" && "$ARGV[0]" ne "--force") {
+       exit (0);
+}
+
 
 #
 # Program Constants



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to