Use `SOLVER_FLAG_FOCUS_NEW` to install latests versions of deps

This is a new flag in the recent 0.7.30 release.
It is used only in current rawhide.

We previously tried to use `SOLVER_FLAG_FOCUS_BEST` but it turned out to
be too strong, this new flag should update packages only if it is
required for installing the latests versions of dependencies.

We had several reports where users expect this behavior.

This should properly resolve issue such as:
https://bugzilla.redhat.com/show_bug.cgi?id=2150300
https://issues.redhat.com/browse/RHEL-1374
This commit is contained in:
Aleš Matěj 2024-07-15 13:06:26 +02:00 committed by amatej
parent 62b8ffbc09
commit 26096c96b0
4 changed files with 29 additions and 2 deletions

View File

@ -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!")

View File

@ -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
@ -771,6 +782,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} \

View File

@ -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})

View File

@ -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;
}