Skip to content

Commit e659393

Browse files
committed
Add is_dep_satisfied to PackageQuery and use it for repoclosure
`is_dep_satisfied` correctly handles also rich dependencies. It requires new libsolv >= 0.7.35 API.
1 parent 473a6e3 commit e659393

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

dnf5-plugins/repoclosure_plugin/repoclosure.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,11 @@ void RepoclosureCommand::run() {
170170
for (const auto & pkg : to_check_query) {
171171
std::vector<std::string> unsatisfied;
172172
for (const auto & reldep : pkg.get_requires()) {
173-
if (libdnf5::rpm::Reldep::is_rich_dependency(reldep.to_string())) {
174-
// Rich dependencies are skipped because they are too complicated to provide correct result
175-
continue;
176-
};
177173
int reldep_id = reldep.get_id().id;
178174
auto resolved_it = resolved.find(reldep_id);
179175
bool satisfied;
180176
if (resolved_it == resolved.end()) {
181-
libdnf5::rpm::PackageQuery reldep_q(available_query);
182-
reldep_q.filter_provides(reldep);
183-
satisfied = !reldep_q.empty();
177+
satisfied = available_query.is_dep_satisfied(reldep);
184178
resolved.emplace(reldep_id, satisfied);
185179
} else {
186180
satisfied = resolved_it->second;

dnf5.spec

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ Provides: dnf5-command(versionlock)
125125

126126
%global libmodulemd_version 2.5.0
127127
%global librepo_version 1.20.0
128-
%if %{with focus_new}
129-
%global libsolv_version 0.7.30
130-
%else
131-
%global libsolv_version 0.7.25
132-
%endif
128+
%global libsolv_version 0.7.35
133129
%global sqlite_version 3.35.0
134130
%global swig_version 4
135131

include/libdnf5/rpm/package_query.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,10 @@ class LIBDNF_API PackageQuery : public PackageSet {
988988
std::pair<bool, libdnf5::rpm::Nevra> resolve_pkg_spec(
989989
const std::string & pkg_spec, const libdnf5::ResolveSpecSettings & settings, bool with_src);
990990

991+
/// Returns `true` if the dependency `reldep` is satisfied by the packages in query, otherwise `false` is returned.
992+
/// @since 5.2.16
993+
bool is_dep_satisfied(const Reldep & reldep);
994+
991995
void swap(PackageQuery & other) noexcept;
992996

993997
/// Filter packages to keep only duplicates of installed packages. Packages are duplicate if they have the same `name` and `arch` but different `evr`.

libdnf5/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ if (WITH_MODULEMD)
8181
target_link_libraries(libdnf5_iface INTERFACE ${LIBMODULEMD_LIBRARIES})
8282
endif()
8383

84-
if (ENABLE_SOLV_FOCUSNEW)
85-
pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.30)
86-
else()
87-
pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.25)
88-
endif()
84+
pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.35)
8985
list(APPEND LIBDNF5_PC_REQUIRES "${LIBSOLV_MODULE_NAME}")
9086
target_link_libraries(libdnf5 PRIVATE ${LIBSOLV_LIBRARIES})
9187
target_link_libraries(libdnf5_iface INTERFACE ${LIBSOLV_LIBRARIES})

libdnf5/rpm/package_query.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,12 @@ void PackageQuery::filter_priority() {
26352635
}
26362636
}
26372637

2638+
bool PackageQuery::is_dep_satisfied(const Reldep & reldep) {
2639+
p_impl->base->get_rpm_package_sack()->p_impl->make_provides_ready();
2640+
auto & pool = get_rpm_pool(p_impl->base);
2641+
return pool.is_dep_satisfied_in_map(reldep.get_id().id, *p_impl);
2642+
}
2643+
26382644
std::pair<bool, libdnf5::rpm::Nevra> PackageQuery::resolve_pkg_spec(
26392645
const std::string & pkg_spec, const ResolveSpecSettings & settings, bool with_src) {
26402646
auto & pool = get_rpm_pool(p_impl->base);

libdnf5/solv/pool.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ class Pool {
253253

254254
int set_flag(int flag, int value) { return pool_set_flag(pool, flag, value); }
255255

256+
/// Returns `1` if the dependency `dep` is satisfied by the packages specified
257+
/// in `map`, otherwise `0` is returned.
258+
int is_dep_satisfied_in_map(Id dep, SolvMap & map) { return pool_satisfieddep_map(pool, &map.get_map(), dep); }
259+
256260
protected:
257261
SolvMap considered; // owner of the considered map, `pool->considered` is only a raw pointer
258262
::Pool * pool;

0 commit comments

Comments
 (0)