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

[SCM] Debian package checker branch, master, updated. 2.5.6-27-gbb9fd6d



The following commit has been merged in the master branch:
commit 4f61a988c11572d2500ed87440fdf42dcf75cfc1
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Mar 25 14:04:42 2012 +0200

    coll/*: Use L::Collect->index to access index data
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/ocaml b/checks/ocaml
index d4acb11..26d150d 100644
--- a/checks/ocaml
+++ b/checks/ocaml
@@ -42,7 +42,7 @@ my %provided_o;
 open ARINFO, '<', 'ar-info';
 while (<ARINFO>) {
     chomp;
-    if (/^\.\/([^:]+): (.*)$/) {
+    if (/^(?:\.\/)?([^:]+): (.*)$/) {
         my $filename = $1;
         my $dirname = dirname($filename);
         foreach (split(m/ /o, $2)) {
diff --git a/collection/ar-info b/collection/ar-info
index 9907590..4cbd88b 100755
--- a/collection/ar-info
+++ b/collection/ar-info
@@ -24,30 +24,31 @@ use warnings;
 
 use lib "$ENV{LINTIAN_ROOT}/lib";
 use FileHandle;
+use Lintian::Collect;
 use Lintian::Command qw(spawn);
 use Util qw(fail);
 
 ($#ARGV == 2) or fail 'syntax: ar-info <pkg> <type> <dir>';
 my ($pkg, $type, $dir) = @ARGV;
+my $info = Lintian::Collect->new ($pkg, $type, $dir);
 
 if ( -e "$dir/ar-info" ) {
     unlink "$dir/ar-info" or fail "unlink ar-info: $!";
 }
 
-# Open before chdir, as unpacked may be a symlink
-open INDEX, '<', "$dir/index"
-    or fail("cannot open index file: $!");
 open OUT, '>', "$dir/ar-info"
     or fail("cannot open ar-info file: $!");
 
 chdir ("$dir/unpacked")
     or fail("cannot chdir to unpacked directory: $!");
 
-while (<INDEX>) {
-    chomp;
-    next unless /\.a$/;
-    my $file = (split(' ', $_, 6))[5];
-    next unless -f $file;
+foreach my $origfile (@{ $info->sorted_index }) {
+    next unless $origfile =~ m/\.a$/;
+    next unless -f $origfile and not -l $origfile;
+    my $file = $origfile;
+    $file =~ s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
+    $file =~ s/\\\\/\\/g;
+
     my $opts = { pipe_out => FileHandle->new, err => '/dev/null' };
     spawn($opts, [ 'ar', 't', $file ]);
     print OUT "$file:";
@@ -60,7 +61,6 @@ while (<INDEX>) {
     $opts->{harness}->finish;
 }
 
-close(INDEX);
 close(OUT) or fail("cannot write ar-info: $!");
 
 # Local Variables:
diff --git a/collection/file-info b/collection/file-info
index 21482cc..dba694b 100755
--- a/collection/file-info
+++ b/collection/file-info
@@ -26,10 +26,12 @@ use Cwd qw(realpath);
 use FileHandle;
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Util;
+use Lintian::Collect;
 use Lintian::Command qw(spawn reap);
 
 ($#ARGV == 2) or fail 'syntax: file-info <pkg> <type> <dir>';
 my ($pkg, $type, $dir) = @ARGV;
+my $info = Lintian::Collect->new ($pkg, $type, $dir);
 my $last = '';
 
 my $helper = realpath("$0-helper");
@@ -43,9 +45,6 @@ if ( -e $outfile ) {
     unlink ($outfile) or fail "unlink file-info.gz: $!";
 }
 
-open INDEX, '<', "$dir/index"
-    or fail("cannot open index file: $!");
-
 chdir ("$dir/unpacked")
     or fail("cannot chdir to unpacked directory: $!");
 
@@ -59,16 +58,13 @@ my %opts = ( pipe_in => FileHandle->new,
 spawn(\%opts, ['xargs', '-0r', 'file', '-NF', '', '--print0', '--'], '|', [$helper], '|', ['gzip', '--best', '-c']);
 $opts{pipe_in}->blocking(1);
 
-while (<INDEX>) {
-    chomp;
-    $_ = (split(' ', $_, 6))[5];
-    s/ link to .*//;
-    s/ -> .*//;
-    s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
-    s/\\\\/\\/;
-    printf {$opts{pipe_in}} "%s\0", $_;
+foreach my $file (@{ $info->sorted_index }) {
+    next unless $file; # ignore "root-dir" which has "no name" (post stripping).
+    my $c = $file;
+    $c =~ s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
+    $c =~ s/\\\\/\\/g;
+    printf {$opts{pipe_in}} "%s\0", $c;
 }
-close(INDEX) or fail("cannot close index file: $!");
 
 close $opts{pipe_in};
 reap(\%opts);
diff --git a/collection/java-info b/collection/java-info
index f8ff49d..0a6bb60 100755
--- a/collection/java-info
+++ b/collection/java-info
@@ -23,30 +23,30 @@ use strict;
 use warnings;
 
 use lib "$ENV{'LINTIAN_ROOT'}/lib/";
+use Lintian::Collect;
 use Util qw(fail);
 
-my ($pkg, undef, $dir) = @ARGV;
+my ($pkg, $type, $dir) = @ARGV;
+my $info = Lintian::Collect->new ($pkg, $type, $dir);
 
 # Sanity check
 unless ( -d "$dir/unpacked/") {
     fail "java-info called with the wrong dir argument!";
 }
 
-open INDEX, '<', "$dir/index"
-    or fail "cannot open index: $!";
-
 open OUT, '>', "$dir/java-info"
     or fail "cannot open java-info: $!";
 
 chdir ("$dir/unpacked")
     or fail "unable to chdir to unpacked: $!";
 
-while (<INDEX>) {
-    chomp;
-    $_ = (split(' ', $_, 6))[5];
-    next if / -> .*/;           # We skip symlinks.
-    if (m#\S+\.jar$#i) {
-        my $file = $_;
+foreach my $origfile (@{ $info->sorted_index }) {
+    my $ftype = $info->index->{$origfile}->{type};
+    next unless $ftype eq '-' or $ftype eq 'h';
+    my $file = $origfile;
+    $file =~ s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
+    $file =~ s/\\\\/\\/g;
+    if ($file =~ m#\S+\.jar$#i) {
         my $has_manifest = 0;
 
         # This script needs unzip, there's no way around.
@@ -85,7 +85,6 @@ while (<INDEX>) {
     }
 }
 
-close INDEX;
 close OUT or fail("cannot write java-info: $!");
 
 exit 0
diff --git a/collection/java-info.desc b/collection/java-info.desc
index b256fe9..d793f5c 100644
--- a/collection/java-info.desc
+++ b/collection/java-info.desc
@@ -3,4 +3,4 @@ Author: Vincent Fourmond <fourmond@debian.org>
 Info: This script extracts information from manifests of JAR files
 Type: binary
 Version: 1
-Needs-Info: unpacked
+Needs-Info: unpacked, index
diff --git a/collection/md5sums b/collection/md5sums
index f6dd186..dccb47c 100755
--- a/collection/md5sums
+++ b/collection/md5sums
@@ -24,12 +24,14 @@ use warnings;
 
 use FileHandle;
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Lintian::Collect;
 use Lintian::Command qw(spawn reap);
 use Util;
 
 ($#ARGV == 2) or fail 'syntax: md5sums <pkg> <type> <dir>';
 
 my ($pkg, $type, $dir) = @ARGV;
+my $info = Lintian::Collect->new ($pkg, $type, $dir);
 
 if ( -e "$dir/md5sums" ) {
     unlink "$dir/md5sums" or fail "unlink md5sums: $!";
@@ -43,18 +45,14 @@ my %opts = ( pipe_in => FileHandle->new,
              fail => 'error' );
 spawn(\%opts, ['xargs', '-0r', 'md5sum'] );
 $opts{pipe_in}->blocking(1);
-open(INDEX, '<', "$dir/index")
-    or fail("cannot open index file: $!");
-while (<INDEX>) {
-    next unless m/^-/;
-    chop;
-    $_ = (split(' ', $_, 6))[5];
-    s/ link to .*//;
-    s/\\(\d+)/chr(oct($1))/eg;
-    s/\\\\/\\/g;
-    printf {$opts{pipe_in}} "%s\0", $_;
+
+foreach my $file (@{ $info->sorted_index }) {
+    next unless $info->index->{$file}->{type} =~ m/^[-h]/;
+    my $c = $file;
+    $c =~ s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
+    $c =~ s/\\\\/\\/g;
+    printf {$opts{pipe_in}} "%s\0", $c;
 }
-close(INDEX);
 
 close $opts{pipe_in};
 reap(\%opts);
diff --git a/collection/scripts b/collection/scripts
index 7b8acf3..06aa93b 100755
--- a/collection/scripts
+++ b/collection/scripts
@@ -23,26 +23,24 @@ use strict;
 use warnings;
 
 use lib "$ENV{'LINTIAN_ROOT'}/lib/";
+use Lintian::Collect;
 use Util qw(fail);
 
-my (undef, undef, $dir) = @ARGV;
+my ($pkg, $type, $dir) = @ARGV;
+my $info = Lintian::Collect->new ($pkg, $type, $dir);
 
 open SCRIPTS, '>', "$dir/scripts" or fail "cannot open scripts output file: $!";
-open INDEX, '<', "$dir/index" or fail "cannot open index file: $!";
 
 my $file;
 my $magic;
 my $scriptpath;
 
-while (<INDEX>) {
-    next unless /^-/;   # skip non-files
-    chop;
+foreach my $origfile (@{ $info->sorted_index }) {
+    next unless $info->index->{$origfile}->{type} eq '-';
+    my $file = $origfile;
+    $file =~ s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
+    $file =~ s/\\\\/\\/g;
 
-    # Extract the filename field from the tar-like file index.
-    # Note that the split is done with an explicit limit so that filenames
-    # with embedded spaces are handled correctly.
-    $file = (split(' ', $_, 6))[5];
-    $file =~ s/ link to .*//;    # cut off info about hard links
     # This used to call fail() instead of next.  However, the check to
     # see if all files in the index can be opened should be done elsewhere.
     open(FILE, '<', "$dir/unpacked/$file") or next;
@@ -69,7 +67,6 @@ while (<INDEX>) {
     }
     close(FILE);
 }
-close(INDEX);
 close(SCRIPTS) or fail("cannot write scripts file: $!");
 
 open SCRIPTS, '>', "$dir/control-scripts"
diff --git a/debian/changelog b/debian/changelog
index 813e1da..1b818d9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -38,6 +38,8 @@ lintian (2.5.7) UNRELEASED; urgency=low
   * checks/menus{,.desc}:
     + [NT] Remove "manual" lazy load of data file.
 
+  * collection/*:
+    + [NT] Use Lintian::Collect to access the package index.
   * collection/file-info{,.desc}:
     + [NT] Compress file-info output and bump version of file-info.
   * collection/objdump-info:
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index 591caf2..27173d7 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -256,18 +256,18 @@ sub java_info {
         chomp;
         next if m/^\s*$/o;
 
-        if (m#^-- \./(.+)$#o) {
-            $file = $1;
-            $java_info{$file}->{files} = [];
-            $file_list = $java_info{$file}->{files};
-            $manifest = 0;
-        }
-        elsif (m#^-- MANIFEST: \./(?:.+)$#o) {
+        if (m#^-- MANIFEST: (?:\./)?(?:.+)$#o) {
             # TODO: check $file == $1 ?
             $java_info{$file}->{manifest} = {};
             $manifest = $java_info{$file}->{manifest};
             $file_list = 0;
         }
+        elsif (m#^-- (?:\./)?(.+)$#o) {
+            $file = $1;
+            $java_info{$file}->{files} = [];
+            $file_list = $java_info{$file}->{files};
+            $manifest = 0;
+        }
         else {
             if($manifest && m#^  (\S+):\s(.*)$#o) {
                 $manifest->{$1} = $2;

-- 
Debian package checker


Reply to: