diff --git a/CMakeLists.txt b/CMakeLists.txt index b9d031f42..1621a8384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ option(WITH_MODULEMD "Build with modulemd modules support" ON) option(WITH_ZCHUNK "Build with zchunk delta compression support" ON) option(WITH_SYSTEMD "Build with systemd and D-Bus features" ON) option(ENABLE_SOLV_URPMREORDER "Build with support for URPM-like solution reordering?" OFF) +option(ENABLE_SOLV_FOCUSNEW "Build with SOLVER_FLAG_FOCUS_NEW libsolv flag enabled to ensure new dependencies are installed in latests versions?" ON) # build options - documentation option(WITH_HTML "Build HTML documentation" ON) @@ -106,6 +107,9 @@ add_definitions(-DPROJECT_VERSION_MICRO=${VERSION_MICRO}) if(ENABLE_SOLV_URPMREORDER) add_definitions(-DLIBSOLV_FLAG_URPMREORDER=1) endif() +if(ENABLE_SOLV_FOCUSNEW) + add_definitions(-DLIBSOLV_FLAG_FOCUSNEW=1) +endif() if(WITH_SANITIZERS) message(WARNING "Building with sanitizers enabled!") diff --git a/dnf5.spec b/dnf5.spec index e822a98cd..36305658c 100644 --- a/dnf5.spec +++ b/dnf5.spec @@ -108,6 +108,13 @@ Provides: dnf5-command(versionlock) %bcond_with performance_tests %bcond_with dnf5daemon_tests +# Disable SOLVER_FLAG_FOCUS_NEW only for RHEL +%if 0%{?rhel} && 0%{?rhel} < 10 +%bcond_with focus_new +%else +%bcond_without focus_new +%endif + %if %{with clang} %global toolchain clang %endif @@ -116,7 +123,11 @@ Provides: dnf5-command(versionlock) %global libmodulemd_version 2.5.0 %global librepo_version 1.18.0 -%global libsolv_version 0.7.25 +%if %{with focus_new} + %global libsolv_version 0.7.30 +%else + %global libsolv_version 0.7.25 +%endif %global sqlite_version 3.35.0 %global swig_version 4 %global zchunk_version 0.9.11 @@ -769,6 +780,8 @@ automatically and regularly from systemd timers, cron jobs or similar. -DPACKAGE_VERSION=%{version} \ -DPERL_INSTALLDIRS=vendor \ \ + -DENABLE_SOLV_FOCUSNEW=%{?focus_new:ON}%{!?focus_new:OFF} \ + \ -DWITH_DNF5DAEMON_CLIENT=%{?with_dnf5daemon_client:ON}%{!?with_dnf5daemon_client:OFF} \ -DWITH_DNF5DAEMON_SERVER=%{?with_dnf5daemon_server:ON}%{!?with_dnf5daemon_server:OFF} \ -DWITH_LIBDNF5_CLI=%{?with_libdnf_cli:ON}%{!?with_libdnf_cli:OFF} \ diff --git a/libdnf5/CMakeLists.txt b/libdnf5/CMakeLists.txt index 398725ebc..4d1f5f9f8 100644 --- a/libdnf5/CMakeLists.txt +++ b/libdnf5/CMakeLists.txt @@ -78,7 +78,11 @@ if (WITH_MODULEMD) target_link_libraries(libdnf5_static PRIVATE ${LIBMODULEMD_LIBRARIES}) endif() -pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.25) +if (ENABLE_SOLV_FOCUSNEW) + pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.30) +else() + pkg_check_modules(LIBSOLV REQUIRED libsolv>=0.7.25) +endif() list(APPEND LIBDNF5_PC_REQUIRES "${LIBSOLV_MODULE_NAME}") target_link_libraries(libdnf5 PRIVATE ${LIBSOLV_LIBRARIES}) target_link_libraries(libdnf5_static PRIVATE ${LIBSOLV_LIBRARIES}) diff --git a/libdnf5/rpm/solv/goal_private.cpp b/libdnf5/rpm/solv/goal_private.cpp index 3a8c16fa5..fb8a89e02 100644 --- a/libdnf5/rpm/solv/goal_private.cpp +++ b/libdnf5/rpm/solv/goal_private.cpp @@ -412,6 +412,12 @@ libdnf5::GoalProblem GoalPrivate::resolve() { libsolv_solver.set_flag(SOLVER_FLAG_ALLOW_VENDORCHANGE, vendor_change); libsolv_solver.set_flag(SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, vendor_change); +#if defined(LIBSOLV_FLAG_FOCUSNEW) + // Ensure the solver tries to install the latest versions of dependencies, even if it results in a bigger transaction + // Available since libsolv-0.7.30 + libsolv_solver.set_flag(SOLVER_FLAG_FOCUS_NEW, 1); +#endif + if (libsolv_solver.solve(job)) { return libdnf5::GoalProblem::SOLVER_ERROR; }