Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow obsoletion of protected packages #733

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions libdnf5/rpm/solv/goal_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,19 +580,29 @@ libdnf5::GoalProblem GoalPrivate::protected_in_removals() {
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) {
evan-goode marked this conversation as resolved.
Show resolved Hide resolved
pkg_remove_list.add_unsafe(remove);
}
// We want to allow obsoletion of protected packages, so we do not consider
// obsoletes here, only removes. Previously, obsoletion of protected
// packages was disallowed, but there needed to be some mechanism for
// obsoleting/swapping a protected package, such as to obsolete `dnf` in
// favor of `dnf5`. Obsoleting a package is much harder to do accidentally
// than removing it.

libdnf5::solv::SolvMap protected_pkgs(pool->nsolvables);
if (protected_packages) {
protected_pkgs |= *protected_packages;
}
if (protected_running_kernel.id > 0) {
protected_pkgs.add_unsafe(protected_running_kernel.id);
// Special case: consider the obsoletion of the running kernel as a
// removal. Obsoletion of other protected packages should be allowed.
for (const auto & obsolete : obsoleted) {
if (obsolete == protected_running_kernel.id) {
pkg_remove_list.add_unsafe(obsolete);
}
}
}

removal_of_protected.reset(new libdnf5::solv::SolvMap(std::move(pkg_remove_list)));
Expand Down
Loading