Searches and Versions

By default, a pattern matches a package if any version of the package matches the pattern. However, some patterns will restrict their subterms to only match against some versions of a package. For instance, the search term ?depends(pattern) will select any package that depends on a package matching 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 ?depends(?version(2\.0)), only versions 3.0 and 4.0 will be tested against ?version(2\.0), and hence 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 ?maintainer(maintainer) will only match versions that have the given 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.


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 subterms are matched against the same version of the package.

For example: suppose that version 3.0-1 of the package aardvark is installed, but that version 4.0-1 is available. Then the search expression ?version(4\.0-1)?installed matches aardvark, because ?version(4\.0-1) matches against version 4.0-1 of aardvark, while ?installed matches against version 3.0-1. On the other hand, this expression does not match against all the versions of aardvark, because no single version is installed and also has a version number of 4.0-1.