Skip to content

Commit

Permalink
Use SOLVER_FLAG_FOCUS_NEW to install latests versions of deps
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kontura committed Aug 6, 2024
1 parent 62b8ffb commit 26096c9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!")
Expand Down
15 changes: 14 additions & 1 deletion dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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} \
Expand Down
6 changes: 5 additions & 1 deletion libdnf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 6 additions & 0 deletions libdnf5/rpm/solv/goal_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 26096c9

Please sign in to comment.