Skip to content

Commit

Permalink
Revert "advisory: add running kernel before pkg_specs filtering"
Browse files Browse the repository at this point in the history
This reverts commit f1283c9.

Because running kernel packages were added to newly created
package_query, which already contained all packages (so resulted in
no-op).
Running kernels need to be added after filtering the latest installed
versions but before applying --contains-pkgs option.
  • Loading branch information
m-blaha authored and kontura committed Jul 20, 2023
1 parent c17c4f6 commit e8b9c30
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dnf5/commands/advisory/advisory_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void AdvisoryInfoCommand::process_and_print_queries(
packages.filter_installed();
packages.filter_latest_evr();

add_running_kernel_packages(ctx.base, packages);

advisories.filter_packages(packages, libdnf5::sack::QueryCmp::GT);
}

Expand Down
6 changes: 3 additions & 3 deletions dnf5/commands/advisory/advisory_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ namespace dnf5 {
using namespace libdnf5::cli;

void AdvisoryListCommand::process_and_print_queries(
[[maybe_unused]] Context & ctx,
libdnf5::advisory::AdvisoryQuery & advisories,
libdnf5::rpm::PackageQuery & packages) {
Context & ctx, libdnf5::advisory::AdvisoryQuery & advisories, libdnf5::rpm::PackageQuery & packages) {
std::vector<libdnf5::advisory::AdvisoryPackage> installed_pkgs;
std::vector<libdnf5::advisory::AdvisoryPackage> not_installed_pkgs;

Expand All @@ -50,6 +48,8 @@ void AdvisoryListCommand::process_and_print_queries(
packages.filter_installed();
packages.filter_latest_evr();

add_running_kernel_packages(ctx.base, packages);

not_installed_pkgs = advisories.get_advisory_packages_sorted(packages, libdnf5::sack::QueryCmp::GT);
}

Expand Down
9 changes: 1 addition & 8 deletions dnf5/commands/advisory/advisory_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void AdvisorySubCommand::set_argument_parser() {
// When the running kernel has available advisories show them because the system
// is vulnerable (even if the newer fixed version of kernel is already installed).
// DNF4 bug with behavior description: https://bugzilla.redhat.com/show_bug.cgi?id=1728004
static void add_running_kernel_packages(libdnf5::Base & base, libdnf5::rpm::PackageQuery & package_query) {
void AdvisorySubCommand::add_running_kernel_packages(libdnf5::Base & base, libdnf5::rpm::PackageQuery & package_query) {
auto kernel = base.get_rpm_package_sack()->get_running_kernel();
if (kernel.get_id().id > 0) {
libdnf5::rpm::PackageQuery kernel_query(base);
Expand All @@ -82,13 +82,6 @@ void AdvisorySubCommand::run() {
auto & ctx = get_context();

libdnf5::rpm::PackageQuery package_query(ctx.base);

// When running with the default filter (available)
if (!all->get_value() && !installed->get_value() && !updates->get_value()) {
add_running_kernel_packages(ctx.base, package_query);
}


auto package_specs_strs = contains_pkgs->get_value();
// Filter packages by name patterns if given
if (package_specs_strs.size() > 0) {
Expand Down
2 changes: 2 additions & 0 deletions dnf5/commands/advisory/advisory_subcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class AdvisorySubCommand : public Command {
virtual void process_and_print_queries(
Context & ctx, libdnf5::advisory::AdvisoryQuery & advisories, libdnf5::rpm::PackageQuery & packages) = 0;

void add_running_kernel_packages(libdnf5::Base & base, libdnf5::rpm::PackageQuery & package_query);

std::unique_ptr<AdvisoryAvailableOption> available{nullptr};
std::unique_ptr<AdvisoryInstalledOption> installed{nullptr};
std::unique_ptr<AdvisoryAllOption> all{nullptr};
Expand Down
2 changes: 2 additions & 0 deletions dnf5/commands/advisory/advisory_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ void AdvisorySummaryCommand::process_and_print_queries(
packages.filter_installed();
packages.filter_latest_evr();

add_running_kernel_packages(ctx.base, packages);

advisories.filter_packages(packages, libdnf5::sack::QueryCmp::GT);
mode = _("Available");
}
Expand Down

0 comments on commit e8b9c30

Please sign in to comment.