|
|
922fe2 |
From f1fbef17862e033bf9518bd318339b405f2664dd Mon Sep 17 00:00:00 2001
|
|
|
922fe2 |
From: Nicola Sella <nsella@redhat.com>
|
|
|
922fe2 |
Date: Mon, 22 Mar 2021 17:37:51 +0100
|
|
|
922fe2 |
Subject: [PATCH 1/2] Better explain traceback of rpm.error with dnf
|
|
|
922fe2 |
|
|
|
922fe2 |
=changelog=
|
|
|
922fe2 |
msg: Add dnf.error message to explain rpm.error traceback when package not found after resolving a transaction
|
|
|
922fe2 |
type: bugfix
|
|
|
922fe2 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1815327
|
|
|
922fe2 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1887293
|
|
|
922fe2 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1909845
|
|
|
922fe2 |
---
|
|
|
922fe2 |
dnf/db/group.py | 78 ++++++++++++++++++++++++++-----------------------
|
|
|
922fe2 |
1 file changed, 41 insertions(+), 37 deletions(-)
|
|
|
922fe2 |
|
|
|
922fe2 |
diff --git a/dnf/db/group.py b/dnf/db/group.py
|
|
|
922fe2 |
index 312e3b98..3a17019a 100644
|
|
|
922fe2 |
--- a/dnf/db/group.py
|
|
|
922fe2 |
+++ b/dnf/db/group.py
|
|
|
922fe2 |
@@ -26,6 +26,7 @@ import dnf.exceptions
|
|
|
922fe2 |
from dnf.i18n import _
|
|
|
922fe2 |
from dnf.util import logger
|
|
|
922fe2 |
|
|
|
922fe2 |
+import rpm
|
|
|
922fe2 |
|
|
|
922fe2 |
class PersistorBase(object):
|
|
|
922fe2 |
def __init__(self, history):
|
|
|
922fe2 |
@@ -316,43 +317,46 @@ class RPMTransaction(object):
|
|
|
922fe2 |
modular_problems = 0
|
|
|
922fe2 |
|
|
|
922fe2 |
for tsi in self:
|
|
|
922fe2 |
- if tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADE:
|
|
|
922fe2 |
- hdr = tsi.pkg._header
|
|
|
922fe2 |
- modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
- ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADED:
|
|
|
922fe2 |
- ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_INSTALL:
|
|
|
922fe2 |
- hdr = tsi.pkg._header
|
|
|
922fe2 |
- modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
- ts.addInstall(hdr, tsi, 'i')
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETE:
|
|
|
922fe2 |
- hdr = tsi.pkg._header
|
|
|
922fe2 |
- modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
- ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETED:
|
|
|
922fe2 |
- ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALL:
|
|
|
922fe2 |
- # note: in rpm 4.12 there should not be set
|
|
|
922fe2 |
- # rpm.RPMPROB_FILTER_REPLACEPKG to work
|
|
|
922fe2 |
- hdr = tsi.pkg._header
|
|
|
922fe2 |
- modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
- ts.addReinstall(hdr, tsi)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALLED:
|
|
|
922fe2 |
- # Required when multiple packages with the same NEVRA marked as installed
|
|
|
922fe2 |
- ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_REMOVE:
|
|
|
922fe2 |
- ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADE:
|
|
|
922fe2 |
- hdr = tsi.pkg._header
|
|
|
922fe2 |
- modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
- ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADED:
|
|
|
922fe2 |
- ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
- elif tsi.action == libdnf.transaction.TransactionItemAction_REASON_CHANGE:
|
|
|
922fe2 |
- pass
|
|
|
922fe2 |
- else:
|
|
|
922fe2 |
- raise RuntimeError("TransactionItemAction not handled: %s" % tsi.action)
|
|
|
922fe2 |
+ try:
|
|
|
922fe2 |
+ if tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADE:
|
|
|
922fe2 |
+ hdr = tsi.pkg._header
|
|
|
922fe2 |
+ modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
+ ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADED:
|
|
|
922fe2 |
+ ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_INSTALL:
|
|
|
922fe2 |
+ hdr = tsi.pkg._header
|
|
|
922fe2 |
+ modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
+ ts.addInstall(hdr, tsi, 'i')
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETE:
|
|
|
922fe2 |
+ hdr = tsi.pkg._header
|
|
|
922fe2 |
+ modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
+ ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETED:
|
|
|
922fe2 |
+ ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALL:
|
|
|
922fe2 |
+ # note: in rpm 4.12 there should not be set
|
|
|
922fe2 |
+ # rpm.RPMPROB_FILTER_REPLACEPKG to work
|
|
|
922fe2 |
+ hdr = tsi.pkg._header
|
|
|
922fe2 |
+ modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
+ ts.addReinstall(hdr, tsi)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALLED:
|
|
|
922fe2 |
+ # Required when multiple packages with the same NEVRA marked as installed
|
|
|
922fe2 |
+ ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_REMOVE:
|
|
|
922fe2 |
+ ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADE:
|
|
|
922fe2 |
+ hdr = tsi.pkg._header
|
|
|
922fe2 |
+ modular_problems += self._test_fail_safe(hdr, tsi.pkg)
|
|
|
922fe2 |
+ ts.addInstall(hdr, tsi, 'u')
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADED:
|
|
|
922fe2 |
+ ts.addErase(tsi.pkg.idx)
|
|
|
922fe2 |
+ elif tsi.action == libdnf.transaction.TransactionItemAction_REASON_CHANGE:
|
|
|
922fe2 |
+ pass
|
|
|
922fe2 |
+ else:
|
|
|
922fe2 |
+ raise RuntimeError("TransactionItemAction not handled: %s" % tsi.action)
|
|
|
922fe2 |
+ except rpm.error as e:
|
|
|
922fe2 |
+ raise dnf.exceptions.Error(_("An rpm exception occurred: %s" % e))
|
|
|
922fe2 |
if modular_problems:
|
|
|
922fe2 |
raise dnf.exceptions.Error(_("No available modular metadata for modular package"))
|
|
|
922fe2 |
|
|
|
922fe2 |
--
|
|
|
922fe2 |
2.39.0
|
|
|
922fe2 |
|