chantra / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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