From 82282f382739858f97417ca02e42af97464be127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=91=E5=AE=81?= Date: Thu, 10 Mar 2022 11:31:09 +0800 Subject: [PATCH] Add fail_fast parameter to _download_remote_payloads() method --- ...rameter-to-download_payloads-methods.patch | 68 ++++++++++++++++ ...recoverable-errors-on-packages-downl.patch | 81 +++++++++++++++++++ dnf.spec | 10 ++- 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 Add-fail_fast-parameter-to-download_payloads-methods.patch create mode 100644 Fix-reporting-irrecoverable-errors-on-packages-downl.patch diff --git a/Add-fail_fast-parameter-to-download_payloads-methods.patch b/Add-fail_fast-parameter-to-download_payloads-methods.patch new file mode 100644 index 0000000..351dea5 --- /dev/null +++ b/Add-fail_fast-parameter-to-download_payloads-methods.patch @@ -0,0 +1,68 @@ +From 39b04e98fd7c862c9e070a46b79772fa47dc3371 Mon Sep 17 00:00:00 2001 +From: Marek Blaha +Date: Wed, 6 Oct 2021 09:56:05 +0200 +Subject: [PATCH] Add fail_fast parameter to download_payloads methods + +Unlike in the rpm transaction, reposync needs to switch the fail_fast +off to download as much packages from repository as possible. +--- + dnf/base.py | 6 +++--- + dnf/repo.py | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/dnf/base.py b/dnf/base.py +index e1aa2bd..f2b9c55 100644 +--- a/dnf/base.py ++++ b/dnf/base.py +@@ -1059,7 +1059,7 @@ class Base(object): + timer() + self._trans_success = True + +- def _download_remote_payloads(self, payloads, drpm, progress, callback_total): ++ def _download_remote_payloads(self, payloads, drpm, progress, callback_total, fail_fast=True): + lock = dnf.lock.build_download_lock(self.conf.cachedir, self.conf.exit_on_lock) + with lock: + beg_download = time.time() +@@ -1071,7 +1071,7 @@ class Base(object): + progress.start(len(payloads), est_remote_size, total_drpms=total_drpm) + else: + progress.start(len(payloads), est_remote_size) +- errors = dnf.repo._download_payloads(payloads, drpm) ++ errors = dnf.repo._download_payloads(payloads, drpm, fail_fast) + + if errors._irrecoverable: + raise dnf.exceptions.DownloadError(errors._irrecoverable) +@@ -1097,7 +1097,7 @@ class Base(object): + est_remote_size = sum(pload.download_size + for pload in payloads) + progress.start(len(payloads), est_remote_size) +- errors = dnf.repo._download_payloads(payloads, drpm) ++ errors = dnf.repo._download_payloads(payloads, drpm, fail_fast) + + if errors._irrecoverable: + raise dnf.exceptions.DownloadError(errors._irrecoverable) +diff --git a/dnf/repo.py b/dnf/repo.py +index 7550897..db3ac6a 100644 +--- a/dnf/repo.py ++++ b/dnf/repo.py +@@ -84,7 +84,7 @@ def _pkg2payload(pkg, progress, *factories): + raise ValueError(_('no matching payload factory for %s') % pkg) + + +-def _download_payloads(payloads, drpm): ++def _download_payloads(payloads, drpm, fail_fast=True): + # download packages + def _download_sort_key(payload): + return not hasattr(payload, 'delta') +@@ -94,7 +94,7 @@ def _download_payloads(payloads, drpm): + for pload in sorted(payloads, key=_download_sort_key)] + errs = _DownloadErrors() + try: +- libdnf.repo.PackageTarget.downloadPackages(libdnf.repo.VectorPPackageTarget(targets), True) ++ libdnf.repo.PackageTarget.downloadPackages(libdnf.repo.VectorPPackageTarget(targets), fail_fast) + except RuntimeError as e: + errs._fatal = str(e) + drpm.wait() +-- +2.20.1 + diff --git a/Fix-reporting-irrecoverable-errors-on-packages-downl.patch b/Fix-reporting-irrecoverable-errors-on-packages-downl.patch new file mode 100644 index 0000000..66a83e0 --- /dev/null +++ b/Fix-reporting-irrecoverable-errors-on-packages-downl.patch @@ -0,0 +1,81 @@ +From a8cc5149203ad1bb2800d6c4fc3fb34c6b2b514d Mon Sep 17 00:00:00 2001 +From: Marek Blaha +Date: Wed, 6 Oct 2021 09:43:37 +0200 +Subject: [PATCH] Fix reporting irrecoverable errors on packages download + +The original _irrecoverable property returns random dictionary - either +packages irrecoverable errors, or global fatal error or even new empty +dictionary. This makes it prone to programmer errors like: + +errs._irrecoverable[pkg] = [err] + +which may lead to setting the error into the newly created empty +dictionary instead of packages errors dictionary as intended. + +I turned the property to method which I consider more clear. +--- + dnf/base.py | 8 ++++---- + dnf/repo.py | 9 ++++----- + 2 files changed, 8 insertions(+), 9 deletions(-) + +diff --git a/dnf/base.py b/dnf/base.py +index f2b9c55..3d5a255 100644 +--- a/dnf/base.py ++++ b/dnf/base.py +@@ -1073,8 +1073,8 @@ class Base(object): + progress.start(len(payloads), est_remote_size) + errors = dnf.repo._download_payloads(payloads, drpm, fail_fast) + +- if errors._irrecoverable: +- raise dnf.exceptions.DownloadError(errors._irrecoverable) ++ if errors._irrecoverable(): ++ raise dnf.exceptions.DownloadError(errors._irrecoverable()) + + remote_size = sum(errors._bandwidth_used(pload) + for pload in payloads) +@@ -1099,8 +1099,8 @@ class Base(object): + progress.start(len(payloads), est_remote_size) + errors = dnf.repo._download_payloads(payloads, drpm, fail_fast) + +- if errors._irrecoverable: +- raise dnf.exceptions.DownloadError(errors._irrecoverable) ++ if errors._irrecoverable(): ++ raise dnf.exceptions.DownloadError(errors._irrecoverable()) + + remote_size += \ + sum(errors._bandwidth_used(pload) for pload in payloads) +diff --git a/dnf/repo.py b/dnf/repo.py +index db3ac6a..5e6f723 100644 +--- a/dnf/repo.py ++++ b/dnf/repo.py +@@ -112,7 +112,7 @@ def _download_payloads(payloads, drpm, fail_fast=True): + errs._skipped.add(pkg) + continue + pkg.repo._repo.expire() +- errs._irrecoverable[pkg] = [err] ++ errs._pkg_irrecoverable[pkg] = [err] + + return errs + +@@ -131,15 +131,14 @@ def _update_saving(saving, payloads, errs): + + class _DownloadErrors(object): + def __init__(self): +- self._val_irrecoverable = {} ++ self._pkg_irrecoverable = {} + self._val_recoverable = {} + self._fatal = None + self._skipped = set() + +- @property + def _irrecoverable(self): +- if self._val_irrecoverable: +- return self._val_irrecoverable ++ if self._pkg_irrecoverable: ++ return self._pkg_irrecoverable + if self._fatal: + return {'': [self._fatal]} + return {} +-- +2.20.1 + diff --git a/dnf.spec b/dnf.spec index 577980b..f1a074c 100644 --- a/dnf.spec +++ b/dnf.spec @@ -3,7 +3,7 @@ Name: dnf Version: 4.2.23 -Release: 6 +Release: 7 Summary: A software package manager that manages packages on Linux distributions. License: GPLv2+ and GPLv2 and GPL URL: https://github.com/rpm-software-management/dnf @@ -18,6 +18,8 @@ Patch5: Add-missing-check-if-path-exists-fixes-dead-code.patch Patch6: dnf-rpm-miscutils.py-fix-usage-of-_.patch Patch7: Pass-the-package-to-rpmkeys-stdin.patch Patch8: Use-rpmkeys-alone-to-verify-signature.patch +Patch9: Add-fail_fast-parameter-to-download_payloads-methods.patch +Patch10: Fix-reporting-irrecoverable-errors-on-packages-downl.patch BuildArch: noarch BuildRequires: cmake gettext systemd bash-completion python3-sphinx @@ -208,6 +210,12 @@ popd %{_mandir}/man8/%{name}-automatic.8* %changelog +* Thu Mar 10 2022 zhangshaoning - 4.2.23-7 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Add fail_fast parameter to _download_remote_payloads() method + * Tue Aur 3 2021 Jianmin - 4.2.23-6 - Type:enhancement - ID:NA