From 7fa292edbe924923cc689721fe58244ca0a40bcd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 21 Aug 2019 22:21:30 +0200 Subject: patterns: Add ?source-name and ?source-version --- apt-pkg/cachefilter-patterns.cc | 4 ++++ apt-pkg/cachefilter-patterns.h | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index ba341df60..4414792cf 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -236,6 +236,10 @@ std::unique_ptr PatternParser::aPattern(std::unique_p return std::make_unique(aPattern(node->arguments[0]).release()); if (node->matches("?obsolete", 0, 0)) return std::make_unique(); + if (node->matches("?source-package", 1, 1)) + return std::make_unique(aWord(node->arguments[0])); + if (node->matches("?source-version", 1, 1)) + return std::make_unique(aWord(node->arguments[0])); if (node->matches("?true", 0, 0)) return std::make_unique(); if (node->matches("?upgradable", 0, 0)) diff --git a/apt-pkg/cachefilter-patterns.h b/apt-pkg/cachefilter-patterns.h index 4959b0f14..46a54cf81 100644 --- a/apt-pkg/cachefilter-patterns.h +++ b/apt-pkg/cachefilter-patterns.h @@ -260,6 +260,26 @@ struct VersionAnyMatcher : public Matcher } }; +struct VersionIsSourcePackage : public VersionAnyMatcher +{ + BaseRegexMatcher matcher; + VersionIsSourcePackage(std::string const &pattern) : matcher(pattern) {} + bool operator()(pkgCache::VerIterator const &Ver) override + { + return matcher(Ver.SourcePkgName()); + } +}; + +struct VersionIsSourceVersion : public VersionAnyMatcher +{ + BaseRegexMatcher matcher; + VersionIsSourceVersion(std::string const &pattern) : matcher(pattern) {} + bool operator()(pkgCache::VerIterator const &Ver) override + { + return matcher(Ver.SourceVerStr()); + } +}; + struct VersionIsVersion : public VersionAnyMatcher { BaseRegexMatcher matcher; -- cgit v1.2.3