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

Re: menu enhancements



Attached is the new patch with a couple of corrections and the following
three new tags:

* desktop-command-with-path: same as the menu- version of the check
* desktp-contains-deprecated-header: check for [KDE Desktop Entry]
* deprecated-kdelnk-file: check for .kdelnk files (but don't syntax-check
them as .desktop files)

Cheers,
-- 
Atomo64 - Raphael

Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
diff --git a/checks/menu-format b/checks/menu-format
index ecd2d7b..b45152f 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -407,6 +407,8 @@ while (<IN>) {
     my $operm = perm2oct($perm);
     $file_index{$file} = 1;
 
+    tag 'deprecated-kdelnk-file', "$file" if ($file =~ m,\.kdelnk$,);
+
     if ($perm =~ m,^-, && $file =~ m,/usr/share/applications/.*\.desktop$,) {
         if ($perm =~ m,x,o) {
             tag "executable-desktop-file", sprintf("$file %04o",$operm);
@@ -626,6 +628,11 @@ sub VerifyLine {
                 or ($tested_packages >= 2)
                 or ($section =~ m:^(WindowManagers/Modules|FVWM Modules|Window Maker):));
 
+    if ($vals{'command'} =~ m,^(/(?:usr/)?bin/\w+),
+        || ($command && $command =~ m,^(/(?:usr/)?bin/\w+),)) {
+        tag 'menu-command-with-path', "$fullname:$linecount $1";
+    }
+
     if (exists($vals{'icon'})) {
 	VerifyIcon($menufile, $fullname, $linecount, $vals{'icon'}, 32);
     }
@@ -760,8 +767,9 @@ sub VerifyDesktopFile {
         # ignore any keys in other groups.
         last if ($saw_first and $line =~ /^\[(.*)\]\s*$/);
         unless ($saw_first) {
-            return unless $line =~ /^\[Desktop Entry\]\s*$/;
+            return unless $line =~ /^\[(KDE )?Desktop Entry\]\s*$/;
             $saw_first = 1;
+            tag 'desktp-contains-deprecated-header', "$file:$." if ($line =~ /^\[KDE Desktop Entry\]\s*$/);
         }
 
 	# Tag = Value.	For most errors, just add the error to pending rather
@@ -818,6 +826,10 @@ sub VerifyDesktopFile {
         my ($okay, $command) = VerifyCmd ($file, undef, $vals{'Exec'}, $pkg);
         tag "desktop-command-not-in-package", "$file $command"
             unless $okay or $command eq 'kcmshell';
+        if ($vals{'Exec'} =~ m,^(/(?:usr/)?s?bin/\w+),
+            || ($command && $command =~ m,^(/(?:usr/)?bin/\w+),)) {
+            tag 'desktop-command-with-path', "$file: $1";
+        }
     }
 
     # Check the Category tag.
@@ -895,7 +907,7 @@ sub VerifyCmd {
     } else {
         $cmd = $com[0];
     }
-    my $okay = $cmd && ($cmd =~ /^[\'\"]/ || $file_index{$cmd} || grep { $file_index{$_ . $cmd} } @path);
+    my $okay = $cmd && ($cmd =~ /^[\'\"]/ || $file_index{$cmd} || $cmd =~ m,^(/bin/)?sh, || $cmd =~ m,^(/usr/bin/)?sensible-(pager|editor|browser), || grep { $file_index{$_ . $cmd} } @path);
     return ($okay, $cmd);
 }
 
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index d1f6d65..500ce27 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -270,3 +270,30 @@ Info: The desktop entry specifies a command that is not available in the
  desktop file after the install location of the binary was changed.  A
  desktop file for a command should be included in the same package as that
  command.
+
+Tag: menu-command-with-path
+Type: warning
+Info: The menu command entry has a prepended path. Programs called from menu
+ files normally should not have a path prepended. Prepending a path may prevent
+ the local administrator or user from using a replacement version of a command
+ for some local reason.
+
+Tag: desktop-command-with-path
+Type: warning
+Info: The desktop Exec entry has a prepended path. Programs called from desktop
+ files normally should not have a path prepended. Prepending a path may prevent
+ the local administrator or user from using a replacement version of a command
+ for some local reason.
+
+Tag: desktp-contains-deprecated-header
+Type: warning
+Info: The header on this line of the desktop entry has been deprecated in the
+ FreeDesktop specification.
+Ref: http://standards.freedesktop.org/desktop-entry-spec/1.0/apc.html
+
+Tag: deprecated-kdelnk-file
+Type: error
+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
diff --git a/testset/binary/debian/hello.desktop b/testset/binary/debian/hello.desktop
index 4f4a865..331f4b1 100644
--- a/testset/binary/debian/hello.desktop
+++ b/testset/binary/debian/hello.desktop
@@ -1,11 +1,11 @@
 # some random comment
 
 # [Foo Bar]
-[Desktop Entry]
+[KDE Desktop Entry]
 Name=Hello
 Name[en_US]=Hello
 Comment=Say hello!

-Exec=kdesu hello
+Exec=/usr/bin/kdesu hello
 Icon=hello
 Terminal=true
 Type=Application
diff --git a/testset/binary/debian/menu b/testset/binary/debian/menu
index 652381a..e8972f4 100644
--- a/testset/binary/debian/menu
+++ b/testset/binary/debian/menu
@@ -23,3 +23,4 @@
 ?package(binary):needs="fvwmmodule" section="Window Maker" title="Fake Module"\
  command="hello"
 ?package(binary):needs="x11" section="Applications/System/Hardware" title="Run xfdisk" command="su-to-root -c 'xfdisk -f'"
+?package(binary):needs="text" section="Applications/System/Administration" title="foo" command="sh /path/to/foo"
diff --git a/testset/binary/debian/rules b/testset/binary/debian/rules
index 33d83f6..9ed885d 100755
--- a/testset/binary/debian/rules
+++ b/testset/binary/debian/rules
@@ -58,6 +58,8 @@ binary-arch: build
 	install -d $(tmp)/usr/share/applications
 	install -m 644 debian/hello.desktop \
 	    $(tmp)/usr/share/applications/hello.desktop
+	install -m 644 debian/hello.desktop \
+	    $(tmp)/usr/share/applications/hello.kdelnk
 	install -m 755 debian/goodbye.desktop \
 	    $(tmp)/usr/share/applications/goodbye.desktop
 
diff --git a/testset/tags.binary b/testset/tags.binary
index 7819d9c..41bb2a5 100644
--- a/testset/tags.binary
+++ b/testset/tags.binary
@@ -2,6 +2,7 @@ E: binary source: debian-rules-missing-required-target binary-indep
 E: binary: debian-changelog-file-missing-or-wrong-name
 E: binary: debian-news-file-uses-obsolete-national-encoding at line 3
 E: binary: depends-on-x-metapackage pre-depends: xorg
+E: binary: deprecated-kdelnk-file /usr/share/applications/hello.kdelnk
 E: binary: desktop-entry-missing-required-key /usr/share/applications/goodbye.desktop Name
 E: binary: doc-base-document-field-ends-in-whitespace binary:1
 E: binary: doc-base-file-duplicated-format binary:36 html
@@ -73,11 +74,13 @@ W: binary: debian-copyright-file-uses-obsolete-national-encoding at line 13
 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
+W: binary: desktop-command-with-path /usr/share/applications/hello.desktop: /usr/bin/kdesu
 W: binary: desktop-entry-contains-unknown-key /usr/share/applications/goodbye.desktop:5 SpecialTag
 W: binary: desktop-entry-contains-unknown-key /usr/share/applications/goodbye.desktop:7 icon
 W: binary: desktop-entry-file-has-crs /usr/share/applications/hello.desktop:7
 W: binary: desktop-entry-invalid-category WeirdStuff /usr/share/applications/goodbye.desktop
 W: binary: desktop-entry-uses-reserved-category Screensaver /usr/share/applications/goodbye.desktop
+W: binary: desktp-contains-deprecated-header /usr/share/applications/hello.desktop:4
 W: binary: doc-base-abstract-field-separator-extra-whitespaces binary:7
 W: binary: doc-base-file-unknown-format binary:20 esp
 W: binary: doc-base-unknown-section binary:11 Non/Existant
@@ -95,6 +98,10 @@ W: binary: menu-command-not-in-package /usr/share/menu/binary:18 imnothere
 W: binary: menu-command-not-in-package /usr/share/menu/binary:20 cfdisk
 W: binary: menu-command-not-in-package /usr/share/menu/binary:4 xfdisk
 W: binary: menu-command-not-in-package /usr/share/menu/binary:7 /imnothere
+W: binary: menu-command-with-path /usr/lib/menu/binary:2 /usr/bin/su
+W: binary: menu-command-with-path /usr/lib/menu/binary:21 /usr/bin/hello
+W: binary: menu-command-with-path /usr/share/menu/binary:2 /usr/bin/su
+W: binary: menu-command-with-path /usr/share/menu/binary:21 /usr/bin/hello
 W: binary: menu-file-in-usr-lib usr/lib/menu/binary
 W: binary: menu-item-creates-new-section Applications/System /usr/lib/menu/binary:2
 W: binary: menu-item-creates-new-section Applications/System /usr/share/menu/binary:2


Reply to: