summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cachefilter-patterns.cc2
-rw-r--r--apt-pkg/cachefilter-patterns.h12
-rw-r--r--doc/apt-patterns.7.xml3
-rwxr-xr-xtest/integration/test-apt-patterns3
4 files changed, 20 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
diff --git a/doc/apt-patterns.7.xml b/doc/apt-patterns.7.xml
index 64dad4dd4..e1c64de8e 100644
--- a/doc/apt-patterns.7.xml
+++ b/doc/apt-patterns.7.xml
@@ -72,6 +72,9 @@
<varlistentry><term><code>?automatic</code></term>
<listitem><para>Selects packages that were installed automatically.</para></listitem>
</varlistentry>
+ <varlistentry><term><code>?broken</code></term>
+ <listitem><para>Selects packages that have broken dependencies.</para></listitem>
+ </varlistentry>
<varlistentry><term><code>?config-files</code></term>
<listitem><para>Selects packages that are not fully installed, but have solely residual configuration files left.</para></listitem>
</varlistentry>
diff --git a/test/integration/test-apt-patterns b/test/integration/test-apt-patterns
index b84605256..e566c6bd2 100755
--- a/test/integration/test-apt-patterns
+++ b/test/integration/test-apt-patterns
@@ -117,6 +117,9 @@ automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list '?automatic'
testsuccessequal "Listing...
+broken/now 1.0 i386 [installed,local]" apt list '?broken'
+
+testsuccessequal "Listing...
conf-only/now 1.0 i386 [residual-config]" apt list '?config-files'
testsuccessequal "Listing...