Skip to content

Commit

Permalink
Allow obsoletion of protected packages
Browse files Browse the repository at this point in the history
As described at the end of this comment:
rpm-software-management/dnf#1926 (comment)

There should be some mechanism for replacing even protected packages,
e.g. to upgrade DNF to DNF 5. Obsoleting a protected package is less
likely to happen accidentally than removing it. But this change does
mean that a protected package could be obsoleted, and then the obsoleter
could be removed, which is perhaps not ideal.

IMO a better, more "declarative" way, might be to disallow any
transaction that would result in a protected package no longer being
provided. But I'm not sure how to do this without modifying libsolv.
  • Loading branch information
evan-goode committed Aug 28, 2023
1 parent 3fca06e commit 8c005d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libdnf/goal/Goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,12 +1631,18 @@ Goal::Impl::protectedInRemovals()
if ((!protectedPkgs || !protectedPkgs->size()) && !protect_running_kernel)
return false;
auto pkgRemoveList = listResults(SOLVER_TRANSACTION_ERASE, 0);
Id protected_kernel = protectedRunningKernel();
auto pkgObsoleteList = listResults(SOLVER_TRANSACTION_OBSOLETED, 0);
map_or(pkgRemoveList.getMap(), pkgObsoleteList.getMap());
// Special case: consider the obsoletion of the running kernel as a
// removal. Obsoletion of other protected packages should be allowed.
for (size_t obsolete_index = 0; obsolete_index < pkgObsoleteList.size(); obsolete_index += 1) {
if (protected_kernel == pkgObsoleteList[obsolete_index]) {
pkgRemoveList.set(protected_kernel);
}
}

removalOfProtected.reset(new PackageSet(pkgRemoveList));
Id id = -1;
Id protected_kernel = protectedRunningKernel();
while(true) {
id = removalOfProtected->next(id);
if (id == -1)
Expand Down

0 comments on commit 8c005d2

Please sign in to comment.