diff options
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 3 | ||||
| -rw-r--r-- | apt-pkg/cachefilter-patterns.h | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index 471e698d6..12d8ae748 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -56,6 +56,7 @@ static const constexpr struct {"n"_sv, "?name"_sv, true}, {"o"_sv, "?obsolete"_sv, false}, {"O"_sv, "?origin"_sv, true}, + {"p"_sv, "?priority"_sv, true}, {"s"_sv, "?section"_sv, true}, {"e"_sv, "?source-package"_sv, true}, {"T"_sv, "?true"_sv, false}, @@ -477,6 +478,8 @@ std::unique_ptr<APT::CacheFilter::Matcher> PatternParser::aPattern(std::unique_p return std::make_unique<Patterns::PackageReverseDepends>(aPattern(node->arguments[0]), pkgCache::Dep::Enhances); if (node->matches("?essential", 0, 0)) return std::make_unique<Patterns::PackageIsEssential>(); + if (node->matches("?priority", 1, 1)) + return std::make_unique<Patterns::VersionIsPriority>(aWord(node->arguments[0])); if (node->matches("?exact-name", 1, 1)) return std::make_unique<Patterns::PackageHasExactName>(aWord(node->arguments[0])); if (node->matches("?false", 0, 0)) diff --git a/apt-pkg/cachefilter-patterns.h b/apt-pkg/cachefilter-patterns.h index e0c48dd12..d55cb6335 100644 --- a/apt-pkg/cachefilter-patterns.h +++ b/apt-pkg/cachefilter-patterns.h @@ -417,6 +417,22 @@ struct APT_HIDDEN VersionIsVersion : public VersionAnyMatcher return matcher(Ver.VerStr()); } }; + +struct APT_HIDDEN VersionIsPriority : public VersionAnyMatcher +{ + std::string name; + explicit VersionIsPriority(std::string name) : name(name) {} + bool operator()(pkgCache::VerIterator const &Ver) override + { + std::string Mapping[] = {"", "required","important","standard", + "optional","extra"}; + if (Ver->Priority > 0 && Ver->Priority < APT_ARRAY_SIZE(Mapping)) { + return name == Mapping[Ver->Priority]; + } + return false; + } +}; + } // namespace Patterns } // namespace Internal } // namespace APT |
