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

[SCM] Debian package checker branch, master, updated. 2.5.11-139-g76f1c80



The following commit has been merged in the master branch:
commit 76f1c80058f9439f934e971090b4fa1d4bf060e5
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Jan 31 20:27:38 2013 +0100

    coll: Lazily open some pipes that are not always used
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/collection/hardening-info b/collection/hardening-info
index 20817e2..f6102ad 100755
--- a/collection/hardening-info
+++ b/collection/hardening-info
@@ -37,7 +37,7 @@ use FileHandle;
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Lintian::Collect;
 use Lintian::Command qw(spawn reap);
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail touch_file);
 
 sub collect {
 my ($pkg, $type, $dir) = @_;
@@ -53,16 +53,18 @@ if ( -e "$dir/hardening-info" ) {
 chdir ("$dir/unpacked")
     or fail("unable to chdir to unpacked: $!");
 
-my %opts = ( pipe_in => FileHandle->new,
-             out => "$dir/hardening-info",
-             fail => 'never' );
-
-# Use xargs to keep processing times of packages like linux-image
-# reasonble.
-spawn(\%opts, ['xargs', '-0r', 'hardening-check', '--lintian', '--'], '|',
-    [$helper]);
-$opts{pipe_in}->blocking(1);
+my %opts;
+my $open_hardening_info = sub {
+    # Use xargs to keep processing times of packages like linux-image
+    # reasonble.
 
+    %opts = ( pipe_in => FileHandle->new,
+              out => "$dir/hardening-info",
+              fail => 'error' );
+    spawn (\%opts, ['xargs', '-0r', 'hardening-check', '--lintian', '--'], '|',
+           [$helper]);
+    $opts{pipe_in}->blocking(1);
+};
 
 foreach my $bin ($info->sorted_index) {
     next unless $info->index ($bin)->is_file;
@@ -71,11 +73,17 @@ foreach my $bin ($info->sorted_index) {
     next if $bin =~ m/\.ko$/o;
     my $finfo = $info->file_info ($bin);
     next unless $finfo =~ m/\bELF\b/o;
+    $open_hardening_info->() unless %opts;
     printf {$opts{pipe_in}} "%s\0", $bin;
 }
 
-close $opts{pipe_in};
-reap (\%opts);
+if (%opts) {
+    close $opts{pipe_in};
+    reap (\%opts);
+} else {
+    touch_file ("$dir/hardening-info");
+}
+
 }
 
 collect (@ARGV) if $0 =~ m,(?:^|/)hardening-info$,;
diff --git a/collection/strings b/collection/strings
index 8682bbe..84213b2 100755
--- a/collection/strings
+++ b/collection/strings
@@ -59,10 +59,13 @@ mkdir "$dir/strings" or
 chdir ("$dir/unpacked")
     or fail("cannot chdir to unpacked directory: $!");
 
-my %opts = ( pipe_in => FileHandle->new,
-             fail => 'error' );
-spawn (\%opts, ['xargs', '-0r', 'strings', '-f', '--'], '|', [$helper, "$dir/strings"]);
-$opts{pipe_in}->blocking(1);
+my %opts;
+my $open_strings_pipe = sub {
+    %opts = ( pipe_in => FileHandle->new,
+              fail => 'error' );
+    spawn (\%opts, ['xargs', '-0r', 'strings', '-f', '--'], '|', [$helper, "$dir/strings"]);
+    $opts{pipe_in}->blocking(1);
+};
 
 foreach my $bin ($info->sorted_index) {
     my $finfo = $info->file_info ($bin);
@@ -75,10 +78,14 @@ foreach my $bin ($info->sorted_index) {
         push @manual, $bin;
         next;
     }
+    $open_strings_pipe->() unless %opts;
     printf {$opts{pipe_in}} "%s\0", $bin;
 }
-close $opts{pipe_in};
-reap (\%opts);
+
+if (%opts) {
+    close $opts{pipe_in};
+    reap (\%opts);
+}
 
 
 # Fall back to the safe but slower method for files with "special"

-- 
Debian package checker


Reply to: