summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cachefilter-patterns.cc2
-rw-r--r--apt-pkg/cachefilter-patterns.h15
-rw-r--r--doc/apt-patterns.7.xml3
-rwxr-xr-xtest/integration/test-apt-patterns5
4 files changed, 25 insertions, 0 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc
index 4414792cf..aeed31263 100644
--- a/apt-pkg/cachefilter-patterns.cc
+++ b/apt-pkg/cachefilter-patterns.cc
@@ -214,6 +214,8 @@ std::unique_ptr<APT::CacheFilter::Matcher> PatternParser::aPattern(std::unique_p
if (node->matches("?architecture", 1, 1))
return std::make_unique<APT::CacheFilter::PackageArchitectureMatchesSpecification>(aWord(node->arguments[0]));
+ if (node->matches("?archive", 1, 1))
+ return std::make_unique<Patterns::VersionIsArchive>(aWord(node->arguments[0]));
if (node->matches("?automatic", 0, 0))
return std::make_unique<Patterns::PackageIsAutomatic>(file);
if (node->matches("?broken", 0, 0))
diff --git a/apt-pkg/cachefilter-patterns.h b/apt-pkg/cachefilter-patterns.h
index 46a54cf81..c92a152d6 100644
--- a/apt-pkg/cachefilter-patterns.h
+++ b/apt-pkg/cachefilter-patterns.h
@@ -260,6 +260,21 @@ struct VersionAnyMatcher : public Matcher
}
};
+struct VersionIsArchive : public VersionAnyMatcher
+{
+ BaseRegexMatcher matcher;
+ VersionIsArchive(std::string const &pattern) : matcher(pattern) {}
+ bool operator()(pkgCache::VerIterator const &Ver) override
+ {
+ for (auto VF = Ver.FileList(); not VF.end(); VF++)
+ {
+ if (VF.File().Archive() && matcher(VF.File().Archive()))
+ return true;
+ }
+ return false;
+ }
+};
+
struct VersionIsSourcePackage : public VersionAnyMatcher
{
BaseRegexMatcher matcher;
diff --git a/doc/apt-patterns.7.xml b/doc/apt-patterns.7.xml
index 09ebedeab..fe82ca1b8 100644
--- a/doc/apt-patterns.7.xml
+++ b/doc/apt-patterns.7.xml
@@ -112,6 +112,9 @@
These patterns select specific versions of a package.
</para>
<variablelist>
+ <varlistentry><term><code>?archive(REGEX)</code></term>
+ <listitem><para>Selects versions that come from the archive that matches the specified regular expression. Archive, here, means the values after <code>a=</code> in <command>apt-cache policy</command>.</para></listitem>
+ </varlistentry>
<varlistentry><term><code>?source-package(REGEX)</code></term>
<listitem><para>Selects versions where the source package name matches the specified regular expression.</para></listitem>
</varlistentry>
diff --git a/test/integration/test-apt-patterns b/test/integration/test-apt-patterns
index c030e37ec..2fa5d336d 100755
--- a/test/integration/test-apt-patterns
+++ b/test/integration/test-apt-patterns
@@ -113,6 +113,11 @@ testsuccessequal "Listing..." apt list '?architecture(foreign)'
testsuccessequal "Listing..." apt list '?architecture(native)'
testsuccessequal "Listing...
+available/unstable 1.0 all
+foreign/unstable 2.0 amd64
+not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?archive(^unstable$)'
+
+testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list '?automatic'