diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2019-08-15 13:32:54 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2019-08-15 20:21:34 +0200 |
commit | 9282c9094ab3e77cebe90e97b2f9a5fc21463e2f (patch) | |
tree | 2e72354f968e0c68eb29261cfeecffd1fa9e423c /apt-pkg | |
parent | a3e9ab661b2d670f7d0da53a5f56c52af0763c5b (diff) | |
download | apt-9282c9094ab3e77cebe90e97b2f9a5fc21463e2f.tar.gz |
Add ?broken pattern
This matches all packages that have broken dependencies in the
installed version or the version selected for install.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 2 | ||||
-rw-r--r-- | apt-pkg/cachefilter-patterns.h | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index 0f23890b4..a180cf78e 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -212,6 +212,8 @@ std::unique_ptr<APT::CacheFilter::Matcher> PatternParser::aPattern(std::unique_p return std::make_unique<APT::CacheFilter::PackageArchitectureMatchesSpecification>(aWord(node->arguments[0])); if (node->matches("?automatic", 0, 0)) return std::make_unique<Patterns::PackageIsAutomatic>(file); + if (node->matches("?broken", 0, 0)) + return std::make_unique<Patterns::PackageIsBroken>(file); if (node->matches("?config-files", 0, 0)) return std::make_unique<Patterns::PackageIsConfigFiles>(); if (node->matches("?false", 0, 0)) diff --git a/apt-pkg/cachefilter-patterns.h b/apt-pkg/cachefilter-patterns.h index 7770385c9..c219e5bcd 100644 --- a/apt-pkg/cachefilter-patterns.h +++ b/apt-pkg/cachefilter-patterns.h @@ -128,6 +128,18 @@ struct PackageIsAutomatic : public PackageMatcher } }; +struct PackageIsBroken : public PackageMatcher +{ + pkgCacheFile *Cache; + explicit PackageIsBroken(pkgCacheFile *Cache) : Cache(Cache) {} + bool operator()(pkgCache::PkgIterator const &Pkg) override + { + assert(Cache != nullptr); + auto state = (*Cache)[Pkg]; + return state.InstBroken() || state.NowBroken(); + } +}; + struct PackageIsConfigFiles : public PackageMatcher { bool operator()(pkgCache::PkgIterator const &Pkg) override |