Skip to content

Commit

Permalink
dnf5: Command "check": Improve conflicts detection
Browse files Browse the repository at this point in the history
Also detects a conflict in case if name of package with conflicting
"provide" is different from the conflicting "provide" name.

For example, both packages "pipewire-media-session" and "wireplumber"
provide "pipewire-session-manager" and conflict.
  • Loading branch information
jrohel committed Nov 21, 2023
1 parent 5359105 commit bbda0d3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dnf5/commands/check/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,19 @@ void CheckCommand::run() {
for (auto conflict : pkg.get_conflicts()) {
auto conflicted = installed;
conflicted.filter_provides(conflict);
auto conflict_str = conflict.to_string();
conflicted.filter_name({conflict_str.substr(0, conflict_str.find_first_of(" \t\n\r\f\v"))});
for (auto conflict_pkg : conflicted) {
if (conflict_pkg == pkg) {
// skip self conflicts
continue;
}
// If A conflicts with B then B conflicts with A.
// Prints the packages in a row sorted to find and remove duplicate rows.
bool swap = cmp_nevra(conflict_pkg, pkg);
auto msg = fmt::format(
"{} has installed conflict \"{}\": {}",
pkg.get_full_nevra(),
conflict_str,
conflict_pkg.get_full_nevra());
swap ? conflict_pkg.get_full_nevra() : pkg.get_full_nevra(),
conflict.to_string(),
swap ? pkg.get_full_nevra() : conflict_pkg.get_full_nevra());
output_lines.insert(msg);
}
}
Expand Down

0 comments on commit bbda0d3

Please sign in to comment.