Lintian::Lab -- Interface to the Lintian Lab
use Lintian::Lab;
# Static lab
my $lab = Lintian::Lab->new ('/var/lib/lintian/static-lab');
if (!$lab->exists) {
$lab->create;
}
$lab->open;
# Fetch a package from the lab
my $lpkg = $lab->get_package ('lintian', 'binary', '2.5.4', 'all');
my $visitor = sub {
my ($lpkg, $pkg_name, $pkg_ver, $pkg_arch) = @_;
# do stuff with that entry
};
$lab->visit_packages ($visitor, 'source');
$lab->close;
This module provides an abstraction from "How and where" packages are placed. It handles creation and deletion of the Lintian Lab itself as well as providing access to the entries.
Creates a new Lab instance. If DIR is defined it will be used as the path to the lab and the lab will be in static mode. Otherwise the lab will be in temporary mode and will point to a temporary directory.
Returns the absolute path to the base of the lab.
Note: This may return the empty string if either the lab has been deleted or this is a temporary lab that has not been created yet. In the latter case, "create" or "open" should be run to get a non-empty value from this method.
Returns a truth value if this lab is open.
Note: If the lab is open, it also exists. However, if the lab is closed then the lab may or may not exist (see "exists").
Returns a truth value if the instance points to an existing lab.
Note: This never implies that the lab is open. Though it may imply the lab is closed (see "is_open").
Fetches an existing package from the lab.
The first argument can be a processable. In that case all other arguments are ignored.
If the first calling convention is used then this method will search for an existing package. The EXTRA argument can be used to narrow the search or even to add a new entry.
EXTRA consists of (in order):
If version or arch is omitted (or if it is undef) then that search parameter is consider a wildcard for "any". Example:
# Returns all eclipse-platform packages with architecture i386 regardless
# of their version (if any)
@ps = $lab->get_package ('eclipse-platform', 'binary', undef, 'i386');
# Returns all eclipse-platform packages with version 3.5.2-11 regardless
# of their architecture (if any)
@ps = $lab->get_package ('eclipse-platform', 'binary', '3.5.2-11');
# Return the eclipse-platform package with version 3.5.2-11 and architecture
# i386 (or undef)
$pkg = $lab->get_package ('eclipse-platform', 'binary', '3.5.2-11', 'i386');
In list context, this returns a list of matches. In scalar context this returns the first match (if any). Note there is no guaranteed order (e.g. the returned list is not ordered).
If the second calling convention is used, then this method will search for an entry matching the the processable passed. If such an entry does not exists, an new "non-existing" entry will be returned. This entry can be created by using the create method on the entry.
Process a given QUERY and return the results from it. A QUERY is a string of the format:
[TYPE:]NAME[/VERSION[/ARCH]]
TYPE can be one of the regular package type (e.g. "binary") or one of the two special values "ALL" (default if omitted) or "GROUP". If TYPE is ALL, then the query is one once for each of package type.
NAME is the name of the package to request. For GROUP queries, this is the name of the source package. It is not possible to do any kind of wildcards in NAME:
VERSION is the version of the package. For GROUP queries, this is the version of the source package. If omitted or the string '_', then any version will match.
ARCH is the architecture of the package. For GROUP and "source" queries, ARCH is ignored (if given). If ARCH is omitted or the string '_', then any package architecture will match. NB: The ARCH field should match the architecture field of the entry (which for .changes files usually contains spaces).