|
|
8c93e6 |
From fa6afad083ffc19438603f43d17785f5741505b4 Mon Sep 17 00:00:00 2001
|
|
|
8c93e6 |
From: Jaroslav Rohel <jrohel@redhat.com>
|
|
|
8c93e6 |
Date: Mon, 16 Dec 2019 12:52:41 +0100
|
|
|
8c93e6 |
Subject: [PATCH 1/2] Sort packages in transaction output by nevra
|
|
|
8c93e6 |
(RhBug:1773436)
|
|
|
8c93e6 |
|
|
|
8c93e6 |
---
|
|
|
8c93e6 |
dnf/cli/output.py | 2 +-
|
|
|
8c93e6 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
8c93e6 |
|
|
|
8c93e6 |
diff --git a/dnf/cli/output.py b/dnf/cli/output.py
|
|
|
8c93e6 |
index 2ff41b6255..1d3eb1e94a 100644
|
|
|
8c93e6 |
--- a/dnf/cli/output.py
|
|
|
8c93e6 |
+++ b/dnf/cli/output.py
|
|
|
8c93e6 |
@@ -1147,7 +1147,7 @@ def _add_line(lines, data, a_wid, po, obsoletes=[]):
|
|
|
8c93e6 |
for i in tsi._item.getReplacedBy():
|
|
|
8c93e6 |
replaces.setdefault(i, set()).add(tsi)
|
|
|
8c93e6 |
|
|
|
8c93e6 |
- for tsi in pkglist:
|
|
|
8c93e6 |
+ for tsi in sorted(pkglist, key=lambda x: x.pkg):
|
|
|
8c93e6 |
if tsi.action not in dnf.transaction.FORWARD_ACTIONS + [libdnf.transaction.TransactionItemAction_REMOVE]:
|
|
|
8c93e6 |
continue
|
|
|
8c93e6 |
|
|
|
8c93e6 |
|
|
|
8c93e6 |
From 0779b458ca30e895b72bcfb2d513c13b12f605df Mon Sep 17 00:00:00 2001
|
|
|
8c93e6 |
From: Jaroslav Rohel <jrohel@redhat.com>
|
|
|
8c93e6 |
Date: Mon, 16 Dec 2019 14:53:00 +0100
|
|
|
8c93e6 |
Subject: [PATCH 2/2] Sort packages in post transaction output by nevra
|
|
|
8c93e6 |
|
|
|
8c93e6 |
---
|
|
|
8c93e6 |
dnf/cli/output.py | 20 ++++++++++++++++++--
|
|
|
8c93e6 |
1 file changed, 18 insertions(+), 2 deletions(-)
|
|
|
8c93e6 |
|
|
|
8c93e6 |
diff --git a/dnf/cli/output.py b/dnf/cli/output.py
|
|
|
8c93e6 |
index 1d3eb1e94a..5dc0af6f4b 100644
|
|
|
8c93e6 |
--- a/dnf/cli/output.py
|
|
|
8c93e6 |
+++ b/dnf/cli/output.py
|
|
|
8c93e6 |
@@ -23,6 +23,7 @@
|
|
|
8c93e6 |
|
|
|
8c93e6 |
from copy import deepcopy
|
|
|
8c93e6 |
import fnmatch
|
|
|
8c93e6 |
+import functools
|
|
|
8c93e6 |
import hawkey
|
|
|
8c93e6 |
import itertools
|
|
|
8c93e6 |
import libdnf.transaction
|
|
|
8c93e6 |
@@ -1449,11 +1450,26 @@ def _fits_in_cols(msgs, num):
|
|
|
8c93e6 |
col_lens[col] *= -1
|
|
|
8c93e6 |
return col_lens
|
|
|
8c93e6 |
|
|
|
8c93e6 |
+ def _tsi_or_pkg_nevra_cmp(item1, item2):
|
|
|
8c93e6 |
+ """Compares two transaction items or packages by nevra.
|
|
|
8c93e6 |
+ Used as a fallback when tsi does not contain package object.
|
|
|
8c93e6 |
+ """
|
|
|
8c93e6 |
+ ret = (item1.name > item2.name) - (item1.name < item2.name)
|
|
|
8c93e6 |
+ if ret != 0:
|
|
|
8c93e6 |
+ return ret
|
|
|
8c93e6 |
+ nevra1 = hawkey.NEVRA(name=item1.name, epoch=item1.epoch, version=item1.version,
|
|
|
8c93e6 |
+ release=item1.release, arch=item1.arch)
|
|
|
8c93e6 |
+ nevra2 = hawkey.NEVRA(name=item2.name, epoch=item2.epoch, version=item2.version,
|
|
|
8c93e6 |
+ release=item2.release, arch=item2.arch)
|
|
|
8c93e6 |
+ ret = nevra1.evr_cmp(nevra2, self.sack)
|
|
|
8c93e6 |
+ if ret != 0:
|
|
|
8c93e6 |
+ return ret
|
|
|
8c93e6 |
+ return (item1.arch > item2.arch) - (item1.arch < item2.arch)
|
|
|
8c93e6 |
+
|
|
|
8c93e6 |
out = ''
|
|
|
8c93e6 |
list_bunch = _make_lists(transaction, self.base._goal)
|
|
|
8c93e6 |
skipped_conflicts, skipped_broken = self._skipped_packages(report_problems=False)
|
|
|
8c93e6 |
skipped = skipped_conflicts.union(skipped_broken)
|
|
|
8c93e6 |
- skipped = sorted(set([str(pkg) for pkg in skipped]))
|
|
|
8c93e6 |
|
|
|
8c93e6 |
for (action, tsis) in [(_('Upgraded'), list_bunch.upgraded),
|
|
|
8c93e6 |
(_('Downgraded'), list_bunch.downgraded),
|
|
|
8c93e6 |
@@ -1471,7 +1487,7 @@ def _fits_in_cols(msgs, num):
|
|
|
8c93e6 |
continue
|
|
|
8c93e6 |
msgs = []
|
|
|
8c93e6 |
out += '\n%s:\n' % action
|
|
|
8c93e6 |
- for tsi in tsis:
|
|
|
8c93e6 |
+ for tsi in sorted(tsis, key=functools.cmp_to_key(_tsi_or_pkg_nevra_cmp)):
|
|
|
8c93e6 |
msgs.append(str(tsi))
|
|
|
8c93e6 |
for num in (8, 7, 6, 5, 4, 3, 2):
|
|
|
8c93e6 |
cols = _fits_in_cols(msgs, num)
|