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

[SCM] Debian package checker branch, master, updated. 2.5.1-162-gae057df



The following commit has been merged in the master branch:
commit ae057dfadafcf37905c49067644aa914a64375d1
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Jul 30 22:06:04 2011 +0200

    Added new --packages-from-file option
    
    Allows the argument to be "-" for stdin and has a simpler syntax
    than --packages-file.

diff --git a/debian/changelog b/debian/changelog
index 904918d..909a3ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -206,6 +206,10 @@ lintian (2.5.2) UNRELEASED; urgency=low
       loaded.  Previously Lintian would only load direct
       dependencies of a collection and assume that was enough.
     + [NT] Allow "verbose" to appear in the lintianrc file.
+    + [NT] Added new "--packages-from-file" option.  Lintian will
+      read packages from the file (one package per line) and process
+      these.  Unlike "--packages-file" it allows its argument to be
+      "-" for stdin and the format is simpler.
 
   * lib/Lab.pm:
     + [NT] Removed $dist argument to lab creation, since we rely on
diff --git a/frontend/lintian b/frontend/lintian
index 1e14ea0..dc6ffbb 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -224,6 +224,7 @@ Package selection options:
     -a, --all                 process all packages in distribution
     -b, --binary              process only binary packages
     -p X, --packages-file X   process all files in file (special syntax!)
+    --packages-from-file  X   process the packages in a file (if "-" use stdin)
     -s, --source              process only source packages
     --udeb                    process only udeb packages
 EOT-EOT-EOT
@@ -492,6 +493,7 @@ my %opthash = (			# ------------------ actions
 	       'source|s' => \&record_pkgmode,
 	       'udeb' => \&record_pkgmode,
 	       'packages-file|p=s' => \$packages_file,
+	       'packages-from-file=s' => \$opt{'packages-from-file'},
 
 	       # ------------------ experimental
 	       'exp-output:s' => \$experimental_output_opts,
@@ -534,18 +536,23 @@ if (defined $opt{'LINTIAN_ROOT'}) {
 $LINTIAN_ROOT = $opt{'LINTIAN_ROOT'};
 
 # option --all and packages specified at the same time?
-if (($check_everything or $packages_file) and $#ARGV+1 > 0) {
-    print STDERR "warning: options -a or -p cannot be mixed with package parameters!\n";
-    print STDERR "(will ignore -a or -p option)\n";
+if (($check_everything or $packages_file or $opt{'packages-from-file'}) and $#ARGV+1 > 0) {
+    print STDERR "warning: options -a, -p and --packages-from-file cannot be mixed with package parameters!\n";
+    print STDERR "(will ignore -a, -p or/and --packages-from-file option)\n";
     undef $check_everything;
     undef $packages_file;
+    delete $opt{'packages-from-file'};
+}
+
+if ($packages_file && $opt{'packages-from-file'}) {
+    die "The options -p and --packages-from-file cannot be used together.\n"
 }
 
 # check specified action
 $action = 'check' unless $action;
 
 # check for arguments
-if ($action =~ /^(?:check|unpack|remove)$/ and $#ARGV == -1 and not $check_everything and not $packages_file) {
+if ($action =~ /^(?:check|unpack|remove)$/ and $#ARGV == -1 and not $check_everything and not $packages_file and not $opt{'packages-from-file'}) {
     syntax();
 }
 
@@ -1003,10 +1010,29 @@ if ($check_everything) {
     open(my $pkgin, '<', $packages_file) or fail("Reading $packages_file: $!");
     while (my $line = <$pkgin>) {
 	chomp($line);
-	my (undef, undef, undef, $file) = split(/\s+/, $line, 4);
+	my ($t, undef, undef, $file) = split(/\s+/, $line, 4);
+	unless (defined $file && length $t == 1) {
+	    print STDERR "Syntax error in packages-file at line $.\n";
+	    print STDERR " - perhaps you meant to use \"--packages-from-file $packages_file\"\n";
+	    exit 1;
+	}
 	$pool->add_file($file);
     }
     close($pkgin);
+} elsif ($opt{'packages-from-file'}){
+    my $fd;
+    if ($opt{'packages-from-file'} eq '-') {
+	$fd = \*STDIN;
+    } else {
+	open $fd, '<', $opt{'packages-from-file'} or die "opening $opt{'packages-from-file'}: $!";
+    }
+    while (my $file = <$fd>) {
+	chomp($file);
+	$pool->add_file($file);
+    }
+    # close unless it is STDIN (else we will see a lot of warnings
+    # about STDIN being reopened as "output only")
+    close $fd unless $opt{'packages-from-file'} eq '-';
 }
 
 # undef these as they are not needed any more and they give a cheap
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index 39b988c..9c8b6ba 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -414,6 +414,13 @@ package), B<package> is the package name, B<version> is the package's
 version, and B<file> is the package file name (absolute path
 specification).
 
+=item B<--packages-from-file> X
+
+Process the packages listed in X.  Lintian will parse each line (all
+whitespace included) as the path to a package it should process.
+
+If the file is "-", Lintian will read the packages from STDIN.
+
 =item B<-s>, B<--source>
 
 The following packages listed on the command line are source packages.

-- 
Debian package checker


Reply to: