libdnf/0023-Clearer-error-for-protected-package-broken-dependenc.patch
2026-05-19 15:12:41 -04:00

61 lines
2.6 KiB
Diff

From 35f16bc89b567460dd7857f632a38790839baca9 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 47d9888e..4544cd9e 100644
--- a/libdnf/goal/Goal.cpp
+++ b/libdnf/goal/Goal.cpp
@@ -1752,11 +1752,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) {
@@ -1766,9 +1766,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();
@@ -1781,8 +1785,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