diff options
-rw-r--r-- | apt-pkg/cachefilter-patterns.cc | 4 | ||||
-rw-r--r-- | doc/apt-patterns.7.xml | 6 | ||||
-rwxr-xr-x | test/integration/test-apt-patterns | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index 8b8695f71..f202df796 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -258,11 +258,13 @@ std::unique_ptr<APT::CacheFilter::Matcher> PatternParser::aPattern(std::unique_p return std::make_unique<APT::CacheFilter::PackageNameMatchesFnmatch>(aWord(node->arguments[0])); // Variable argument patterns - if (node->matches("?and", 0, -1)) + if (node->matches("?and", 0, -1) || node->matches("?narrow", 0, -1)) { auto pattern = std::make_unique<APT::CacheFilter::ANDMatcher>(); for (auto &arg : node->arguments) pattern->AND(aPattern(arg).release()); + if (node->term == "?narrow") + return std::make_unique<Patterns::VersionIsAnyVersion>(std::move(pattern)); return pattern; } if (node->matches("?or", 0, -1)) diff --git a/doc/apt-patterns.7.xml b/doc/apt-patterns.7.xml index 102ed3901..c2549f620 100644 --- a/doc/apt-patterns.7.xml +++ b/doc/apt-patterns.7.xml @@ -69,6 +69,9 @@ <listitem><para>Selects any version where the pattern matches on the version.</para> <para>For example, while <code>?and(?version(1),?version(2))</code> matches a package which has one version containing 1 and one version containing 2, <code>?any-version(?and(?version(1),?version(2)))</code> restricts the <code>?and</code> to act on the same version.</para></listitem> </varlistentry> + <varlistentry><term><code>?narrow(PATTERN...)</code></term> + <listitem><para>Selects any version matching all PATTERNs, short for<code>?any-version(?and(PATTERN...))</code>.</para></listitem> + </varlistentry> </variablelist> </refsect1> <refsect1> @@ -181,6 +184,9 @@ <listitem> <para>A trailing comma is allowed in argument lists</para> </listitem> + <listitem> + <para>?narrow accepts infinite arguments</para> + </listitem> </itemizedlist> </refsect1> diff --git a/test/integration/test-apt-patterns b/test/integration/test-apt-patterns index 767fd22b1..291aad1d4 100755 --- a/test/integration/test-apt-patterns +++ b/test/integration/test-apt-patterns @@ -110,11 +110,15 @@ not-obsolete/unstable 2.0 i386 [upgradable from: 1.0] N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?and(?version(^1\.0$),?version(^2\.0$))' testsuccessequal "Listing..." apt list '?any-version(?and(?version(^1\.0$),?version(^2\.0$)))' +testsuccessequal "Listing..." apt list '?narrow(?version(^1\.0$),?version(^2\.0$))' # XXX FIXME: I guess we do want this to only show version 1.0? testsuccessequal "Listing... not-obsolete/unstable 2.0 i386 [upgradable from: 1.0] N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?any-version(?and(?version(^1\.0$),?name(not-obsolete)))' +testsuccessequal "Listing... +not-obsolete/unstable 2.0 i386 [upgradable from: 1.0] +N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?narrow(?version(^1\.0$),?name(not-obsolete))' |