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

[lintian] 01/03: c/menu-format.pm: Refactor the loop for finding desktop files



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

nthykier pushed a commit to branch master
in repository lintian.

commit 7f5601ba991dfd65971e0c4268e25589d34524fc
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Oct 25 16:24:16 2014 +0200

    c/menu-format.pm: Refactor the loop for finding desktop files
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/menu-format.pm | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/checks/menu-format.pm b/checks/menu-format.pm
index 914f942..062d384 100644
--- a/checks/menu-format.pm
+++ b/checks/menu-format.pm
@@ -154,7 +154,6 @@ my %needs_tag_vals_hash = map { $_ => 1 } @needs_tag_vals;
 
 sub run {
     my ($pkg, $type, $info, $proc, $group) = @_;
-    my $mdir = $info->lab_data_path('menu');
     my @menufiles;
     for my $dirname (qw(usr/share/menu/ usr/lib/menu/)) {
         if (my $dir = $info->index_resolved_path($dirname)) {
@@ -162,21 +161,25 @@ sub run {
         }
     }
 
+    for my $file ($info->sorted_index) {
+        tag 'deprecated-kdelnk-file', $file
+          if ($file->basename =~ m,\.kdelnk$,);
+    }
+
     # Find the desktop files in the package for verification.
     my @desktop_files;
-    foreach my $file ($info->sorted_index) {
-        my $operm = $file->operm;
-
-        tag 'deprecated-kdelnk-file', $file if ($file =~ m,\.kdelnk$,);
-
-        if (   $file->is_file
-            && $file =~ m,^usr/share/(?:applications|xsessions)/.*\.desktop$,){
-
-            if ($operm & 0111) {
-                tag 'executable-desktop-file', sprintf('%s %04o',$file,$operm);
-            }
-            unless ($file =~ m,template,o) {
-                push(@desktop_files, $file);
+    for my $subdir (qw(applications xsessions)) {
+        if (my $dir = $info->index("usr/share/$subdir/")) {
+            for my $file ($dir->children) {
+                next unless $file->is_file;
+                next unless $file->basename =~ m/\.desktop$/;
+                if ($file->is_executable) {
+                    tag 'executable-desktop-file',
+                      sprintf('%s %04o',$file, $file->operm);
+                }
+                if (index($file, 'template') == -1) {
+                    push(@desktop_files, $file);
+                }
             }
         }
     }

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


Reply to: