[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.1.3-9-g1bd2c3a



The following commit has been merged in the master branch:
commit dd0d451497eac3887260bd43ded48b9fbe5fdc17
Author: Russ Allbery <rra@debian.org>
Date:   Sun Dec 28 19:57:30 2008 -0800

    Check for update-desktop-database calls with MimeType keys
    
    * checks/menu-format{,.desc}:
      + [RA] If a *.desktop file contains a MimeType key, check that the
        postinst calls update-desktop-database.  (Closes: #488832)
    * checks/rules{,.desc}:
      + [RA] Remove desktop-file-but-no-dh_desktop-call.  The only action of
        dh_desktop is now checked by desktop-mimetype-without-update-call;
        dh_desktop is unnecessary with other *.desktop files.

diff --git a/checks/menu-format b/checks/menu-format
index 8518811..5c71249 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -378,6 +378,9 @@ my %sections_hash = map { $_ => 1 } @sections;
 # Holds a hash of all files in the package, used for checking for executables.
 my %file_index;
 
+# Whether the postinst script calls update-desktop-database.
+my $postinst_calls_update;
+
 # -----------------------------------
 
 sub run {
@@ -419,6 +422,20 @@ foreach my $file (sort keys %{$info->index}) {
     }
 }
 
+# If we saw any desktop files, we may want to know whether postinst calls
+# update-desktop-database.
+if (@desktop_files) {
+    $postinst_calls_update = 0;
+    if (open(IN, '<', "control/postinst")) {
+	local $_;
+	while (<IN>) {
+	    next if /^\s*\#/;
+	    $postinst_calls_update = 1 if /\bupdate-desktop-database\b/;
+	}
+    }
+    close IN;
+}
+
 # Verify all the desktop files.
 for my $desktop_file (@desktop_files) {
     VerifyDesktopFile ($desktop_file, $desktop_file, $pkg);
@@ -842,6 +859,12 @@ sub VerifyDesktopFile {
             tag "desktop-entry-lacks-main-category", "$file";
         }
     }
+
+    # If there is a MimeType key, the package should call
+    # update-desktop-database in the postinst.
+    if ($vals{'MimeType'} and not $postinst_calls_update) {
+	tag "desktop-mimetype-without-update-call", $file;
+    }
 }
 
 # Verify whether a command is shipped as part of the package.  Takes the full
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index c5578f4..70e739a 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -331,3 +331,17 @@ Info: kdelnk files were used by KDE 1 and since KDE 2 desktop files are used
  instead.  Renaming the file and removing the deprecated header and keys
  is often all that needs to be done.
 Ref: http://standards.freedesktop.org/desktop-entry-spec/1.0/apc.html
+
+Tag: desktop-mimetype-without-update-call
+Severity: minor
+Certainty: certain
+Info: Your package installs a .desktop file which contains a
+ <tt>MimeType</tt> setting, but it doesn't call
+ <tt>update-desktop-database</tt> in the package <tt>postinst</tt>
+ maintainer script.  This program updates the MIME type cache and should
+ be called whenever installing a package with a new <tt>MimeType</tt>
+ registration.
+ .
+ If you are using debhelper, you can add the necessary fragment to your
+ <tt>postinst</tt> by calling <tt>dh_desktop</tt> in
+ <tt>debian/rules</tt>.
diff --git a/checks/rules b/checks/rules
index cedc6a4..72ed9dc 100644
--- a/checks/rules
+++ b/checks/rules
@@ -165,15 +165,6 @@ unless ($includes) {
 	tag "debian-rules-missing-required-target", $target
 	    unless $seen{$target};
     }
-
-    #check if we should have seen some dh_ calls:
-    if (Dep::implies($build_deps, Dep::parse("debhelper"))) {
-        #.desktop files usually imply dh_desktop:
-	if (scalar @{[glob("debfiles/*.desktop")]} &&
-	    ! grep { /^\s*(dh_desktop|dh\s+.*(\$\@|binary))/ } map { @$_ } values %rules_per_target) {
-	    tag "desktop-file-but-no-dh_desktop-call";
-	}
-    }
 }
 
 # Make sure we have no content for binary-arch if we are arch-indep:
diff --git a/checks/rules.desc b/checks/rules.desc
index 323ef2a..6c36658 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -92,13 +92,6 @@ Info: It looks like you try to run code in the binary-arch target of
  <tt>debian/rules</tt>, even though your package is architecture-
  independent.
 
-Tag: desktop-file-but-no-dh_desktop-call
-Severity: minor
-Certainty: certain
-Info: It looks like your package includes a .desktop file and you use
- debhelper to build it, but you don't call dh_desktop in your rules
- file.
-
 Tag: debian-rules-calls-debhelper-in-odd-order
 Severity: normal
 Certainty: certain
diff --git a/debian/changelog b/debian/changelog
index 6aad5af..204d326 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,12 +5,21 @@ lintian (2.1.4) UNRELEASED; urgency=low
       - control-interpreter-in-usr-local (split from
          interpreter-in-usr-local)
       - control-interpreter-without-depends
+      - desktop-mimetype-without-update-call
       - forbidden-postrm-interpreter
       - preinst-interpreter-without-predepends
       - unknown-control-interpreter (split from unusual-interpreter)
     + Removed
+      - desktop-file-but-no-dh_desktop-call
       - interpreter-without-predep
 
+  * checks/menu-format{,.desc}:
+    + [RA] If a *.desktop file contains a MimeType key, check that the
+      postinst calls update-desktop-database.  (Closes: #488832)
+  * checks/rules{,.desc}:
+    + [RA] Remove desktop-file-but-no-dh_desktop-call.  The only action of
+      dh_desktop is now checked by desktop-mimetype-without-update-call;
+      dh_desktop is unnecessary with other *.desktop files.
   * checks/scripts{,.desc}:
     + [RA] Overhaul checking of maintainer script and config interpreters:
       - postrm scripts must use an essential interpreter.
diff --git a/t/tests/6000_menu-format-desktop-mimetype.desc b/t/tests/6000_menu-format-desktop-mimetype.desc
new file mode 100644
index 0000000..b1befe7
--- /dev/null
+++ b/t/tests/6000_menu-format-desktop-mimetype.desc
@@ -0,0 +1,6 @@
+Testname: menu-format-desktop-mimetype
+Version: 1.0
+Section: doc
+Description: Check update-desktop-detabase and MimeType *.desktop
+Test-For: desktop-mimetype-but-no-update-call
+References: Debian Bug#488832
diff --git a/t/tests/menu-format-desktop-mimetype/debian/debian/install b/t/tests/menu-format-desktop-mimetype/debian/debian/install
new file mode 100644
index 0000000..92cb649
--- /dev/null
+++ b/t/tests/menu-format-desktop-mimetype/debian/debian/install
@@ -0,0 +1 @@
+foo.desktop usr/share/applications
diff --git a/t/tests/menu-format-desktop-mimetype/debian/debian/postinst b/t/tests/menu-format-desktop-mimetype/debian/debian/postinst
new file mode 100644
index 0000000..0f2e47e
--- /dev/null
+++ b/t/tests/menu-format-desktop-mimetype/debian/debian/postinst
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# This script is here without a debhelper token so that dh_desktop won't
+# add the update-desktop-database call whose absence we're checking for.
+# Also check that the above comment doesn't fool us.
+
+set -e
+run something
diff --git a/t/tests/menu-format-desktop-mimetype/debian/foo.desktop b/t/tests/menu-format-desktop-mimetype/debian/foo.desktop
new file mode 100644
index 0000000..60a3552
--- /dev/null
+++ b/t/tests/menu-format-desktop-mimetype/debian/foo.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=GNU Foo
+GenericName=Foo
+Comment=A foo test entry for Lintian
+Type=Application
+Categories=Game;BoardGame;GTK;
+MimeType=application/foo;
diff --git a/t/tests/menu-format-desktop-mimetype/tags b/t/tests/menu-format-desktop-mimetype/tags
new file mode 100644
index 0000000..f49d105
--- /dev/null
+++ b/t/tests/menu-format-desktop-mimetype/tags
@@ -0,0 +1 @@
+W: menu-format-desktop-mimetype: desktop-mimetype-without-update-call /usr/share/applications/foo.desktop

-- 
Debian package checker


Reply to: