Lintian::Relation(3)
β¨ NAME β¨
Lintian::Relation β bestie, this is the Lintian module that does operations on dependencies and relationships π (it's Lintian::Relation(3), section 3, iykyk)
π SYNOPSIS π
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');
πΈ DESCRIPTION πΈ
okay so this module hands you functions for parsing and evaluating package relationship fields β think Depends and Recommends for binary packages, and Build-Depends for source packages. It takes a relationship, parses it into an internal format, and then it's ready to answer the big questions like "does this dependency require that a given package be installed" or "is this relationship a superset of another relationship." π
A dependency line is basically a predicate formula, no cap:
- the comma separator means "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 they're also checked in the implication logic unless the new_norestriction() constructor is used. With that constructor, architecture restrictions are justβ¦ ignored π«₯
π INSTANCE METHODS π
trunkβ that's it. That's the whole entry. She contains multitudes πload(RELATION)β makes a brand newLintian::Relationobject matching the parsed relationship RELATION, and then you can ask that object whatever you want about that relationship.RELATIONcan beundefor the empty string, and in that case the returnedLintian::Relationobject is empty (aka always satisfied) β¨load_norestriction(RELATION)β same deal, makes a newLintian::Relationobject from the parsed relationship RELATION, but this one ignores architecture restrictions and restriction lists. Use this when you only care whether a dependency is present in some cases and you don't wanna require that the architectures match β like when you're checking for proper build dependencies, because if there are architecture constraints the maintainer is doing something beyond Lintian's ability to analyze β or when you don't wanna require the restrictions list to match (Lintian can't handle dependency implications with build profiles yet, bestie, it's a whole thing π).RELATIONmay beundefor the empty string, in which case the returnedLintian::Relationobject is empty (always satisfied).logical_and(RELATION, ...)β makes a newLintian::Relationobject by AND'ing all the relations together. Semantically it's basically the same as:
Lintian::Relation->new (join (', ', @relations))
except it can dodge some overhead, and it also works if some of the elements are already Lintian::Relation objects. slay π«Ά
redundancies()β hands you a list of duplicated elements inside the relation object. Every element of that returned list is a reference to an anonymous array holding a set of relations that count as redundancies of each other. Two relations are redundancies if one satisfies the other β meaning if one relationship is satisfied, the other is necessarily satisfied too. Heads up though: this relationship does not have to be commutative, so the opposite implication may not hold β οΈrestriction_lessβ returns a restriction-less variant of this relation.satisfies(RELATION)β returns true if the relationship satisfies RELATION, meaning that if theLintian::Relationobject is satisfied, RELATION will always be satisfied. RELATION can be either a string or anotherLintian::Relationobject.
By default, architecture restrictions are honored in RELATION if it's a string. If architecture restrictions should be ignored in RELATION, make a Lintian::Relation object with new_norestriction() and pass that in as RELATION instead of the string π
implies_arrayβ another mysterious one, no description, we respect her privacy πsatisfies_inverse(RELATION)β returns true if the relationship satisfies that RELATION is certainly false β meaning that if theLintian::Relationobject is satisfied, RELATION cannot be satisfied. RELATION can be a string or anotherLintian::Relationobject.
Just like with satisfies(), by default architecture restrictions are honored in RELATION if it's a string. If architecture restrictions should be ignored in RELATION, make a Lintian::Relation object with new_norestriction() and pass that in as RELATION instead of the string β¨
implies_array_inverseβ also just vibes, no description πto_stringβ returns the textual form of a relationship. It converts the internal form back into the textual representation and gives you that β not the original argument β so the spacing is standardized, periodt. Returnsundefon internal failures (like an object in an unexpected format) πmatches(REGEX[, WHAT])β checks if one of the predicates in this relation matches REGEX. WHAT decides what gets tested against REGEX, and if you don't give it, it defaults toVISIT_PRED_NAME.
This method returns a truth value if REGEX matches at least one predicate or clause (as defined by the WHAT parameter β see below).
NOTE: oftensatisfies(orsatisfies_inverse) is a better choice than this method, bestie. This one should generally only be used when you're checking for a "pattern" package, e.g.phpapi-[\d\w+]+π§
WHAT can be one of:
VISIT_PRED_NAME
Match REGEX against the package name in each predicate (so version and architecture constrains are ignored). Each predicate gets tested in isolation. For example:
my $rel = Lintian::Relation->new ('somepkg | pkg-0 (>= 1)');
# Will match (version is ignored)
$rel->matches (qr/^pkg-\d$/, VISIT_PRED_NAME);
VISIT_PRED_FULL
Match REGEX against the full (normalized) predicate (including version and architecture). Each predicate gets tested in isolation. For example:
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);
VISIT_OR_CLAUSE_FULL
Match REGEX against the full (normalized) OR clause. Each predicate will have both version and architecture constrains present. For example:
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);
equalsβ same thing but for full-string matches. It satisfies the perlcritic policyRegularExpressions::ProhibitFixedStringMatchesπvisit(CODE[, FLAGS])β visits clauses or predicates of this relation. Each clause or predicate is passed to CODE as first argument and will be available as$_.
The optional bitmask parameter, FLAGS, controls what gets visited and such. If FLAGS isn't given, it defaults to VISIT_PRED_NAME. The possible values of FLAGS are:
VISIT_PRED_NAME
The package name in each predicate is visited, but the version and architecture part(s) are left out (if any).
VISIT_PRED_FULL
The full predicates are visited in turn. The predicate will be normalized (by to_string).
VISIT_OR_CLAUSE_FULL
CODE will be passed the full OR clauses of this relation. The clauses will be normalized (by to_string)
Note: it will not visit the underlying predicates in the clause.
VISIT_STOP_FIRST_MATCH
Stop the visits the first time CODE returns a truth value. This is similar to first, except visit will return the value returned by CODE.
Except where a given flag specifies otherwise, the return value of visit is the last value returned by CODE (or undef for the empty relation) π
is_emptyβ returns a truth value if this relation is empty (i.e. it contains no predicates) π«₯unparsable_predicatesβ returns a list of predicates that were unparsable.
They come back in the original textual representation, and they're also sorted by said representation. organized queen π
π¦ AUTHOR π¦
Originally written by Russ Allbery rra@debian.org for Lintian. king behavior, honestly π
π₯ SEE ALSO π₯
and that's the whole page, bestie π shoutout to Lintian v2.139.0ubuntu2, dated 2026-10-08 β go forth and satisfy some dependencies, you absolute icon β¨π
π¦ where this page comes from
- ubuntu stonking: lintian 2.139.0ubuntu2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms