By default, a pattern matches a package if any version of the package
matches the pattern. However, some patterns will restrict their
sub-patterns to only match against some versions of a package. For
instance, the search term
will
select any package that depends on a package matching
?depends
(pattern
)pattern
. However,
pattern
will only be checked against the versions
of the package that actually satisfy a dependency. This means that if
foo
depends on bar (>= 3.0)
and
versions 2.0
, 3.0
, and
4.0
of bar
are available, then in the
search pattern
, only
versions ?depends
(?version
(2\.0))3.0
and 4.0
will be tested
against
, and hence
?version
(2\.0)foo
will not be found by this search.
It matters which versions are checked because, as in the example above, some
patterns will match one version but not another. For instance, the pattern
?installed
will only match the version of the package (if any) that is
currently installed. Similarly, the pattern
will
only match versions that have the given
?maintainer
(maintainer
)maintainer
. Normally all versions of a package
have the same maintainer, but this is not always the case; in fact, any
search pattern that examines the fields of a package (other than its name,
of course) will behave this way, because all the fields of a package can
change between versions.
To test a pattern against all the versions of a package, even if the pattern
would normally be tested against only some of the versions, use the ?widen
term. For instance,
will match any
package ?depends
(?widen
(?version
(2\.0)))A
that depends on a package
B
, where B
has a
version matching 2.0
, regardless of whether that version
actually satisfies A
's dependency. On the other
hand, the ?narrow
term restricts the versions that its sub-pattern is
matched against:
will match any package whose
installed version has a dependency that can be satisfied by a package whose
version string contains 「?narrow
(?installed
,
?depends
(?version
(ubuntu)))ubuntu
」.
注記 | |
---|---|
There is a subtle, but important, distinction between matching a pattern against a package, and matching it against all the versions of that package. When a pattern is matched against a package, each of its terms is matched against the package, and so each term will match if any version of the package matches. In contrast, when a pattern is matched against each version of a package, it will successfully match if it matches when all its terms are matched against the same version of the package.
For example: suppose that version |