diff --git a/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch b/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch new file mode 100644 index 0000000..57808d6 --- /dev/null +++ b/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch @@ -0,0 +1,170 @@ +From 9224bd0556c5b056ae6250d8aa582dfdcc2de650 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Mon, 13 Jul 2020 22:17:10 +0200 +Subject: [PATCH] Print info about obsoleted packages before transaction + (RhBug:1855542) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- Added number of obsolete packages into transaction summary. +- Added which packages are obsolete and by whom they are replaced. + +The user can run microdnf in test mode (--setopt=tsflags=test) to know +what microdnf will do. However, without this patch, information about +obsolete (replaced as obsolete) packages was missing. + +Example output before patch: +# microdnf install TestB +Package Repository Size +Installing: + TestB-1.0.0-1.noarch ci-obsoletes 5,9 kB +Transaction Summary: + Installing: 1 packages + Reinstalling: 0 packages + Upgrading: 0 packages + Removing: 0 packages + Downgrading: 0 packages +Downloading packages... +Running transaction test... +Installing: TestB;1.0.0-1;noarch;ci-obsoletes +Obsoleting: TestA;1.0.0-1;noarch;installed +Complete. + +Example output after patch: +# microdnf install TestB +Package Repository Size +Installing: + TestB-1.0.0-1.noarch ci-obsoletes 5,9 kB + replacing TestA-1.0.0-1.noarch +Transaction Summary: + Installing: 1 packages + Reinstalling: 0 packages + Upgrading: 0 packages + Obsoleting: 1 packages + Removing: 0 packages + Downgrading: 0 packages +Downloading packages... +Running transaction test... +Installing: TestB;1.0.0-1;noarch;ci-obsoletes +Obsoleting: TestA;1.0.0-1;noarch;installed +Complete. +--- + dnf/dnf-utils.c | 37 ++++++++++++++++++++++++++++--------- + 1 file changed, 28 insertions(+), 9 deletions(-) + +diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c +index c58f519..ff0e891 100644 +--- a/dnf/dnf-utils.c ++++ b/dnf/dnf-utils.c +@@ -3,6 +3,7 @@ + * Copyright © 2010-2015 Richard Hughes + * Copyright © 2016 Colin Walters + * Copyright © 2016-2017 Igor Gnatenko ++ * Copyright © 2017-2020 Jaroslav Rohel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -34,13 +35,15 @@ dnf_package_cmp_cb (DnfPackage **pkg1, DnfPackage **pkg2) + + + static void +-dnf_utils_add_transaction_packages (struct libscols_table *tb, ++dnf_utils_add_transaction_packages (DnfContext *ctx, ++ struct libscols_table *tb, + struct libscols_line *parent, + GPtrArray *pkgs) + { + // sort packages by NEVRA + g_ptr_array_sort (pkgs, (GCompareFunc) dnf_package_cmp_cb); + ++ HyGoal goal = dnf_context_get_goal (ctx); + for (guint i = 0; i < pkgs->len; i++) + { + DnfPackage *pkg = pkgs->pdata[i]; +@@ -48,9 +51,21 @@ dnf_utils_add_transaction_packages (struct libscols_table *tb, + struct libscols_line *ln = scols_table_new_line (tb, parent); + scols_line_set_data (ln, COL_NEVRA, dnf_package_get_nevra (pkg)); + scols_line_set_data (ln, COL_REPO, dnf_package_get_reponame (pkg)); +- char *formatted_pkg_size = g_format_size (dnf_package_get_size (pkg)); ++ g_autofree gchar *formatted_pkg_size = g_format_size (dnf_package_get_size (pkg)); + scols_line_set_data (ln, COL_SIZE, formatted_pkg_size); +- g_free(formatted_pkg_size); ++ ++ if (dnf_package_get_action (pkg) != DNF_STATE_ACTION_REMOVE) ++ { ++ g_autoptr(GPtrArray) pkgs_replaced = hy_goal_list_obsoleted_by_package (goal, pkg); ++ g_ptr_array_sort (pkgs_replaced, (GCompareFunc) dnf_package_cmp_cb); ++ for (guint i = 0; i < pkgs_replaced->len; i++) ++ { ++ DnfPackage *pkg = pkgs_replaced->pdata[i]; ++ struct libscols_line *replacing_ln = scols_table_new_line (tb, ln); ++ g_autofree gchar *replacing_text = g_strconcat ("replacing ", dnf_package_get_nevra (pkg), NULL); ++ scols_line_set_data (replacing_ln, COL_NEVRA, replacing_text); ++ } ++ } + } + } + +@@ -92,10 +107,9 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Installing:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_install); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_install); + } + +- + g_autoptr(GPtrArray) pkgs_reinstall = dnf_goal_get_packages (dnf_context_get_goal (ctx), + DNF_PACKAGE_INFO_REINSTALL, + -1); +@@ -103,7 +117,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Reinstalling:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_reinstall); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_reinstall); + } + + g_autoptr(GPtrArray) pkgs_upgrade = dnf_goal_get_packages (dnf_context_get_goal (ctx), +@@ -113,9 +127,13 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Upgrading:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_upgrade); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_upgrade); + } + ++ g_autoptr(GPtrArray) pkgs_obsolete = dnf_goal_get_packages (dnf_context_get_goal (ctx), ++ DNF_PACKAGE_INFO_OBSOLETE, ++ -1); ++ + g_autoptr(GPtrArray) pkgs_remove = dnf_goal_get_packages (dnf_context_get_goal (ctx), + DNF_PACKAGE_INFO_REMOVE, + -1); +@@ -123,7 +141,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Removing:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_remove); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_remove); + } + + g_autoptr(GPtrArray) pkgs_downgrade = dnf_goal_get_packages (dnf_context_get_goal (ctx), +@@ -133,7 +151,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Downgrading:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_downgrade); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_downgrade); + } + + scols_print_table (tb); +@@ -144,6 +162,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + g_print (" %-15s %4d packages\n", "Installing:", pkgs_install->len); + g_print (" %-15s %4d packages\n", "Reinstalling:", pkgs_reinstall->len); + g_print (" %-15s %4d packages\n", "Upgrading:", pkgs_upgrade->len); ++ g_print (" %-15s %4d packages\n", "Obsoleting:", pkgs_obsolete->len); + g_print (" %-15s %4d packages\n", "Removing:", pkgs_remove->len); + g_print (" %-15s %4d packages\n", "Downgrading:", pkgs_downgrade->len); + diff --git a/SPECS/microdnf.spec b/SPECS/microdnf.spec index d8dfed4..0089caa 100644 --- a/SPECS/microdnf.spec +++ b/SPECS/microdnf.spec @@ -1,8 +1,8 @@ -%global libdnf_version 0.55.0 +%global libdnf_version 0.55.0-4 Name: microdnf Version: 3.4.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Minimal C implementation of DNF License: GPLv3+ @@ -11,6 +11,7 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Patch0: 0001-Add-module-enable-disable-reset-command.patch Patch1: 0002-Add-support-for-setting-a-platform-module-ID.patch Patch2: 0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch +Patch3: 0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch BuildRequires: gcc BuildRequires: meson >= 0.36.0 @@ -56,6 +57,9 @@ capabilities are intentionally not implemented in Micro DNF. %{_bindir}/%{name} %changelog +* Mon Feb 08 2021 Nicola Sella - 3.4.0-4 +- Print info about obsoleted packages before transaction (RhBug:1855542) + * Fri Jan 29 2021 Nicola Sella - 3.4.0-3 - Patch: Add support for setting a platform module ID - Rename "update" command to "upgrade", "update" remain as compatibility alias