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

[SCM] Debian package checker branch, master, updated. 2.5.8-6-g8750202



The following commit has been merged in the master branch:
commit 875020209ec49dfb01400beccce7d0713b126795
Author: Niels Thykier <niels@thykier.net>
Date:   Tue Jun 5 01:23:18 2012 +0200

    checks/*: Migrate to new Lintian::Path API
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/apache2 b/checks/apache2
index 81dc52c..af75bd1 100644
--- a/checks/apache2
+++ b/checks/apache2
@@ -45,10 +45,10 @@ sub run {
     if ($type eq 'binary') {
         foreach my $file ($info->sorted_index) {
             next if $file eq '';
-            my $file_info = $info->index->{$file};
+            my $index_info = $info->index->{$file};
 
             # File is probably not relevant to us, ignore it
-            next if $file_info->{type} eq 'd';
+            next if $index_info->is_dir;
             next if $file !~ m#^(?:usr/lib/apache2/modules/|etc/apache2/)#;
 
 
diff --git a/checks/binaries b/checks/binaries
index 9769401..07a2b00 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -207,8 +207,8 @@ foreach ($info->sorted_index) {
     # create copy, don't modify the index
     my $path = $_;
 
-    my $ftype = $info->index->{$path}->{'type'};
-    next unless ($ftype eq 'd' || $ftype eq 'l');
+    my $index_info = $info->index->{$path};
+    next unless $index_info->is_dir || $index_info->is_symlink;
     $path =~ s,/\z,,;
     $directories{"/$path"}++;
 }
diff --git a/checks/changelog-file b/checks/changelog-file
index b24cb0c..c0e39f4 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -47,7 +47,7 @@ my %file_info;
 
 # skip packages which have a /usr/share/doc/$pkg -> foo symlink
 return 0 if $info->index->{"usr/share/doc/$pkg"} and
-    $info->index->{"usr/share/doc/$pkg"}->{type} eq 'l';
+    $info->index->{"usr/share/doc/$pkg"}->is_symlink;
 
 
 # Modify the file_info by following symbolic links.
@@ -118,7 +118,7 @@ foreach ($info->sorted_index) {
                 }
             }
             if (not $max_compressed and $file_info{$file1} =~ m/gzip compressed/) {
-                if ($info->index->{$file1}->{type} ne 'l') {
+                if (!$info->index->{$file1}->is_symlink) {
                     tag 'changelog-not-compressed-with-max-compression', $file;
                 }
             }
diff --git a/checks/conffiles b/checks/conffiles
index 78f1fc8..d669f35 100644
--- a/checks/conffiles
+++ b/checks/conffiles
@@ -76,7 +76,7 @@ if (-f $cf) {
 # Read package contents...
 foreach my $file ($info->sorted_index) {
     my $index_info = $info->index->{$file};
-    next unless $file =~ m,^etc, and $index_info->{type}=~ m/^[-h]/;
+    next unless $file =~ m,^etc, and $index_info->is_file;
 
     # If there is a /etc/foo, it must be a conffile (with a few exceptions).
     if (not exists($conffiles{$file})
diff --git a/checks/copyright-file b/checks/copyright-file
index c9944f6..b89543c 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -51,7 +51,7 @@ if (exists $info->index->{"$path/copyright.gz"}) {
 if (exists $info->index->{"$path/copyright"}) {
     my $index_info = $info->index->{"$path/copyright"};
     $found = 1;
-    if ($index_info->{type} eq 'l') {
+    if ($index_info->is_symlink) {
         tag 'copyright-file-is-symlink';
         $linked = 1;
         # Fall through here - coll/copyright-file protects us
@@ -61,8 +61,8 @@ if (exists $info->index->{"$path/copyright"}) {
 
 if (not $found) {
     my $index_info = $info->index->{$path};
-    if (defined $index_info && $index_info->{link}) {
-        my $link = $index_info->{link};
+    if (defined $index_info && $index_info->is_symlink) {
+        my $link = $index_info->link;
 
         # check if this symlink references a directory elsewhere
         if ($link =~ m,^(?:\.\.)?/,) {
diff --git a/checks/duplicate-files b/checks/duplicate-files
index ea0e919..5df3910 100644
--- a/checks/duplicate-files
+++ b/checks/duplicate-files
@@ -36,11 +36,11 @@ foreach my $file ($info->sorted_index){
     my $md5 = $info->md5sums->{$file};
     my $fs;
     next unless defined $md5;
-    next unless $info->index->{$file}->{type} eq '-';
+    next unless $info->index->{$file}->is_regular_file;
     # Ignore empty files; in some cases (e.g. python) a file is
     # required even if it is empty and we are never looking at a
     # substantial gain in such a case.  Also see #632789
-    next unless $info->index->{$file}->{size};
+    next unless $info->index->{$file}->size;
     next unless $file =~ m@usr/share/doc/@o;
     $fs = $hashmap{$md5};
     unless (defined $fs){
diff --git a/checks/fields b/checks/fields
index bcd52df..81679c0 100644
--- a/checks/fields
+++ b/checks/fields
@@ -522,7 +522,7 @@ my $metapackage = 0;
 if ($type eq 'binary') {
     $metapackage = 1;
     for my $file ($info->sorted_index) {
-        next if $info->index->{$file}->{type} =~ /^d/;
+        next if $info->index->{$file}->is_dir;
         next if $file =~ m%^usr/share/doc/%;
         next if $file =~ m%^usr/share/lintian/overrides/%;
         next if $file =~ m%^usr/share/cdd/%;
diff --git a/checks/files b/checks/files
index 01b4430..60b346d 100644
--- a/checks/files
+++ b/checks/files
@@ -263,13 +263,13 @@ if (!$is_dummy) {
 foreach my $file ($info->sorted_index) {
     next if $file eq '';
     my $index_info = $info->index->{$file};
-    my $owner = $index_info->{owner} . '/' . $index_info->{group};
-    my $operm = $index_info->{operm};
-    my $link = $index_info->{link};
+    my $owner = $index_info->owner . '/' . $index_info->group;
+    my $operm = $index_info->operm;
+    my $link = $index_info->link;
 
     $arch_dep_files = 1 if $file !~ m,^usr/share/,o && $file ne 'usr/';
 
-    if ($index_info->{type} eq 'h') {
+    if ($index_info->is_hardlink) {
         my $link_target_dir = $link;
         $link_target_dir =~ s,[^/]*$,,;
 
@@ -286,16 +286,16 @@ foreach my $file ($info->sorted_index) {
                 or $file !~ m,^\Q$link_target_dir\E[^/]*$,;
     }
 
-    my ($year) = ($index_info->{date} =~ /^(\d{4})/);
+    my ($year) = ($index_info->date =~ /^(\d{4})/);
     if ( $year <= 1984 ) { # value from dak CVS: Dinstall::PastCutOffYear
         tag 'package-contains-ancient-file', "$file " . $index_info->{date};
     }
 
-    if (!($index_info->{uid} < 100 || $index_info->{uid} == 65_534
-            || ($index_info->{uid} >= 60_000 && $index_info->{uid} < 65_000))
-            || !($index_info->{gid} < 100 || $index_info->{gid} == 65_534
-            || ($index_info->{gid} >= 60_000 && $index_info->{gid} < 65_000))) {
-        tag 'wrong-file-owner-uid-or-gid', $file, $index_info->{uid} . '/' . $index_info->{gid};
+    if (!($index_info->uid < 100 || $index_info->uid == 65_534
+            || ($index_info->uid >= 60_000 && $index_info->uid < 65_000))
+            || !($index_info->gid < 100 || $index_info->gid == 65_534
+            || ($index_info->gid >= 60_000 && $index_info->gid < 65_000))) {
+        tag 'wrong-file-owner-uid-or-gid', $file, $index_info->uid . '/' . $index_info->gid;
     }
 
     # *.devhelp and *.devhelp2 files must be accessible from a directory in
@@ -327,7 +327,7 @@ foreach my $file ($info->sorted_index) {
             tag 'bad-permissions-for-etc-cron.d-script', sprintf('%s %04o != 0644',$file,$operm);
         }
         # ---------------- /etc/emacs.*
-        elsif ($file =~ m,^etc/emacs.*/\S, and $index_info->{type} =~ m,^[-h],
+        elsif ($file =~ m,^etc/emacs.*/\S, and $index_info->is_file
                and $operm != 0644) {
             tag 'bad-permissions-for-etc-emacs-script', sprintf('%s %04o != 0644',$file,$operm);
         }
@@ -339,7 +339,7 @@ foreach my $file ($info->sorted_index) {
         elsif ($file =~ m,^etc/init\.d/\S,
                and $file !~ m,^etc/init\.d/(?:README|skeleton)$,
                and $operm != 0755
-               and $index_info->{type} =~ m,^[-h],) {
+               and $index_info->is_file) {
             tag 'non-standard-file-permissions-for-etc-init.d-script',
                 sprintf('%s %04o != 0755',$file,$operm);
         }
@@ -348,7 +348,7 @@ foreach my $file ($info->sorted_index) {
             tag 'package-modifies-ld.so-search-path', $file;
         }
         #----------------- /etc/modprobe.d
-        elsif ($file =~ m,^etc/modprobe\.d/(.+)$, and $1 !~ m,\.conf$, and $index_info->{type} !~ m/^d/) {
+        elsif ($file =~ m,^etc/modprobe\.d/(.+)$, and $1 !~ m,\.conf$, and !$index_info->is_dir) {
             tag 'non-conf-file-in-modprobe.d', $file;
         }
         #----------------- /etc/pam.conf
@@ -357,7 +357,7 @@ foreach my $file ($info->sorted_index) {
         }
         #----------------- /etc/php5/conf.d
         elsif ($file =~ m,^etc/php5/conf.d/.+\.ini$,) {
-            if ($index_info->{type} =~ m/^[-h]/) {
+            if ($index_info->is_file) {
                 open (PHPINI, '<', $info->unpacked($file)) or fail("cannot open .ini file: $!");
                 while (<PHPINI>) {
                     next unless (m/^\s*#/);
@@ -394,12 +394,12 @@ foreach my $file ($info->sorted_index) {
                 }
 
                 # file directly in /usr/share/doc ?
-                if ($index_info->{type} =~ m/^[-h]/ and $file =~ m,^usr/share/doc/[^/]+$,) {
+                if ($index_info->is_file and $file =~ m,^usr/share/doc/[^/]+$,) {
                     tag 'file-directly-in-usr-share-doc', $file;
                 }
 
                 # executable in /usr/share/doc ?
-                if ($index_info->{type} =~ m/^[-h]/ and
+                if ($index_info->is_file and
                     $file !~ m,^usr/share/doc/(?:[^/]+/)?examples/, and
                     ($operm & 0111)) {
                     if ($script{$file}) {
@@ -410,7 +410,7 @@ foreach my $file ($info->sorted_index) {
                 }
 
                 # zero byte file in /usr/share/doc/
-                if ($index_info->{size} == 0 and $index_info->{type} =~ m,^-,) {
+                if ($index_info->size == 0 and $index_info->is_regular_file) {
                     # Exceptions: examples may contain empty files for various
                     # reasons, Doxygen generates empty *.map files, and Python
                     # uses __init__.py to mark module directories.
@@ -422,8 +422,8 @@ foreach my $file ($info->sorted_index) {
                 }
                 # gzipped zero byte files:
                 # 276 is 255 bytes (maximal length for a filename) + gzip overhead
-                if ($file =~ m,.gz$, and $index_info->{size} <= 276
-                    and $index_info->{type} =~ m,^[-h],
+                if ($file =~ m,.gz$, and $index_info->size <= 276
+                    and $index_info->is_file
                     and $info->file_info->{$file} =~ m/gzip compressed/) {
                     my $f = quotemeta($info->unpacked($file));
                     unless (`gzip -dc $f`) {
@@ -455,7 +455,7 @@ foreach my $file ($info->sorted_index) {
 
         #----------------- /usr/X11R6/
         elsif ($file =~ m,^usr/X11R6/, and
-               $index_info->{type} !~ m,^l,) { #links to FHS locations are allowed
+               not $index_info->is_symlink) { #links to FHS locations are allowed
             tag 'package-installs-file-to-usr-x11r6', $file;
         }
 
@@ -467,7 +467,7 @@ foreach my $file ($info->sorted_index) {
                 $warned_debug_name = 1;
             }
 
-            if ($index_info->{type} =~ m/^[-h]/o &&
+            if ($index_info->is_file &&
                 $file =~ m,^usr/lib/debug/usr/lib/pyshared/(python\d?(?:\.\d+))/(.++)$,o){
                 my $correct = "usr/lib/debug/usr/lib/pymodules/$1/$2";
                 tag 'python-debug-in-wrong-location', $file, $correct;
@@ -500,7 +500,7 @@ foreach my $file ($info->sorted_index) {
         }
         # ---------------- /usr/local
         elsif ($file =~ m,^usr/local/\S+,) {
-            if ($index_info->{type} =~ m/^d/) {
+            if ($index_info->is_dir) {
                 tag 'dir-in-usr-local', $file;
             } else {
                 tag 'file-in-usr-local', $file;
@@ -515,10 +515,10 @@ foreach my $file ($info->sorted_index) {
             if ($type eq 'udeb') {
                 tag 'udeb-contains-documentation-file', $file;
             }
-            if ($index_info->{type} =~ m/^d/) {
+            if ($index_info->is_dir) {
                 tag 'stray-directory-in-manpage-directory', $file
                     if ($file !~ m,^usr/(?:X11R6|share)/man/(?:[^/]+/)?(?:man\d/)?$,);
-            } elsif ($index_info->{type} =~ m,^[-h], and ($operm & 0111)) {
+            } elsif ($index_info->is_file and ($operm & 0111)) {
                 tag 'executable-manpage', $file;
             }
         }
@@ -560,13 +560,13 @@ foreach my $file ($info->sorted_index) {
         }
         # ---------------- /usr/share
         elsif ($file =~ m,^usr/share/[^/]+$,) {
-            if ($index_info->{type} =~ m/^[-h]/) {
+            if ($index_info->is_file) {
                 tag 'file-directly-in-usr-share', $file;
             }
         }
         # ---------------- /usr/bin
         elsif ($file =~ m,^usr/bin/,) {
-            if ($index_info->{type} =~ m/^d/ and $file =~ m,^usr/bin/., and $file !~ m,^usr/bin/(?:X11|mh)/,) {
+            if ($index_info->is_dir and $file =~ m,^usr/bin/., and $file !~ m,^usr/bin/(?:X11|mh)/,) {
                 tag 'subdir-in-usr-bin', $file;
             }
         }
@@ -605,7 +605,7 @@ foreach my $file ($info->sorted_index) {
 
         # ---------------- non-games-specific data in games subdirectory
         elsif ($file =~ m,^usr/share/games/(?:applications|mime|icons|pixmaps)/,
-               and $index_info->{type} !~ m/^d/) {
+               and not $index_info->is_dir) {
             tag 'global-data-in-games-directory', $file;
         }
     }
@@ -662,7 +662,7 @@ foreach my $file ($info->sorted_index) {
     }
     # ---------------- /bin
     elsif ($file =~ m,^bin/,) {
-        if ($index_info->{type} =~ m/^d/ and $file =~ m,^bin/.,) {
+        if ($index_info->is_dir and $file =~ m,^bin/.,) {
             tag 'subdir-in-bin', $file;
         }
     }
@@ -701,7 +701,7 @@ foreach my $file ($info->sorted_index) {
     }
 
     # ---------------- any files
-    if ($index_info->{type} !~ m/^d/) {
+    if (not $index_info->is_dir) {
         unless ($type eq 'udeb'
                 or $file =~ m,^usr/(?:bin|dict|doc|games|
                                     include|info|lib(?:32|64)?|
@@ -726,7 +726,7 @@ foreach my $file ($info->sorted_index) {
         }
     }
 
-    if ($type ne 'udeb' && $index_info->{type} ne 'l' && $pkg !~ m/^libc[0-9]/o &&
+    if ($type ne 'udeb' && !$index_info->is_symlink && $pkg !~ m/^libc[0-9]/o &&
             $file =~ m,^(?:usr/)?lib/([^/]+)/lib[^/]+\.so(?:\.[^/]+)?$,o) {
         my $subdir = $1;
         # Skip if it not an ELF file (probably a .so script)
@@ -745,7 +745,7 @@ foreach my $file ($info->sorted_index) {
     }
 
     # ---------------- __pycache__ (directory for pyc/pyo files)
-    if ($index_info->{type} =~ m/^d/o && $file =~ m,/__pycache__/,o){
+    if ($index_info->is_dir && $file =~ m,/__pycache__/,o){
         tag 'package-installs-python-pycache-dir', $file;
     }
 
@@ -792,7 +792,7 @@ foreach my $file ($info->sorted_index) {
     # we do the same check on perl scripts in checks/scripts
     {
         my $dep = $info->relation('strong');
-        if ($index_info->{type} =~ m/^[-h]/o && $file =~ m,\.pm$, && !$dep->implies ('libperl4-corelibs-perl | perl (<< 5.12.3-7)')) {
+        if ($index_info->is_file && $file =~ m,\.pm$, && !$dep->implies ('libperl4-corelibs-perl | perl (<< 5.12.3-7)')) {
             open (PM, '<', $info->unpacked($file)) or fail("cannot open .pm file: $!");
             while (<PM>) {
                 if (/(?:do|require)\s+(?:'|")(abbrev|assert|bigfloat|bigint|bigrat|cacheout|complete|ctime|dotsh|exceptions|fastcwd|find|finddepth|flush|getcwd|getopt|getopts|hostname|importenv|look|newgetopt|open2|open3|pwd|shellwords|stat|syslog|tainted|termcap|timelocal|validate)\.pl(?:'|")/) {
@@ -921,7 +921,7 @@ foreach my $file ($info->sorted_index) {
     if ($file =~ m,/icons/[^/]+/(\d+)x(\d+)/(?!animations/).*\.png$,) {
         my ($dwidth, $dheight) = ($1, $2);
         my $path;
-        if ($index_info->{type} =~ m/^l/) {
+        if ($index_info->is_symlink) {
             $path = resolve_pkg_path(dirname($file), $link);
         } else {
             $path = $file;
@@ -941,7 +941,7 @@ foreach my $file ($info->sorted_index) {
     }
 
     # ---------------- plain files
-    if ($index_info->{type} =~ m/^[-h]/) {
+    if ($index_info->is_file) {
         # ---------------- backup files and autosave files
         if ($file =~ /~$/ or $file =~ m,\#[^/]+\#$, or $file =~ m,/\.[^/]+\.swp$,) {
             tag 'backup-file-in-package', $file;
@@ -1079,8 +1079,8 @@ foreach my $file ($info->sorted_index) {
         if ($operm & 06000) {
             my ($setuid, $setgid) = ('','');
             # get more info:
-            $setuid = $index_info->{owner} if ($operm & 04000);
-            $setgid = $index_info->{group} if ($operm & 02000);
+            $setuid = $index_info->owner if $operm & 04000;
+            $setgid = $index_info->group if $operm & 02000;
 
             # 1st special case: program is using svgalib:
             if (exists $linked_against_libvga{$file}) {
@@ -1163,7 +1163,7 @@ foreach my $file ($info->sorted_index) {
         }
     }
     # ---------------- directories
-    elsif ($index_info->{type} =~ m/^d/) {
+    elsif ($index_info->is_dir) {
         # special cases first:
         # game directory with setgid bit
         if ($file =~ m,^var/(?:lib/)?games/\S+, and $operm == 02775
@@ -1232,7 +1232,7 @@ foreach my $file ($info->sorted_index) {
         }
     }
     # ---------------- symbolic links
-    elsif ($index_info->{type} =~ m/^l/) {
+    elsif ($index_info->is_symlink) {
         # link
 
         my $mylink = $link;
@@ -1383,7 +1383,7 @@ if ($pkg_section !~ m,games$, and $games > 0 and $other == 0) {
 # python-support needs a directory for each package even it might be empty
 if($pkg ne 'base-files'){
     foreach my $dir ($info->sorted_index) {
-        next if $dir eq '' or $info->index->{$dir}->{type} ne 'd';
+        next if $dir eq '' or not $info->index->{$dir}->is_dir;
         next if ($dir =~ m{^var/} or $dir =~ m{^etc/});
         if (dir_counts($info, $dir) == 0) {
             if ($dir ne 'usr/lib/perl5/'
@@ -1429,6 +1429,8 @@ sub dir_counts {
     my ($info, $dir) = @_;
 
     if (defined $info->index->{$dir}) {
+        # internal access to undocumented field
+        # - stinks, but "count" is hardly API worthy.
         return $info->index->{$dir}->{count} || 0;
     } else {
         return 0;
diff --git a/checks/group-checks b/checks/group-checks
index 3a5be77..4bcd86d 100644
--- a/checks/group-checks
+++ b/checks/group-checks
@@ -145,7 +145,7 @@ sub _overlap_check {
         $b_file = $b_index->{$file} // $b_index->{"$file/"};
         if ($b_file) {
             $a_file = $a_info->index->{$file} // $a_info->index->{"$file/"};
-            next if $a_file->{type} eq $b_file->{type} && $a_file->{type} eq 'd';
+            next if $a_file->is_dir and $b_file->is_dir;
             tag 'binaries-have-file-conflict', $a_proc->pkg_name, $b_proc->pkg_name, $file;
         }
     }
diff --git a/checks/huge-usr-share b/checks/huge-usr-share
index 2c1bdc8..ed56e17 100644
--- a/checks/huge-usr-share
+++ b/checks/huge-usr-share
@@ -44,9 +44,9 @@ return 0 if $arch eq 'all';
 # in /usr/share.  Convert the totals to kilobytes.
 my ($size, $size_usrshare) = (0, 0);
 for my $file (keys %{ $info->index }) {
-    $size += $info->index->{$file}{size};
+    $size += $info->index->{$file}->size;
     if ($file =~ m,usr/share/,) {
-        $size_usrshare += $info->index->{$file}{size};
+        $size_usrshare += $info->index->{$file}->size;
     }
 }
 $size = int ($size / 1024);
diff --git a/checks/infofiles b/checks/infofiles
index b0b20d9..5a1a254 100644
--- a/checks/infofiles
+++ b/checks/infofiles
@@ -38,10 +38,10 @@ my $info = shift;
 foreach my $file ($info->sorted_index) {
     my $index_info = $info->index->{$file};
     my $file_info = $info->file_info->{$file};
-    my $link = $index_info->{link} || '';
+    my $link = $index_info->link || '';
     my ($fname, $path) = fileparse($file);
 
-    next unless ($index_info->{type} =~ m,^[\-lh],o)
+    next unless ($index_info->is_symlink or $index_info->is_file)
             and ($path =~ m,^usr/share/info/, or $path =~ m,^usr/info/,);
 
     # Ignore dir files.  That's a different error which we already catch in
@@ -54,7 +54,7 @@ foreach my $file ($info->sorted_index) {
     my @fname_pieces = split /\./, $fname;
     my $ext = pop @fname_pieces;
     if ($ext eq 'gz') { # ok!
-        if ($index_info->{type} =~ m,^[-h],o) { # compressed with maximum compression rate?
+        if ($index_info->is_file) { # compressed with maximum compression rate?
             if ($file_info !~ m/gzip compressed data/o) {
                 tag 'info-document-not-compressed-with-gzip', $file;
             } else {
diff --git a/checks/java b/checks/java
index d29c161..0823475 100644
--- a/checks/java
+++ b/checks/java
@@ -51,7 +51,7 @@ $need_cp = 1 if @java_lib_depends;
 for my $jar_file (sort keys %{$java_info}) {
     my $file_list = $java_info->{$jar_file}->{files};
     my $manifest = $java_info->{$jar_file}->{manifest};
-    my $operm = $info->index->{$jar_file}->{operm};
+    my $operm = $info->index->{$jar_file}->operm;
     my $jar_dir;
     my $classes = 1;
     my $datafiles = 1;
@@ -133,7 +133,7 @@ for my $jar_file (sort keys %{$java_info}) {
                         $tinfo = $info->{index}->{$target};
                         # Points to file or link in this package, which is sometimes
                         #  easier than re-writing the classpath.
-                        next if defined $tinfo && ($tinfo->{type} =~ m/^[-hl]/o);
+                        next if defined $tinfo and ($tinfo->is_symlink or $tinfo->is_file);
                         # Relative path with subdirectories.
                         push @relative, $p;
                     }
diff --git a/checks/manpages b/checks/manpages
index 5031c88..94ebdb3 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -48,8 +48,7 @@ my %manpage;
 foreach my $file ($info->sorted_index) {
     my $index_info = $info->index->{$file};
     my $file_info = $info->file_info->{$file};
-    my $link = $index_info->{link} || '';
-    my $perm = $index_info->{type};
+    my $link = $index_info->link || '';
     my ($fname, $path, $suffix) = fileparse($file);
 
     # Binary that wants a manual page?
@@ -57,7 +56,7 @@ foreach my $file ($info->sorted_index) {
     # It's tempting to check the section of the man page depending on the
     # location of the binary, but there are too many mismatches between
     # bin/sbin and 1/8 that it's not clear it's the right thing to do.
-    if (($perm =~ m,^[\-lh],o) and
+    if (($index_info->is_symlink or $index_info->is_file) and
         (($path eq 'bin/') or
          ($path eq 'sbin/') or
          ($path eq 'usr/bin/') or
@@ -80,7 +79,7 @@ foreach my $file ($info->sorted_index) {
     }
 
     # manual page?
-    next unless ($perm =~ m,^[\-lh],o) and
+    next unless ($index_info->is_symlink or $index_info->is_file) and
         (($path =~ m,^usr/man(/\S+),o)
          or ($path =~ m,^usr/X11R6/man(/\S+),o)
          or ($path =~ m,^usr/share/man(/\S+),o) );
@@ -106,7 +105,7 @@ foreach my $file ($info->sorted_index) {
     if ($ext ne 'gz') {
         push @pieces, $ext;
         tag 'manpage-not-compressed', $file;
-    } elsif ($perm =~ m,^[-h],o) { # so it's .gz... files first; links later
+    } elsif ($index_info->is_file) { # so it's .gz... files first; links later
         if ($file_info !~ m/gzip compressed data/o) {
             tag 'manpage-not-compressed-with-gzip', $file;
         } elsif ($file_info !~ m/max compression/o) {
@@ -129,7 +128,7 @@ foreach my $file ($info->sorted_index) {
     }
 
     # check symbolic links to other manual pages
-    if ($perm =~ m,^l,o) {
+    if ($index_info->is_symlink) {
         if ($link =~ m,(^|/)undocumented,o) {
             if ($path =~ m,^usr/share/man,o) {
                 # undocumented link in /usr/share/man -- possibilities
@@ -168,7 +167,7 @@ foreach my $file ($info->sorted_index) {
         while (<MANFILE>) { push @manfile, $_; }
         close MANFILE;
         # Is it a .so link?
-        if ($index_info->{size} < 256) {
+        if ($index_info->size < 256) {
             my ($i, $first) = (0, '');
             do {
                 $first = $manfile[$i++] || '';
@@ -332,10 +331,9 @@ foreach my $depproc (@{ $ginfo->direct_dependencies ($proc) }) {
     foreach my $file ($depinfo->sorted_index){
         next if $file eq '';
         my $index_info = $depinfo->index->{$file};
-        my $perm = $index_info->{type};
         my ($fname, $path, $suffix) = fileparse($file, qr,\..+$,o);
         my $lang = '';
-        next unless ($perm =~ m,^[\-lh],o) and
+        next unless ($index_info->is_file or $index_info->is_symlink) and
             (($path =~ m,^usr/man/\S+,o)
              or ($path =~ m,^usr/X11R6/man/\S+,o)
              or ($path =~ m,^usr/share/man/\S+,o) );
diff --git a/checks/md5sums b/checks/md5sums
index e6ed2f1..b132bc5 100644
--- a/checks/md5sums
+++ b/checks/md5sums
@@ -62,7 +62,7 @@ unless (-f $control) {
     my $only_conffiles = 1;
     foreach my $file ($info->sorted_index) {
         # Skip non-files, they will not appear in the md5sums file
-        next if !$file or $info->index->{$file}->{type} ne '-';
+        next unless $info->index->{$file}->is_regular_file;
         unless ($conffile{$file}) {
             $only_conffiles = 0;
             last;
diff --git a/checks/menu-format b/checks/menu-format
index d0d8acd..fcee4e9 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -343,11 +343,11 @@ closedir MENUDIR;
 my @desktop_files;
 foreach my $file ($info->sorted_index) {
     my $index_info = $info->index->{$file};
-    my $operm = $index_info->{operm};
+    my $operm = $index_info->operm;
 
     tag 'deprecated-kdelnk-file', $file if ($file =~ m,\.kdelnk$,);
 
-    if ($index_info->{type} =~ m/[-h]/ &&
+    if ($index_info->is_file &&
         $file =~ m,^usr/share/applications/.*\.desktop$,) {
 
         if ($operm & 0111) {
diff --git a/checks/menus b/checks/menus
index 8a0304c..01be751 100644
--- a/checks/menus
+++ b/checks/menus
@@ -89,9 +89,9 @@ for my $file ($info->sorted_index) {
 
     add_file_link_info ($info, $file, \%all_files, \%all_links);
     my $index_info = $info->index->{$file};
-    my $operm = $index_info->{operm};
+    my $operm = $index_info->operm;
 
-    if ($index_info->{type} =~ m,^[-h],) { # file checks
+    if ($index_info->is_file) { # file checks
         # menu file?
         if ($file =~ m,^usr/(lib|share)/menu/\S,o) { # correct permissions?
             if ($operm & 0111) {
@@ -496,8 +496,8 @@ sub check_doc_base_file_section {
 # links have to include a leading /.
 sub add_file_link_info {
     my ($info, $file, $all_files, $all_links) = @_;
-    my $link = $info->index->{$file}->{link};
-    my $ishard = ($info->index->{$file}->{type} eq 'h');
+    my $link = $info->index->{$file}->link;
+    my $ishard = $info->index->{$file}->is_hardlink;
 
     $file = "/" . $file if (not $file =~ m%^/%); # make file absolute
     $file =~ s%/+%/%g;                           # remove duplicated `/'
diff --git a/checks/scripts b/checks/scripts
index 07eb7b7..bc0dc69 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -207,9 +207,8 @@ foreach my $file ($info->sorted_index) {
     $ELF{$file} = 1 if $info->file_info->{$file} =~ /^[^,]*\bELF\b/o;
 
     my $index_info = $info->index->{$file};
-    my $operm = $index_info->{operm};
-    next unless $index_info->{type} =~ m,^[-h], and ($operm & 0111);
-    my $is_suid = $operm & 04000;
+    my $operm = $index_info->operm;
+    next unless $index_info->is_file and ($operm & 0111);
     $executable{$file} = 1;
 }
 
@@ -335,7 +334,7 @@ for my $filename (sort keys %{$info->scripts}) {
             # executable).
             my $interfile = substr $interpreter, 1;
             my $index_info = $info->index->{$interfile};
-            $pinter = 1 if $index_info && ($index_info->{operm} & 0111);
+            $pinter = 1 if $index_info && ($index_info->operm & 0111);
         }
         script_tag('unusual-interpreter', $filename, "#!$interpreter")
             unless $pinter;
diff --git a/checks/shared-libs b/checks/shared-libs
index 1d14ece..40a7314 100644
--- a/checks/shared-libs
+++ b/checks/shared-libs
@@ -101,14 +101,14 @@ for my $cur_file ($info->sorted_index) {
     my $cur_file_data = $info->index->{$cur_file};
 
     if (exists $SONAME{$cur_file} or
-        (defined $cur_file_data->{link} and exists $SONAME{abs_path(dirname($cur_file).'/'.$cur_file_data->{link})})) {
+        (defined $cur_file_data->link and exists $SONAME{abs_path(dirname($cur_file).'/'.$cur_file_data->link)})) {
         # yes!!
         my ($real_file, $perm);
         if (exists $SONAME{$cur_file}) {
             $real_file = $cur_file;
-            $perm = $cur_file_data->{operm};
+            $perm = $cur_file_data->operm;
         } else {
-            $real_file = abs_path(dirname($cur_file).'/'.$cur_file_data->{link});
+            $real_file = abs_path (dirname ($cur_file) . '/' . $cur_file_data->link);
             # perm not needed for this branch
         }
 
@@ -166,7 +166,7 @@ for my $cur_file ($info->sorted_index) {
     } elsif ($ldconfig_dirs->known(dirname($cur_file))
              && exists $sharedobject{$cur_file}) {
         tag 'sharedobject-in-library-directory-missing-soname', $cur_file;
-    } elsif ($cur_file =~ m/\.la$/ and not defined($cur_file_data->{link})) {
+    } elsif ($cur_file =~ m/\.la$/ and not defined $cur_file_data->link) {
         local $_;
         open(LAFILE, '<', $info->unpacked($cur_file))
             or fail("Could not open $cur_file for reading!");
@@ -215,15 +215,15 @@ for my $shlib_file (keys %SONAME) {
             # the library file uses its SONAME, this is ok...
         } else {
             # $link_file really a symlink?
-            if (exists $info->index->{$link_file}->{link}) {
+            if ($info->index->{$link_file}->is_symlink) {
                 # yes.
 
                 # $link_file pointing to correct file?
-                if ($info->index->{$link_file}->{link} eq $shlib_name) {
+                if ($info->index->{$link_file}->link eq $shlib_name) {
                     # ok.
                 } else {
                     tag 'ldconfig-symlink-referencing-wrong-file',
-                        "$link_file -> " . $info->index->{$link_file}->{link} . " instead of $shlib_name";
+                        "$link_file -> " . $info->index->{$link_file}->link . " instead of $shlib_name";
                 }
             } else {
                 tag 'ldconfig-symlink-is-not-a-symlink', "$shlib_file $link_file";
diff --git a/checks/symlinks b/checks/symlinks
index f37bd51..add08f7 100644
--- a/checks/symlinks
+++ b/checks/symlinks
@@ -41,9 +41,8 @@ my @dindexes;
 
 foreach my $file ($info->sorted_index) {
     my $index_info = $index->{$file};
-    my $perm = $index_info->{type};
-    if ($perm =~ m/^l/o){
-        my $target = $index_info->{link}//''; # the link target
+    if ($index_info->is_symlink){
+        my $target = $index_info->link//''; # the link target
         my $path; # the target (from the pkg root)
         # Should not happen (too often) - but just in case
         next unless $target;
diff --git a/debian/changelog b/debian/changelog
index 780533a..bd8a15c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,7 @@
 lintian (2.5.9) UNRELEASED; urgency=low
 
+  * checks/*:
+    + [NT] Migrate to new Lintian::Path API.
   * checks/fields:
     + [NT] Also classify lib*-cli-dev as belonging to the section
       cli-mono (rather than libdevel).  Thanks to Chow Loong Jin

-- 
Debian package checker


Reply to: