|
|
1f580a |
From 6a6ab3e12b4fe0f3fc402a6b99932640fabccc32 Mon Sep 17 00:00:00 2001
|
|
|
1f580a |
From: Marek Blaha <mblaha@redhat.com>
|
|
|
1f580a |
Date: Wed, 3 Jul 2019 10:49:20 +0200
|
|
|
1f580a |
Subject: [PATCH 1/2] Method to get catched rpm errors from RPMTransaction
|
|
|
1f580a |
(RhBug:1677199)
|
|
|
1f580a |
|
|
|
1f580a |
This method enables iterating through messages logged by underlaying
|
|
|
1f580a |
rpm. The messages could be then logged by dnf, printed to user...
|
|
|
1f580a |
---
|
|
|
1f580a |
dnf/yum/rpmtrans.py | 6 ++++++
|
|
|
1f580a |
1 file changed, 6 insertions(+)
|
|
|
1f580a |
|
|
|
1f580a |
diff --git a/dnf/yum/rpmtrans.py b/dnf/yum/rpmtrans.py
|
|
|
1f580a |
index 8a5bd4731..b0fd9b6eb 100644
|
|
|
1f580a |
--- a/dnf/yum/rpmtrans.py
|
|
|
1f580a |
+++ b/dnf/yum/rpmtrans.py
|
|
|
1f580a |
@@ -210,6 +210,12 @@ class RPMTransaction(object):
|
|
|
1f580a |
except IOError:
|
|
|
1f580a |
pass
|
|
|
1f580a |
|
|
|
1f580a |
+ def messages(self):
|
|
|
1f580a |
+ messages = self._scriptOutput()
|
|
|
1f580a |
+ if messages:
|
|
|
1f580a |
+ for line in messages.splitlines():
|
|
|
1f580a |
+ yield ucd(line)
|
|
|
1f580a |
+
|
|
|
1f580a |
def _scriptout(self):
|
|
|
1f580a |
msgs = self._scriptOutput()
|
|
|
1f580a |
for display in self.displays:
|
|
|
1f580a |
--
|
|
|
1f580a |
2.21.0
|
|
|
1f580a |
|
|
|
1f580a |
|
|
|
1f580a |
From 61e0b7c553fe0c04dfeb3b6d4c16fa36e4eb26f4 Mon Sep 17 00:00:00 2001
|
|
|
1f580a |
From: Marek Blaha <mblaha@redhat.com>
|
|
|
1f580a |
Date: Wed, 3 Jul 2019 10:54:42 +0200
|
|
|
1f580a |
Subject: [PATCH 2/2] Print rpm error messages during transaction
|
|
|
1f580a |
(RhBug:1677199)
|
|
|
1f580a |
|
|
|
1f580a |
This patch lets the rpm error messages to be passed on to the user.
|
|
|
1f580a |
Original code basically considered all rpm errors as "Failed to obtain
|
|
|
1f580a |
the transaction lock", which is obviously not always the case. Now dnf
|
|
|
1f580a |
prints out original rpm messages so that user could find out what the
|
|
|
1f580a |
real problem is.
|
|
|
1f580a |
|
|
|
1f580a |
https://bugzilla.redhat.com/show_bug.cgi?id=1677199
|
|
|
1f580a |
---
|
|
|
1f580a |
dnf/base.py | 16 ++++++++--------
|
|
|
1f580a |
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
|
1f580a |
|
|
|
1f580a |
diff --git a/dnf/base.py b/dnf/base.py
|
|
|
1f580a |
index 237ad397d..2c5d17e8b 100644
|
|
|
1f580a |
--- a/dnf/base.py
|
|
|
1f580a |
+++ b/dnf/base.py
|
|
|
1f580a |
@@ -983,16 +983,16 @@ class Base(object):
|
|
|
1f580a |
if errors is None:
|
|
|
1f580a |
pass
|
|
|
1f580a |
elif len(errors) == 0:
|
|
|
1f580a |
- # this is a particularly tricky case happening also when rpm failed
|
|
|
1f580a |
- # to obtain the transaction lock. We can only try to see if a
|
|
|
1f580a |
- # particular element failed and if not, decide that is the
|
|
|
1f580a |
- # case.
|
|
|
1f580a |
+ # If there is no failing element it means that some "global" error
|
|
|
1f580a |
+ # occured (like rpm failed to obtain the transaction lock). Just pass
|
|
|
1f580a |
+ # the rpm logs on to the user and raise an Error.
|
|
|
1f580a |
+ # If there are failing elements the problem is related to those
|
|
|
1f580a |
+ # elements and the Error is raised later, after saving the failure
|
|
|
1f580a |
+ # to the history and printing out the transaction table to user.
|
|
|
1f580a |
failed = [el for el in self._ts if el.Failed()]
|
|
|
1f580a |
if not failed:
|
|
|
1f580a |
- login = dnf.util.get_effective_login()
|
|
|
1f580a |
- msg = _("Failed to obtain the transaction lock "
|
|
|
1f580a |
- "(logged in as: %s).")
|
|
|
1f580a |
- logger.critical(msg, login)
|
|
|
1f580a |
+ for msg in cb.messages():
|
|
|
1f580a |
+ logger.critical(_('RPM: {}').format(msg))
|
|
|
1f580a |
msg = _('Could not run transaction.')
|
|
|
1f580a |
raise dnf.exceptions.Error(msg)
|
|
|
1f580a |
else:
|
|
|
1f580a |
--
|
|
|
1f580a |
2.21.0
|
|
|
1f580a |
|