diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2019-08-15 13:40:31 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2019-08-15 20:21:34 +0200 |
commit | c94b507b92b3d833761f3e416d4d5bba709bf87f (patch) | |
tree | f6a55dc1c45ecc60cd0a75a08efec1417f60ab1b /apt-pkg | |
parent | af674d82d5cd36e22223ec49675d32adad07e0a9 (diff) |
Add ?virtual pattern
This matches any package that does not have versions.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 2 | ||||
-rw-r--r-- | apt-pkg/cachefilter-patterns.h | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index f078924ff..986faaf52 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -236,6 +236,8 @@ std::unique_ptr<APT::CacheFilter::Matcher> PatternParser::aPattern(std::unique_p return std::make_unique<APT::CacheFilter::TrueMatcher>(); if (node->matches("?upgradable", 0, 0)) return std::make_unique<Patterns::PackageIsUpgradable>(file); + if (node->matches("?virtual", 0, 0)) + return std::make_unique<Patterns::PackageIsVirtual>(); if (node->matches("?x-name-fnmatch", 1, 1)) return std::make_unique<APT::CacheFilter::PackageNameMatchesFnmatch>(aWord(node->arguments[0])); diff --git a/apt-pkg/cachefilter-patterns.h b/apt-pkg/cachefilter-patterns.h index 993839425..d37da815f 100644 --- a/apt-pkg/cachefilter-patterns.h +++ b/apt-pkg/cachefilter-patterns.h @@ -221,6 +221,14 @@ struct PackageIsUpgradable : public PackageMatcher return Pkg->CurrentVer != 0 && (*Cache)[Pkg].Upgradable(); } }; + +struct PackageIsVirtual : public PackageMatcher +{ + bool operator()(pkgCache::PkgIterator const &Pkg) override + { + return Pkg->VersionList == 0; + } +}; } // namespace Patterns } // namespace Internal } // namespace APT |