diff --git a/0038-Better-explain-traceback-of-rpm.error-with-dnf.patch b/0038-Better-explain-traceback-of-rpm.error-with-dnf.patch new file mode 100644 index 0000000..2282e18 --- /dev/null +++ b/0038-Better-explain-traceback-of-rpm.error-with-dnf.patch @@ -0,0 +1,114 @@ +From f1fbef17862e033bf9518bd318339b405f2664dd Mon Sep 17 00:00:00 2001 +From: Nicola Sella +Date: Mon, 22 Mar 2021 17:37:51 +0100 +Subject: [PATCH 1/2] Better explain traceback of rpm.error with dnf + +=changelog= +msg: Add dnf.error message to explain rpm.error traceback when package not found after resolving a transaction +type: bugfix +resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1815327 +resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1887293 +resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1909845 +--- + dnf/db/group.py | 78 ++++++++++++++++++++++++++----------------------- + 1 file changed, 41 insertions(+), 37 deletions(-) + +diff --git a/dnf/db/group.py b/dnf/db/group.py +index 312e3b98..3a17019a 100644 +--- a/dnf/db/group.py ++++ b/dnf/db/group.py +@@ -26,6 +26,7 @@ import dnf.exceptions + from dnf.i18n import _ + from dnf.util import logger + ++import rpm + + class PersistorBase(object): + def __init__(self, history): +@@ -316,43 +317,46 @@ class RPMTransaction(object): + modular_problems = 0 + + for tsi in self: +- if tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADE: +- hdr = tsi.pkg._header +- modular_problems += self._test_fail_safe(hdr, tsi.pkg) +- ts.addInstall(hdr, tsi, 'u') +- elif tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADED: +- ts.addErase(tsi.pkg.idx) +- elif tsi.action == libdnf.transaction.TransactionItemAction_INSTALL: +- hdr = tsi.pkg._header +- modular_problems += self._test_fail_safe(hdr, tsi.pkg) +- ts.addInstall(hdr, tsi, 'i') +- elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETE: +- hdr = tsi.pkg._header +- modular_problems += self._test_fail_safe(hdr, tsi.pkg) +- ts.addInstall(hdr, tsi, 'u') +- elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETED: +- ts.addErase(tsi.pkg.idx) +- elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALL: +- # note: in rpm 4.12 there should not be set +- # rpm.RPMPROB_FILTER_REPLACEPKG to work +- hdr = tsi.pkg._header +- modular_problems += self._test_fail_safe(hdr, tsi.pkg) +- ts.addReinstall(hdr, tsi) +- elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALLED: +- # Required when multiple packages with the same NEVRA marked as installed +- ts.addErase(tsi.pkg.idx) +- elif tsi.action == libdnf.transaction.TransactionItemAction_REMOVE: +- ts.addErase(tsi.pkg.idx) +- elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADE: +- hdr = tsi.pkg._header +- modular_problems += self._test_fail_safe(hdr, tsi.pkg) +- ts.addInstall(hdr, tsi, 'u') +- elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADED: +- ts.addErase(tsi.pkg.idx) +- elif tsi.action == libdnf.transaction.TransactionItemAction_REASON_CHANGE: +- pass +- else: +- raise RuntimeError("TransactionItemAction not handled: %s" % tsi.action) ++ try: ++ if tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADE: ++ hdr = tsi.pkg._header ++ modular_problems += self._test_fail_safe(hdr, tsi.pkg) ++ ts.addInstall(hdr, tsi, 'u') ++ elif tsi.action == libdnf.transaction.TransactionItemAction_DOWNGRADED: ++ ts.addErase(tsi.pkg.idx) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_INSTALL: ++ hdr = tsi.pkg._header ++ modular_problems += self._test_fail_safe(hdr, tsi.pkg) ++ ts.addInstall(hdr, tsi, 'i') ++ elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETE: ++ hdr = tsi.pkg._header ++ modular_problems += self._test_fail_safe(hdr, tsi.pkg) ++ ts.addInstall(hdr, tsi, 'u') ++ elif tsi.action == libdnf.transaction.TransactionItemAction_OBSOLETED: ++ ts.addErase(tsi.pkg.idx) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALL: ++ # note: in rpm 4.12 there should not be set ++ # rpm.RPMPROB_FILTER_REPLACEPKG to work ++ hdr = tsi.pkg._header ++ modular_problems += self._test_fail_safe(hdr, tsi.pkg) ++ ts.addReinstall(hdr, tsi) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_REINSTALLED: ++ # Required when multiple packages with the same NEVRA marked as installed ++ ts.addErase(tsi.pkg.idx) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_REMOVE: ++ ts.addErase(tsi.pkg.idx) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADE: ++ hdr = tsi.pkg._header ++ modular_problems += self._test_fail_safe(hdr, tsi.pkg) ++ ts.addInstall(hdr, tsi, 'u') ++ elif tsi.action == libdnf.transaction.TransactionItemAction_UPGRADED: ++ ts.addErase(tsi.pkg.idx) ++ elif tsi.action == libdnf.transaction.TransactionItemAction_REASON_CHANGE: ++ pass ++ else: ++ raise RuntimeError("TransactionItemAction not handled: %s" % tsi.action) ++ except rpm.error as e: ++ raise dnf.exceptions.Error(_("An rpm exception occurred: %s" % e)) + if modular_problems: + raise dnf.exceptions.Error(_("No available modular metadata for modular package")) + +-- +2.39.0 + diff --git a/0039-Ignore-processing-variable-files-with-unsupported-en.patch b/0039-Ignore-processing-variable-files-with-unsupported-en.patch new file mode 100644 index 0000000..ef476b6 --- /dev/null +++ b/0039-Ignore-processing-variable-files-with-unsupported-en.patch @@ -0,0 +1,50 @@ +From 23742561dcb168604d9668815a8c1ebbdf516d39 Mon Sep 17 00:00:00 2001 +From: Jan Kolarik +Date: Wed, 23 Nov 2022 08:44:41 +0000 +Subject: [PATCH 2/2] Ignore processing variable files with unsupported + encoding (RhBug:2141215) + +This issue could be seen for example when there are some temporary files stored by text editors in the `/etc/dnf/vars` folder. These files could be in the binary format and causes `UnicodeDecodeError` exception to be thrown during processing of the var files. + += changelog = +type: bugfix +resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2141215 +--- + dnf/conf/substitutions.py | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/dnf/conf/substitutions.py b/dnf/conf/substitutions.py +index 1281bdf0..4d0f0d55 100644 +--- a/dnf/conf/substitutions.py ++++ b/dnf/conf/substitutions.py +@@ -18,13 +18,15 @@ + # Red Hat, Inc. + # + ++import logging + import os + import re + +-import dnf +-import dnf.exceptions ++from dnf.i18n import _ + + ENVIRONMENT_VARS_RE = re.compile(r'^DNF_VAR_[A-Za-z0-9_]+$') ++logger = logging.getLogger('dnf') ++ + + class Substitutions(dict): + # :api +@@ -60,7 +62,8 @@ class Substitutions(dict): + val = fp.readline() + if val and val[-1] == '\n': + val = val[:-1] +- except (OSError, IOError): ++ except (OSError, IOError, UnicodeDecodeError) as e: ++ logger.warning(_("Error when parsing a variable from file '{0}': {1}").format(filepath, e)) + continue + if val is not None: + self[fsvar] = val +-- +2.39.0 + diff --git a/dnf.spec b/dnf.spec index 310eb10..d689823 100644 --- a/dnf.spec +++ b/dnf.spec @@ -66,7 +66,7 @@ It supports RPMs, modules and comps groups & environments. Name: dnf Version: 4.7.0 -Release: 14%{?dist} +Release: 15%{?dist} Summary: %{pkg_summary} # For a breakdown of the licensing, see PACKAGE-LICENSING License: GPLv2+ @@ -113,6 +113,9 @@ Patch0034: 0034-Fix-plugins-unit-tests-unload-plugins-upon-their-del.patch Patch0035: 0035-Move-system-upgrade-plugin-to-core-RhBug-2054235.patch Patch0036: 0036-Add-support-for-rollback-of-group-upgrade-rollback-R.patch Patch0037: 0037-Document-changes-to-offline-upgrade-command.patch +Patch0038: 0038-Better-explain-traceback-of-rpm.error-with-dnf.patch +Patch0039: 0039-Ignore-processing-variable-files-with-unsupported-en.patch + BuildArch: noarch @@ -413,6 +416,10 @@ popd %{python3_sitelib}/%{name}/automatic/ %changelog +* Thu Jan 05 2023 Nicola Sella - 4.7.0-15 +- Ignore processing variable files with unsupported encoding (RhBug:2141215) +- Better explain traceback of rpm.error with dnf + * Wed Nov 30 2022 Nicola Sella - 4.7.0-14 - Document changes to offline-upgrade command (RhBug:1939975,2139324)