diff --git a/include/libdnf5/rpm/package_query.hpp b/include/libdnf5/rpm/package_query.hpp index bc1a086be2..1d229eb0f9 100644 --- a/include/libdnf5/rpm/package_query.hpp +++ b/include/libdnf5/rpm/package_query.hpp @@ -275,12 +275,24 @@ class PackageQuery : public PackageSet { /// Filter packages by their `provides`. /// - /// @param patterns A vector of strings the filter is matched against. + /// @param pattern A string the filter is matched against. /// @param cmp_type A comparison (match) operator, defaults to `QueryCmp::EQ`. /// Supported values: `EQ`, `NEQ`, `GLOB`, `NOT_GLOB`. /// @since 5.0 // // @replaces libdnf/sack/query.hpp:method:addFilter(int keyname, int cmp_type, const char *match) - cmp_type = HY_PKG_PROVIDES + void filter_provides(const std::string & pattern, libdnf5::sack::QueryCmp cmp_type = libdnf5::sack::QueryCmp::EQ) { + std::vector patterns{pattern}; + filter_provides(patterns, cmp_type); + }; + + /// Filter packages by their `provides`. + /// + /// @param patterns A vector of strings the filter is matched against. + /// @param cmp_type A comparison (match) operator, defaults to `QueryCmp::EQ`. + /// Supported values: `EQ`, `NEQ`, `GLOB`, `NOT_GLOB`. + /// @since 5.0 + // // @replaces libdnf/sack/query.hpp:method:addFilter(int keyname, int cmp_type, const char **matches) - cmp_type = HY_PKG_PROVIDES void filter_provides( const std::vector & patterns, libdnf5::sack::QueryCmp cmp_type = libdnf5::sack::QueryCmp::EQ); diff --git a/libdnf5/module/module_sack.cpp b/libdnf5/module/module_sack.cpp index e2af5429de..8e7154d5ad 100644 --- a/libdnf5/module/module_sack.cpp +++ b/libdnf5/module/module_sack.cpp @@ -659,7 +659,7 @@ std::optional> ModuleSack::Impl::detect_plat } libdnf5::rpm::PackageQuery base_query(base); - base_query.filter_provides({"system-release"}); + base_query.filter_provides("system-release"); base_query.filter_latest_evr(); // try to detect platform id from available packages diff --git a/test/libdnf5/rpm/test_package_query.cpp b/test/libdnf5/rpm/test_package_query.cpp index f53d4d81ce..0c69ca8242 100644 --- a/test/libdnf5/rpm/test_package_query.cpp +++ b/test/libdnf5/rpm/test_package_query.cpp @@ -539,7 +539,7 @@ void RpmPackageQueryTest::test_filter_provides() { // packages with Provides == "libpkg.so.0()(64bit)" PackageQuery query1(base); - query1.filter_provides({"libpkg.so.0()(64bit)"}); + query1.filter_provides("libpkg.so.0()(64bit)"); std::vector expected = {get_pkg("pkg-libs-1:1.2-4.x86_64")}; CPPUNIT_ASSERT_EQUAL(expected, to_vector(query1)); @@ -548,7 +548,7 @@ void RpmPackageQueryTest::test_filter_provides() { // packages without Provides == "libpkg.so.0()(64bit)" PackageQuery query2(base); - query2.filter_provides({"libpkg.so.0()(64bit)"}, libdnf5::sack::QueryCmp::NEQ); + query2.filter_provides("libpkg.so.0()(64bit)", libdnf5::sack::QueryCmp::NEQ); expected = { get_pkg("pkg-0:1.2-3.src"), @@ -657,7 +657,7 @@ void RpmPackageQueryTest::test_filter_chain() { query.filter_version({"1.2"}); query.filter_release({"3"}); query.filter_arch({"x86_64"}); - query.filter_provides({"foo"}, libdnf5::sack::QueryCmp::NEQ); + query.filter_provides("foo", libdnf5::sack::QueryCmp::NEQ); query.filter_requires({"foo"}, libdnf5::sack::QueryCmp::NEQ); std::vector expected = {get_pkg("pkg-0:1.2-3.x86_64")}; @@ -827,6 +827,6 @@ void RpmPackageQueryTest::test_filter_provides_performance() { for (int i = 0; i < 100000; ++i) { PackageQuery query(base); - query.filter_provides({"prv-all"}); + query.filter_provides("prv-all"); } }