dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0004-Fix-detection-of-the-latest-module-RhBug1781769.patch

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