diff --git a/dnf5-plugins/needs_restarting_plugin/needs_restarting.cpp b/dnf5-plugins/needs_restarting_plugin/needs_restarting.cpp index 2624f5034a..9d67d3bea5 100644 --- a/dnf5-plugins/needs_restarting_plugin/needs_restarting.cpp +++ b/dnf5-plugins/needs_restarting_plugin/needs_restarting.cpp @@ -195,8 +195,16 @@ void NeedsRestartingCommand::system_needs_restarting(Context & ctx) { << "Reboot should not be necessary." << std::endl; } else { std::cout << "Core libraries or services have been updated since boot-up:" << std::endl; + std::vector need_reboot_names; for (const auto & pkg : need_reboot) { - std::cout << " * " << pkg.get_name() << std::endl; + need_reboot_names.emplace_back(pkg.get_name()); + } + std::sort(need_reboot_names.begin(), need_reboot_names.end()); + need_reboot_names.erase( + std::unique(need_reboot_names.begin(), need_reboot_names.end()), need_reboot_names.end()); + + for (const auto & pkg_name : need_reboot_names) { + std::cout << " * " << pkg_name << std::endl; } std::cout << std::endl << "Reboot is required to fully utilize these updates." << std::endl diff --git a/libdnf5/rpm/package_query.cpp b/libdnf5/rpm/package_query.cpp index 26d3e49690..9d6e4c5369 100644 --- a/libdnf5/rpm/package_query.cpp +++ b/libdnf5/rpm/package_query.cpp @@ -2852,11 +2852,11 @@ static const std::unordered_set CORE_PACKAGE_NAMES = { void PackageQuery::filter_reboot_suggested() { auto & pool = get_rpm_pool(p_impl->base); - libdnf5::solv::SolvMap filter_result{pool.get_nsolvables()}; + libdnf5::solv::SolvMap core_packages{pool.get_nsolvables()}; for (const auto & pkg : *this) { if (CORE_PACKAGE_NAMES.contains(pkg.get_name())) { - filter_result.add_unsafe(pkg.get_id().id); + core_packages.add_unsafe(pkg.get_id().id); } } @@ -2864,15 +2864,9 @@ void PackageQuery::filter_reboot_suggested() { auto reboot_advisories = advisories.get_advisory_packages_sorted_by_name_arch_evr(); std::erase_if(reboot_advisories, [](const auto & pkg) { return !pkg.get_reboot_suggested(); }); - const auto & cmp_naevr = libdnf5::rpm::cmp_naevr; - for (const auto & pkg : *this) { - auto lower = std::lower_bound(reboot_advisories.begin(), reboot_advisories.end(), pkg, cmp_naevr); - if (lower != reboot_advisories.end() && lower->get_nevra() == pkg.get_nevra()) { - filter_result.add_unsafe(pkg.get_id().id); - } - } + PQImpl::filter_sorted_advisory_pkgs(*this, reboot_advisories, libdnf5::sack::QueryCmp::EQ); - *p_impl &= filter_result; + *p_impl |= core_packages; } } // namespace libdnf5::rpm