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

[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-139-ga093e64



The following commit has been merged in the lab-refactor branch:
commit a093e64ac02394f509d17738e069bfbcb14b03c8
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Oct 23 17:47:41 2011 +0200

    Remove dist search and create a new lab query format
    
    The lab query format allows more control over which package is
    requested instead of "all with the name foo".  The query format
    is:
    
     [type:]package[/version[/arch]]
    
    The "type" is one of "ALL", "binary", "source", "udeb" and "changes".
    "package" is the name of the package (as before).  "version" is the
    exact version of the package requested and "arch" is the specific
    architecture of the package.
    
    If version or arch is left out, they are assumed to have the specical
    value "_".  If version or arch is "_", then the parameter is ignored
    (i.e. "any version" or "any architecture").  The "arch" parameter
    is completely ignored when matching source packages.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/frontend/lintian b/frontend/lintian
index b1fcc1b..6dc0e17 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -91,7 +91,7 @@ my $BANNER = "Lintian v$LINTIAN_VERSION"; #Version Banner - text form
 # Variables used to record commandline options
 # Commented out variables have "defined" checks somewhere to determine if
 # they were set via commandline or environment variables
-my $pkg_mode = 'a';             # auto -- automatically search for
+my $pkg_mode = 'auto';          # auto -- automatically search for
                                 # binary and source pkgs
 my $debug = 0;
 my $check_everything = 0;       #flag for -a|--all switch
@@ -359,9 +359,9 @@ sub record_unpack_info {
 # Record what type of data is specified
 # Options: -b|--binary, -s|--source, --udeb
 sub record_pkgmode {
-    $pkg_mode = 'b' if $_[0] eq 'binary';
-    $pkg_mode = 's' if $_[0] eq 'source';
-    $pkg_mode = 'u' if $_[0] eq 'udeb';
+    $pkg_mode = 'binary' if $_[0] eq 'binary';
+    $pkg_mode = 'source' if $_[0] eq 'source';
+    $pkg_mode = 'udeb' if $_[0] eq 'udeb';
 }
 
 # Process -L|--display-level flag
@@ -936,61 +936,36 @@ while (my $arg = shift) {
         }
     } else {
         # parameter is a package name--so look it up
-        # search the distribution first, then the lab
-        # special case: search only in lab if action is `remove'
-
-        my $search;
         my @res;
-        if ($action eq 'remove') {
-            # search only in lab--see below
-            $search = 'lab';
-        } else {
-            # search in dist, then in lab
-            $search = 'dist or lab';
-
-            my $found = 0;
-
-            if (($pkg_mode eq 'b') or ($pkg_mode eq 'a')) {
-                $bin_info = load_pkg_list('binary', "$opt{'LINTIAN_LAB'}/info/binary-packages") unless $bin_info;
-                if ($bin_info->get($arg)) {
-                    $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $bin_info->get($arg)->{'file'});
-                    $found = 1;
-                }
-            }
-            if (($pkg_mode eq 'u') or ($pkg_mode eq 'a')) {
-                $udeb_info = load_pkg_list('udeb', "$opt{'LINTIAN_LAB'}/info/udeb-packages") unless $udeb_info;
-                if ($udeb_info->get($arg)) {
-                    $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $udeb_info->get($arg)->{'file'});
-                    $found = 1;
-                }
-            }
-            if (($pkg_mode eq 's') or ($pkg_mode eq 'a')) {
-                $src_info = load_pkg_list('source', "$opt{'LINTIAN_LAB'}/info/source-packages") unless $src_info;
-                if ($src_info->get($arg)) {
-                    $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $src_info->get($arg)->{'file'});
-                    $found = 1;
-                }
-            }
+        my $type = $pkg_mode;
+        my ($pkg, $version, $arch);
+        my $orig = $arg; # Save for the error message later
 
-            next if $found;
-        }
-
-        # nothing found so far, so search the lab
 
-        if ($pkg_mode eq 'b' or $pkg_mode eq 'a') {
-            my @pkgs = $LAB->get_package ($arg, 'binary');
-            push @res, @pkgs;
-        }
-        if ($pkg_mode eq 's' or $pkg_mode eq 'a') {
-            my @pkgs = $LAB->get_package ($arg, 'source');
-            push @res, @pkgs;
+        # "britney"-like format - note this catches the old style, where only the
+        # package name was specified.
+        # Check if it starts with a type specifier (i.e. binary:eclipse/3.5.2-1/amd64)
+        if ($arg =~ m,^([^:]+):(.*),) {
+            ($type, $arg) = ($1, $2);
         }
-        if ($pkg_mode eq 'u' or $pkg_mode eq 'a') {
-            my @pkgs = $LAB->get_package ($arg, 'udeb');
-            push @res, @pkgs;
-        }
-        if ($pkg_mode eq 'c' or $pkg_mode eq 'a') {
-            my @pkgs = $LAB->get_package ($arg, 'changes');
+        # Split on /
+        ($pkg, $version, $arch) = split m,/,o, $arg;
+
+        # if version (or/and arch) is omitted or is the special
+        # value "_", let it be wildcard.
+        $version = undef if !$version or $version eq '_';
+        $arch = undef if !$arch or $arch eq '_';
+        debug_msg (2, "$orig => $type, $pkg, " . ($version//'*') . ', ' . ($arch//'*'));
+
+        if ($type eq 'auto' or $type eq 'ALL') {
+            # Check for all types
+            foreach my $t (qw(binary source udeb changes)) {
+                my @pkgs = $LAB->get_package ($pkg, $t, $version, $arch);
+                push @res, @pkgs;
+            }
+        } else {
+            # specific type requested
+            my @pkgs = $LAB->get_package ($pkg, $type, $version, $arch);
             push @res, @pkgs;
         }
 
@@ -999,11 +974,13 @@ while (my $arg = shift) {
                 $pool->add_proc ($p);
             }
         } else {
-            warning("cannot find binary, udeb or source package $arg in $search (skipping)");
+            my $tuple = join (', ', map { $_//'*'} ($type, $pkg, $version, $arch));
+            debug_msg (1, "Did not find a match for $orig (pkg_mode = $pkg_mode)",
+                       " - Search tuple: ($tuple)");
+            warning ("cannot find binary, udeb or source package $orig in lab (skipping)");
             $exit_code = 2;
             next;
         }
-
     }
 }
 
@@ -1015,19 +992,19 @@ if ($check_everything) {
 
     debug_msg(2, "pkg_mode = $pkg_mode");
 
-    if (($pkg_mode eq 'a') or ($pkg_mode eq 's')) {
+    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'source')) {
         for my $arg (sort $src_info->get_all) {
             debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $src_info->get($arg)->{'file'});
             $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $src_info->get($arg)->{'file'});
         }
     }
-    if (($pkg_mode eq 'a') or ($pkg_mode eq 'b')) {
+    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'binary')) {
         for my $arg (sort $bin_info->get_all) {
             debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $bin_info->get($arg)->{'file'});
             $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $bin_info->get($arg)->{'file'});
         }
     }
-    if (($pkg_mode eq 'a') or ($pkg_mode eq 'u')) {
+    if (($pkg_mode eq 'auto') or ($pkg_mode eq 'udeb')) {
         for my $arg (sort $udeb_info->get_all) {
             debug_msg(1, "doing stuff with $opt{'LINTIAN_ARCHIVEDIR'}/" . $udeb_info->get($arg)->{'file'});
             $pool->add_file("$opt{'LINTIAN_ARCHIVEDIR'}/" . $udeb_info->get($arg)->{'file'});
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index c344d8a..10bc9e6 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -39,13 +39,8 @@ expensive data-collection operations.
 
 There are three ways to specify binary, udeb or source packages for
 Lintian to process: by file name (the .deb file for a binary package
-or the .dsc file for a source package), by package name, or by naming
-a I<.changes> file.  If you list packages by package name, you'll have to
-define the B<LINTIAN_DIST> variable in the configuration file (see
-below).  Lintian will then search for any binary or source packages in
-this directory for packages with the given name. (You can use the
-B<-b> (B<--binary>), B<--udeb> and B<-s> (B<--source>) options if you
-only want to process binary, udeb or source packages.)
+or the .dsc file for a source package), by naming a I<.changes> file,
+or by using a lab query (see L</LAB QUERY> below).
 
 If you specify a I<.changes> file, Lintian will process all packages
 listed in that file.  This is convenient when checking a new package
@@ -430,12 +425,17 @@ Package selection options:
 
 =item B<-a>, B<--all>
 
-Check all packages in the distribution. (This requires that the
-LINTIAN_DIST variable is defined in the configuration file.)
+Check all packages in the laboratory.
+
+Note: If B<--binary>, B<--udeb> or B<--source> is specified, then only
+packages of that type is considered.
 
 =item B<-b>, B<--binary>
 
-The following packages listed on the command line are binary packages.
+The lab-queries listed on the command line are by default binary
+packages.
+
+With B<--all> this means check all binary packages in the lab.
 
 =item B<-p> X, B<--packages-file> X
 
@@ -461,11 +461,19 @@ If the file is "-", Lintian will read the packages from STDIN.
 
 =item B<-s>, B<--source>
 
+The lab-queries listed on the command line are by default source
+packages.
+
+With B<--all> this means check all source packages in the lab.
+
 The following packages listed on the command line are source packages.
 
 =item B<--udeb>
 
-The following packages listed on the command line are udeb packages.
+The lab-queries listed on the command line are by default udeb
+packages.
+
+With B<--all> this means check all udeb packages in the lab.
 
 =back
 
@@ -631,6 +639,50 @@ Lintian run-time error. An error message is sent to stderr.
 
 =back
 
+=head1 LAB QUERY
+
+A lab query can be used to refer to a (set of) package(s) in the
+Lintian Laboratory.  The general format of a query is:
+
+ [type:]package[/version[/arch]]
+
+Where:
+
+=over 4
+
+=item type
+
+This is the type of the package and (if present) must be one of "ALL",
+"binary", "udeb", "source" or "changes".  This is case sensitive.
+
+If omitted this defaults to "ALL" unless another default has been
+specified (see B<--binary>, B<--udeb> or B<--source>).
+
+=item package
+
+This is the name of the package.  This is mandatory and must match
+exactly.
+
+=item version
+
+This is the version of the package, if left out (or if it is "_") then
+any version will do.  Otherwise the version must match exactly.
+
+=item arch
+
+This is the architecture of the package, if left out (or it is "_")
+then any architecture will do.  Otherwise the architecture must match
+exactly.
+
+Note: This is I<completely> ignored when matching against source
+packages.
+
+Note: For changes packages, this must match the contents of the
+architecture field in the changes.  This field may contain a space
+(i.e. "source all") and therefore may also need proper shell escape.
+
+=back
+
 =head1 EXAMPLES
 
 =over 4
@@ -648,12 +700,6 @@ Check source package foo given by foo.dsc.
 Check source package foo given by foo.dsc, including minor/possible
 tags.
 
-=item B<$ lintian foo>
-
-Search for package foo in the Debian archive and check it. (Depending
-on what is found, this command will check either the source or binary
-package foo, or both.)
-
 =item B<$ lintian --archivedir /var/packages --dist custom --area main>
 
 Check all packages found in the Debian archive at
@@ -673,13 +719,13 @@ Search for binary package foo in the Debian archive and check it.
 
 Run the copyright checks on source package foo.
 
-=item B<$ lintian -u foo>
+=item B<$ lintian -u foo -U unpacked>
 
-Unpack package foo in the Lintian laboratory.
+Unpack all packages named foo in the Lintian laboratory.
 
 =item B<$ lintian -r foo>
 
-Remove package foo from the Lintian laboratory.
+Remove all packages named foo from the Lintian laboratory.
 
 =back
 

-- 
Debian package checker


Reply to: