libdnf/0039-Clearer-error-for-protected-package-broken-dependenc.patch
Aleš Matěj 26b7225ec0 Backport: invalid keys crash, removal and problem desc of protected
Resolves: RHEL-145618
Resolves: RHEL-76112
Resolves: RHEL-115194
2026-02-11 11:38:37 +01:00

61 lines
2.6 KiB
Diff

From 5f5dbd01e93d1ec830d5d071051d1a98d2357227 Mon Sep 17 00:00:00 2001
From: Evan Goode <mail@evangoo.de>
Date: Tue, 27 Jan 2026 13:19:14 -0500
Subject: [PATCH 5/5] Clearer error for protected package broken dependencies
The error message now distinguishes removal of a protected package from
breaking dependencies of protected packages.
---
libdnf/goal/Goal.cpp | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/libdnf/goal/Goal.cpp b/libdnf/goal/Goal.cpp
index fb7bd343..5ae86db5 100644
--- a/libdnf/goal/Goal.cpp
+++ b/libdnf/goal/Goal.cpp
@@ -1697,11 +1697,11 @@ Goal::Impl::protectedInRemovals()
std::string
Goal::Impl::describeProtectedRemoval()
{
- std::string message(_("The operation would result in removing"
- " the following protected packages: "));
Pool * pool = solv->pool;
if (removalOfProtected && removalOfProtected->size()) {
+ const std::string removal_message(_("The operation would result in removing "
+ "the following protected packages: "));
Id id = -1;
std::vector<const char *> names;
while((id = removalOfProtected->next(id)) != -1) {
@@ -1711,9 +1711,13 @@ Goal::Impl::describeProtectedRemoval()
if (names.empty()) {
return {};
}
- return message + std::accumulate(std::next(names.begin()), names.end(),
- std::string(names[0]), [](std::string a, std::string b) { return a + ", " + b; });
+ return removal_message +
+ std::accumulate(std::next(names.begin()), names.end(), std::string(names[0]),
+ [](std::string a, std::string b) { return a + ", " + b; });
}
+
+ const std::string broken_dependency_message(_("The operation would result in broken "
+ "dependencies for the following protected packages: "));
auto pset = brokenDependencyAllPkgs(DNF_PACKAGE_STATE_INSTALLED);
Id id = -1;
Id protected_kernel = protectedRunningKernel();
@@ -1726,8 +1730,9 @@ Goal::Impl::describeProtectedRemoval()
}
if (names.empty())
return {};
- return message + std::accumulate(std::next(names.begin()), names.end(), std::string(names[0]),
- [](std::string a, std::string b) { return a + ", " + b; });
+ return broken_dependency_message +
+ std::accumulate(std::next(names.begin()), names.end(), std::string(names[0]),
+ [](std::string a, std::string b) { return a + ", " + b; });
}
}
--
2.53.0