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

[lintian] 01/01: c/menu-format: Add tag to help enforce CTTE#741573



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit b66a41b75675cc766c5159c0a259a80b32ea4157
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Sep 20 22:06:39 2015 +0200

    c/menu-format: Add tag to help enforce CTTE#741573
    
    Per the verdict in [CTTE#741573], a package is now "prohibited" from
    having a menu file and a desktop file for the same command.  Add a
    check for that.
    
    [CTTE#741573]: https://lists.debian.org/debian-devel-announce/2015/09/msg00000.html
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/menu-format.desc                            | 10 ++++++++
 checks/menu-format.pm                              | 29 ++++++++++++++++------
 debian/changelog                                   |  4 +++
 t/tests/legacy-binary/tags                         |  8 ++++++
 .../debian/debian/menu-section.install             |  1 +
 t/tests/menu-format-general/debian/pargs.desktop   |  7 ++++++
 t/tests/menu-format-general/desc                   |  1 +
 t/tests/menu-format-general/tags                   |  5 ++++
 8 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index 9ee6c78..93b75d5 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -399,3 +399,13 @@ Info: This desktop entry uses OnlyShowIn to limit the environments in
  LXDE where it would work fine.  If this application supports any desktop
  environment except some specific ones, it should list the unsupported
  environments in the NotShowIn key instead.
+
+Tag: command-in-menu-file-and-desktop-file
+Severity: normal
+Certainty: possible
+Info: The command is listed both in a menu file and a desktop file
+ .
+ Per the tech-ctte decision on #741573, this is now prohibited.
+ .
+ Please remove the reference from the menu file.
+Ref: https://lists.debian.org/debian-devel-announce/2015/09/msg00000.html
diff --git a/checks/menu-format.pm b/checks/menu-format.pm
index 3d38361..3c4644e 100644
--- a/checks/menu-format.pm
+++ b/checks/menu-format.pm
@@ -154,7 +154,7 @@ my %needs_tag_vals_hash = map { $_ => 1 } @needs_tag_vals;
 
 sub run {
     my ($pkg, $type, $info, $proc, $group) = @_;
-    my @menufiles;
+    my (@menufiles, %desktop_cmds);
     for my $dirname (qw(usr/share/menu/ usr/lib/menu/)) {
         if (my $dir = $info->index_resolved_path($dirname)) {
             push(@menufiles, $dir->children);
@@ -181,7 +181,7 @@ sub run {
 
     # Verify all the desktop files.
     for my $desktop_file (@desktop_files) {
-        verify_desktop_file($desktop_file, $pkg, $info);
+        verify_desktop_file($desktop_file, $pkg, $info, \%desktop_cmds);
     }
 
     # Now all the menu files.
@@ -233,15 +233,17 @@ sub run {
             # This is caught by verify_line().
             if (!($menufile_line =~ m/\\\s*?$/)) {
                 verify_line(
-                    $pkg, $info, $proc, $group, $type,
-                    $menufile, $fullname, $line, $lc
+                    $pkg, $info, $proc, $group,
+                    $type,$menufile, $fullname, $line,
+                    $lc,\%desktop_cmds
                 );
                 $line='';
             }
         } while ($menufile_line = <$fd>);
         verify_line(
-            $pkg, $info, $proc, $group, $type,
-            $menufile, $fullname, $line, $lc
+            $pkg, $info, $proc, $group,
+            $type,$menufile, $fullname, $line,
+            $lc,\%desktop_cmds
         );
 
         close($fd);
@@ -257,7 +259,7 @@ sub run {
 sub verify_line {
     my (
         $pkg, $info, $proc, $group, $type,
-        $menufile, $fullname, $line, $linecount
+        $menufile, $fullname, $line, $linecount,$desktop_cmds
     ) = @_;
 
     my %vals;
@@ -401,6 +403,14 @@ sub verify_line {
         or
         ($section =~ m:^(WindowManagers/Modules|FVWM Modules|Window Maker):));
 
+    if (defined($command)) {
+        $command =~ s@^(?:usr/)?s?bin/@@;
+        if ($desktop_cmds->{$command}) {
+            tag 'command-in-menu-file-and-desktop-file', $command,
+              "${fullname}:${linecount}";
+        }
+    }
+
     if (exists($vals{'icon'})) {
         verify_icon($info, $proc, $group, $menufile, $fullname, $linecount,
             $vals{'icon'}, 32);
@@ -551,7 +561,7 @@ sub verify_icon {
 
 # Syntax-checks a .desktop file.
 sub verify_desktop_file {
-    my ($file, $pkg, $info) = @_;
+    my ($file, $pkg, $info, $desktop_cmds) = @_;
     my ($saw_first, $warned_cr, %vals, @pending);
     my $fd = $file->open;
     while (my $line = <$fd>) {
@@ -649,6 +659,9 @@ sub verify_desktop_file {
         tag 'desktop-command-not-in-package', $file, $command
           unless $okay
           or $command eq 'kcmshell';
+        $command =~ s@^(?:usr/)?s?bin/@@;
+        $desktop_cmds->{$command} = 1
+          if $command !~ m/^(?:su-to-root|sux?|(?:gk|kde)su)$/;
     }
 
     # Check the Category tag.
diff --git a/debian/changelog b/debian/changelog
index c535d25..1766006 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,10 @@ lintian (2.5.38) UNRELEASED; urgency=medium
       original description.  (Closes: #797466)
   * checks/obsolete-sites.pm:
     + [AB] Stop at <>, $, or " when emitting URLs as tag parameter.
+  * checks/menu-format.{desc,pm}:
+    + [NT] Check for menu files used to provide a command also listed in
+      a desktop file.  This tag is based on the verdict in
+      [CTTE #741573].
   * checks/rules.desc:
     + [NT] Improve the wording of one of the tags based on feedback
       from Chris Lamb and Jakub Wilk.  (Closes: #796815)
diff --git a/t/tests/legacy-binary/tags b/t/tests/legacy-binary/tags
index 324f382..3d37085 100644
--- a/t/tests/legacy-binary/tags
+++ b/t/tests/legacy-binary/tags
@@ -79,6 +79,14 @@ W: binary: binary-without-manpage usr/bin/iminusrbin
 W: binary: binary-without-manpage usr/bin/static-hello
 W: binary: changelog-news-debian-mismatch distribution unstable != UNRELEASED
 W: binary: changelog-news-debian-mismatch urgency low != high
+W: binary: command-in-menu-file-and-desktop-file hello usr/lib/menu/binary:21
+W: binary: command-in-menu-file-and-desktop-file hello usr/lib/menu/binary:22
+W: binary: command-in-menu-file-and-desktop-file hello usr/lib/menu/binary:24
+W: binary: command-in-menu-file-and-desktop-file hello usr/lib/menu/binary:5
+W: binary: command-in-menu-file-and-desktop-file hello usr/share/menu/binary:21
+W: binary: command-in-menu-file-and-desktop-file hello usr/share/menu/binary:22
+W: binary: command-in-menu-file-and-desktop-file hello usr/share/menu/binary:24
+W: binary: command-in-menu-file-and-desktop-file hello usr/share/menu/binary:5
 W: binary: debian-news-entry-has-strange-distribution UNRELEASED
 W: binary: description-contains-homepage
 W: binary: desktop-command-not-in-package usr/share/applications/goodbye.desktop goodbye
diff --git a/t/tests/menu-format-general/debian/debian/menu-section.install b/t/tests/menu-format-general/debian/debian/menu-section.install
index 0df55d7..4cf0ec4 100644
--- a/t/tests/menu-format-general/debian/debian/menu-section.install
+++ b/t/tests/menu-format-general/debian/debian/menu-section.install
@@ -1 +1,2 @@
 pargs-section         usr/bin
+pargs.desktop         usr/share/applications
diff --git a/t/tests/menu-format-general/debian/pargs.desktop b/t/tests/menu-format-general/debian/pargs.desktop
new file mode 100644
index 0000000..a31e9bd
--- /dev/null
+++ b/t/tests/menu-format-general/debian/pargs.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=pargs
+Type=Application
+Comment=Argument Printer
+Categories=Development;
+Keywords=Argument;Printer;
+Exec=pargs-section
diff --git a/t/tests/menu-format-general/desc b/t/tests/menu-format-general/desc
index 084d031..d617b58 100644
--- a/t/tests/menu-format-general/desc
+++ b/t/tests/menu-format-general/desc
@@ -4,6 +4,7 @@ Version: 1.0
 Description: Test menu file tags
 Test-For:
  bad-test-in-menu-item
+ command-in-menu-file-and-desktop-file
  duplicated-tag-in-menu-item
  menu-command-not-in-package
  menu-icon-cannot-be-parsed
diff --git a/t/tests/menu-format-general/tags b/t/tests/menu-format-general/tags
index bf5aa1e..767df58 100644
--- a/t/tests/menu-format-general/tags
+++ b/t/tests/menu-format-general/tags
@@ -18,6 +18,11 @@ W: menu-none: menu-icon-uses-relative-path non-existent.xpm
 W: menu-none: menu-icon-uses-relative-path non-existent16.xpm
 W: menu-none: menu-icon-uses-relative-path non-existent32.xpm
 W: menu-none: menu-item-uses-icon-none usr/share/menu/menu-none:4
+W: menu-section: command-in-menu-file-and-desktop-file pargs-section usr/share/menu/menu-section:12
+W: menu-section: command-in-menu-file-and-desktop-file pargs-section usr/share/menu/menu-section:15
+W: menu-section: command-in-menu-file-and-desktop-file pargs-section usr/share/menu/menu-section:3
+W: menu-section: command-in-menu-file-and-desktop-file pargs-section usr/share/menu/menu-section:6
+W: menu-section: command-in-menu-file-and-desktop-file pargs-section usr/share/menu/menu-section:9
 W: menu-section: menu-item-creates-new-section Games usr/share/menu/menu-section:9
 W: menu-section: menu-item-creates-new-section WindowManagers/Programming usr/share/menu/menu-section:15
 W: menu-section: menu-item-uses-apps-games-section usr/share/menu/menu-section:6

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: