Skip to content

Commit

Permalink
Allow obsoletion of protected packages
Browse files Browse the repository at this point in the history
This is the libdnf5 companion to
rpm-software-management/libdnf#1610; if we
change DNF 4, then we should also change DNF 5.

There should be some mechanism for replacing even protected packages,
e.g. to upgrade DNF to DNF 5. We unprotected dnf to allow this upgrade,
but that solution isn't perfect; DNF 5 should be able to remove
python3-dnf[1] and DNF 4 should not be able to remove DNF without
installing DNF 5. @m-blaha proposed "implementing a hard-coded
self-protection for each package manager", i.e. adding back the
hardcoded protection of dnf and python3-dnf in DNF 4 and adding a
protection of dnf5 in DNF 5. So if we want to do this, it seems we would
need to allow obsoletion of protected packages to allow DNF 4 to
obsolete dnf with dnf5.
  • Loading branch information
evan-goode committed Jul 20, 2023
1 parent ef374fd commit e4c3f3d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions libdnf5/rpm/solv/goal_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,20 +571,16 @@ libdnf5::GoalProblem GoalPrivate::protected_in_removals() {
return ret;
}
auto removes = list_removes();
auto obsoleted = list_obsoleted();
if (removes.empty() && obsoleted.empty()) {
if (removes.empty()) {
removal_of_protected.reset();
return ret;
}

auto & pool = get_rpm_pool();

libdnf5::solv::SolvMap pkg_remove_list(pool->nsolvables);
for (auto index = 0; index < removes.size(); ++index) {
pkg_remove_list.add_unsafe(removes[index]);
}
for (auto index = 0; index < obsoleted.size(); ++index) {
pkg_remove_list.add_unsafe(obsoleted[index]);
for (const auto & remove : removes) {
pkg_remove_list.add_unsafe(remove);
}

libdnf5::solv::SolvMap protected_pkgs(pool->nsolvables);
Expand Down

0 comments on commit e4c3f3d

Please sign in to comment.