From e3df7c90373aa450459f7bdc21dea2798e01cfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Wed, 22 May 2024 10:55:25 +0200 Subject: [PATCH] Add hints for `--ignore-installed` and `--ignore-extras` --- dnf5/main.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dnf5/main.cpp b/dnf5/main.cpp index 344e2f411..23f318587 100644 --- a/dnf5/main.cpp +++ b/dnf5/main.cpp @@ -974,6 +974,30 @@ static void print_resolve_hints(dnf5::Context & context) { } } + // hint --ignore-extras if there are unexpected extra packages in the transaction + if ((transaction_problems & libdnf5::GoalProblem::EXTRA) == libdnf5::GoalProblem::EXTRA) { + const std::string_view arg{"--ignore-extras"}; + if (has_named_arg(command, arg.substr(2))) { + hints.emplace_back(libdnf5::utils::sformat(_("{} to allow extra packages in the transaction"), arg)); + } + } + + // hint --ignore-installed if there are mismatches between installed and stored transaction packages in replay + if ((transaction_problems & libdnf5::GoalProblem::NOT_INSTALLED) == libdnf5::GoalProblem::NOT_INSTALLED || + (transaction_problems & libdnf5::GoalProblem::INSTALLED_IN_DIFFERENT_VERSION) == + libdnf5::GoalProblem::INSTALLED_IN_DIFFERENT_VERSION) { + for (const auto & resolve_log : context.get_transaction()->get_resolve_logs()) { + if (resolve_log.get_action() == libdnf5::GoalAction::REPLAY) { + const std::string_view arg{"--ignore-installed"}; + if (has_named_arg(command, arg.substr(2))) { + hints.emplace_back(libdnf5::utils::sformat( + _("{} to allow mismatches between installed and stored transaction packages."), arg)); + break; + } + } + } + } + if ((transaction_problems & libdnf5::GoalProblem::SOLVER_ERROR) == libdnf5::GoalProblem::SOLVER_ERROR) { bool conflict = false; bool broken_file_dep = false;