[lintian] 01/04: c/menu*: Remove the use of "menu-files" collection
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 23edd1fa5e0243dd77b06d17a0dda6fa426e9f05
Author: Niels Thykier <niels@thykier.net>
Date: Tue Sep 30 19:43:52 2014 +0200
c/menu*: Remove the use of "menu-files" collection
We now always have unpacked available, so "menu-files" do not really
provide us with an advantage.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
checks/menu-format.desc | 2 +-
checks/menu-format.pm | 24 ++++++++++--------------
checks/menus.desc | 2 +-
checks/menus.pm | 19 +++++++++----------
4 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index 6f9e583..1fd9ab2 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -1,7 +1,7 @@
Check-Script: menu-format
Author: Joey Hess <joeyh@master.debian.org>
Abbrev: mnf
-Needs-Info: unpacked, menu-files
+Needs-Info: unpacked
Type: binary
Info: This script validates the format of <b>menu</b> files.
diff --git a/checks/menu-format.pm b/checks/menu-format.pm
index 1819f4c..914f942 100644
--- a/checks/menu-format.pm
+++ b/checks/menu-format.pm
@@ -42,7 +42,6 @@ use List::MoreUtils qw(any);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(is_ancestor_of);
# This is a list of all tags that should be in every menu item.
my @req_tags = qw(needs section title command);
@@ -157,10 +156,10 @@ sub run {
my ($pkg, $type, $info, $proc, $group) = @_;
my $mdir = $info->lab_data_path('menu');
my @menufiles;
- for my $dir ("$mdir/lib", "$mdir/share") {
- opendir(my $dirfd, $dir);
- push(@menufiles, map { "$dir/$_" } readdir($dirfd));
- closedir($dirfd);
+ for my $dirname (qw(usr/share/menu/ usr/lib/menu/)) {
+ if (my $dir = $info->index_resolved_path($dirname)) {
+ push(@menufiles, $dir->children);
+ }
}
# Find the desktop files in the package for verification.
@@ -189,18 +188,15 @@ sub run {
# Now all the menu files.
foreach my $menufile (@menufiles) {
- next if -x $menufile; # don't try to parse executables
-
- my $basename = basename $menufile;
- my $fullname = "usr/share/menu/$basename";
- $fullname = "usr/lib/menu/$basename"
- if $menufile =~ m,^\Q$mdir\E/lib/,;
+ # Do not try to parse executables
+ next if $menufile->is_executable or not $menufile->is_open_ok;
- next if $basename eq 'README'; # README is a special case
- next if !is_ancestor_of($mdir, $menufile);
+ my $fullname = $menufile->name;
+ # README is a special case
+ next if $menufile->basename eq 'README';
my $menufile_line ='';
- open(my $fd, '<', $menufile);
+ my $fd = $menufile->open;
# line below is commented out in favour of the while loop
# do { $_=<IN>; } while defined && (m/^\s* \#/ || m/^\s*$/);
while (<$fd>) {
diff --git a/checks/menus.desc b/checks/menus.desc
index d09dab0..8d85427 100644
--- a/checks/menus.desc
+++ b/checks/menus.desc
@@ -4,7 +4,7 @@ Abbrev: men
Type: binary
Info: Check if a binary package conforms to policy with respect to
<b>menu</b> and <b>doc-base</b> files.
-Needs-Info: doc-base-files, menu-files, bin-pkg-control, unpacked
+Needs-Info: doc-base-files, bin-pkg-control, unpacked
Tag: maintainer-script-does-not-check-for-existence-of-updatemenus
Severity: important
diff --git a/checks/menus.pm b/checks/menus.pm
index 6c370ee..32adf6f 100644
--- a/checks/menus.pm
+++ b/checks/menus.pm
@@ -113,20 +113,19 @@ sub run {
# the menu manual
my $menumethod_includes_menu_h = 0;
- my $local_file = $file;
- $local_file =~ s,^etc/menu-methods/,,;
$menumethod_file = $file;
- open(my $fd, '<',
- $info->lab_data_path("menu/methods/$local_file"));
- while (<$fd>) {
- chomp;
- if (m,^!include menu.h,o) {
- $menumethod_includes_menu_h = 1;
- last;
+ if ($file->is_open_ok) {
+ my $fd = $file->open;
+ while (<$fd>) {
+ chomp;
+ if (m,^!include menu.h,o) {
+ $menumethod_includes_menu_h = 1;
+ last;
+ }
}
+ close($fd);
}
- close($fd);
tag 'menu-method-should-include-menu-h', $file
unless $menumethod_includes_menu_h
or $pkg eq 'menu';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: