Skip to content

Commit

Permalink
Limit search pattern for remove command
Browse files Browse the repository at this point in the history
It prevents additional removal after succesful remove using the same spec.
Spec `foo`. The original code during the first run removes (dnf5 remove foo)
all packages with the name `foo`. In the next run (dnf5 remove foo) it
removes all packages providing `foo`. The next run will remove packages
providing binary `foo`. This behavior is inconsistent.

Resolves: https://issues.redhat.com/browse/RHEL-5747
  • Loading branch information
j-mracek committed Jan 4, 2024
1 parent 8a797b9 commit 5a18594
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dnf5/commands/remove/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,16 @@ void RemoveCommand::configure() {

void RemoveCommand::run() {
auto goal = get_context().get_goal();

// Limit remove spec capabity to prevent multiple matches. Remove command should not match anything after performing
// a remove action with the same spec. NEVRA and filenames are the only types that have no overlap.
libdnf5::GoalJobSettings settings;
settings.with_nevra = true;
settings.with_provides = false;
settings.with_filenames = true;
settings.with_binaries = false;
for (const auto & spec : pkg_specs) {
goal->add_remove(spec);
goal->add_remove(spec, settings);
}
// To enable removal of dependency packages it requires to use allow_erasing
goal->set_allow_erasing(true);
Expand Down

0 comments on commit 5a18594

Please sign in to comment.