Lintian::Relation(3) | Debian Package Checker | Lintian::Relation(3) |
Lintian::Relation - Lintian operations on dependencies and relationships
my $depends = Lintian::Relation->new('foo | bar, baz'); print encode_utf8("yes\n") if $depends->satisfies('baz'); print encode_utf8("no\n") if $depends->satisfies('foo');
This module provides functions for parsing and evaluating package relationship fields such as Depends and Recommends for binary packages and Build-Depends for source packages. It parses a relationship into an internal format and can then answer questions such as "does this dependency require that a given package be installed" or "is this relationship a superset of another relationship."
A dependency line is viewed as a predicate formula. The comma separator means "and", and the alternatives separator means "or". A bare package name is the predicate "a package of this name is available". A package name with a version clause is the predicate "a package of this name that satisfies this version clause is available." Architecture restrictions, as specified in Policy for build dependencies, are supported and also checked in the implication logic unless the new_norestriction() constructor is used. With that constructor, architecture restrictions are ignored.
Lintian::Relation->new (join (', ', @relations))
Except it can avoid some overhead and it works if some of the elements are Lintian::Relation objects already.
By default, architecture restrictions are honored in RELATION if it is a string. If architecture restrictions should be ignored in RELATION, create a Lintian::Relation object with new_norestriction() and pass that in as RELATION instead of the string.
As with satisfies(), by default, architecture restrictions are honored in RELATION if it is a string. If architecture restrictions should be ignored in RELATION, create a Lintian::Relation object with new_norestriction() and pass that in as RELATION instead of the string.
This method will return a truth value if REGEX matches at least one predicate or clause (as defined by the WHAT parameter - see below).
NOTE: Often "satisfies" (or "satisfies_inverse") is a better choice than this method. This method should generally only be used when checking for a "pattern" package (e.g. phpapi-[\d\w+]+).
WHAT can be one of:
my $rel = Lintian::Relation->new ('somepkg | pkg-0 (>= 1)'); # Will match (version is ignored) $rel->matches (qr/^pkg-\d$/, VISIT_PRED_NAME);
my $vrel = Lintian::Relation->new ('somepkg | pkg-0 (>= 1)'); my $uvrel = Lintian::Relation->new ('somepkg | pkg-0'); # Will NOT match (does not match with version) $vrel->matches (qr/^pkg-\d$/, VISIT_PRED_FULL); # Will match (this relation does not have a version) $uvrel->matches (qr/^pkg-\d$/, VISIT_PRED_FULL); # Will match (but only because there is a version) $vrel->matches (qr/^pkg-\d \(.*\)$/, VISIT_PRED_FULL); # Will NOT match (there is no version in the relation) $uvrel->matches (qr/^pkg-\d \(.*\)$/, VISIT_PRED_FULL);
my $vpred = Lintian::Relation->new ('pkg-0 (>= 1)'); my $orrel = Lintian::Relation->new ('somepkg | pkg-0 (>= 1)'); my $rorrel = Lintian::Relation->new ('pkg-0 (>= 1) | somepkg'); # Will match $vrel->matches (qr/^pkg-\d(?: \([^\)]\))?$/, VISIT_OR_CLAUSE_FULL); # These Will NOT match (does not match the "|" and the "somepkg" part) $orrel->matches (qr/^pkg-\d(?: \([^\)]\))?$/, VISIT_OR_CLAUSE_FULL); $rorrel->matches (qr/^pkg-\d(?: \([^\)]\))?$/, VISIT_OR_CLAUSE_FULL);
The optional bitmask parameter, FLAGS, can be used to control what is visited and such. If FLAGS is not given, it defaults to VISIT_PRED_NAME. The possible values of FLAGS are:
Note: It will not visit the underlying predicates in the clause.
Except where a given flag specifies otherwise, the return value of visit is last value returned by CODE (or "undef" for the empty relation).
They are returned in the original textual representation and are also sorted by said representation.
Originally written by Russ Allbery <rra@debian.org> for Lintian.
lintian(1)
2024-10-16 | Lintian v2.117.0ubuntu1.2 |