dnf/SOURCES/0004-Fix-detection-of-the-latest-module-RhBug1781769.patch
2021-09-10 09:03:27 +00:00

158 lines
6.0 KiB
Diff

From c8d79c0b9956aeeb8cd3a0422656b030d4656578 Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Mon, 9 Dec 2019 12:32:18 +0100
Subject: [PATCH 1/2] Fix detection of the latest module (RhBug:1781769)
The code originally compared module version as a string, but it should
be compared as a int.
https://bugzilla.redhat.com/show_bug.cgi?id=1781769
Closes: #1548
Approved by: m-blaha
---
dnf/module/module_base.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
index 8093ab443..64bad84b6 100644
--- a/dnf/module/module_base.py
+++ b/dnf/module/module_base.py
@@ -285,7 +285,7 @@ class ModuleBase(object):
if module_list:
latest = module_list[0]
for module in module_list[1:]:
- if module.getVersion() > latest.getVersion():
+ if module.getVersionNum() > latest.getVersionNum():
latest = module
return latest
--
2.21.0
From 44e9095404569dbf8a19726eb79be8e580bed60c Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Wed, 11 Dec 2019 09:52:16 +0100
Subject: [PATCH 2/2] Improve transaction table formatting
It improves formatting of transaction table in case when terminal has
unknown width.
Closes: #1548
Approved by: m-blaha
---
dnf/cli/output.py | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/dnf/cli/output.py b/dnf/cli/output.py
index a03df610c..2ff41b625 100644
--- a/dnf/cli/output.py
+++ b/dnf/cli/output.py
@@ -224,16 +224,32 @@ class Output(object):
if total_width is None:
total_width = self.term.real_columns
+ # We start allocating 1 char to everything but the last column, and a
+ # space between each (again, except for the last column). Because
+ # at worst we are better with:
+ # |one two three|
+ # | four |
+ # ...than:
+ # |one two three|
+ # | f|
+ # |our |
+ # ...the later being what we get if we pre-allocate the last column, and
+ # thus. the space, due to "three" overflowing it's column by 2 chars.
+ if columns is None:
+ columns = [1] * (cols - 1)
+ columns.append(0)
+
# i'm not able to get real terminal width so i'm probably
# running in non interactive terminal (pipe to grep, redirect to file...)
# avoid splitting lines to enable filtering output
if not total_width:
full_columns = []
- for col in data:
+ for d in xrange(0, cols):
+ col = data[d]
if col:
full_columns.append(col[-1][0])
else:
- full_columns.append(0)
+ full_columns.append(columns[d] + 1)
full_columns[0] += len(indent)
# if possible, try to keep default width (usually 80 columns)
default_width = self.term.columns
@@ -241,20 +257,6 @@ class Output(object):
return full_columns
total_width = default_width
- # We start allocating 1 char to everything but the last column, and a
- # space between each (again, except for the last column). Because
- # at worst we are better with:
- # |one two three|
- # | four |
- # ...than:
- # |one two three|
- # | f|
- # |our |
- # ...the later being what we get if we pre-allocate the last column, and
- # thus. the space, due to "three" overflowing it's column by 2 chars.
- if columns is None:
- columns = [1] * (cols - 1)
- columns.append(0)
total_width -= (sum(columns) + (cols - 1) + exact_width(indent))
if not columns[-1]:
@@ -1273,7 +1275,7 @@ class Output(object):
skip_str = skip_str % _(" or part of a group")
pkglist_lines.append((skip_str, lines))
-
+ output_width = self.term.columns
if not data['n'] and not self.base._moduleContainer.isChanged() and not \
(self.base._history and (self.base._history.group or self.base._history.env)):
return u''
@@ -1283,6 +1285,8 @@ class Output(object):
columns = self.calcColumns(data, indent=" ", columns=columns,
remainder_column=2, total_width=total_width)
(n_wid, a_wid, v_wid, r_wid, s_wid) = columns
+ real_width = sum(columns) + 5
+ output_width = output_width if output_width >= real_width else real_width
# Do not use 'Package' without context. Using context resolves
# RhBug 1302935 as a side effect.
@@ -1325,13 +1329,13 @@ class Output(object):
# Translators: This is the full (unabbreviated) term 'Size'.
C_('long', 'Size'))
- out = [u"%s\n%s\n%s\n" % ('=' * self.term.columns,
+ out = [u"%s\n%s\n%s\n" % ('=' * output_width,
self.fmtColumns(((msg_package, -n_wid),
(msg_arch, -a_wid),
(msg_version, -v_wid),
(msg_repository, -r_wid),
(msg_size, s_wid)), u" "),
- '=' * self.term.columns)]
+ '=' * output_width)]
for (action, lines) in pkglist_lines:
if lines:
@@ -1349,11 +1353,10 @@ class Output(object):
if lines:
out.append(totalmsg)
-
out.append(_("""
Transaction Summary
%s
-""") % ('=' * self.term.columns))
+""") % ('=' * output_width))
summary_data = (
(_('Install'), len(list_bunch.installed) +
len(list_bunch.installed_group) +
--
2.21.0