!116 fix Python dnf API does not respect cacheonly

From: @chen-haixing-hw 
Reviewed-by: @anonymous_z 
Signed-off-by: @anonymous_z
This commit is contained in:
openeuler-ci-bot 2022-05-06 09:08:24 +00:00 committed by Gitee
commit aeb7207a40
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From 118bd0c124377dad1a01e7bbd3ec58fb6700714c Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Wed, 20 Oct 2021 09:20:03 +0200
Subject: [PATCH] Fix: Python dnf API does not respect cacheonly
(RhBug:1862970)
`Repo` object has always been constructed with default synchronization
strategy. The configuration option `cacheonly` was ignored. DNF
application set synchronization strategy later in the `Cli` object
during processing demands.
The fix takes into account the `cacheonly` option during the construction
of the `Repo` object. Synchronization strategy may still be overriden
during demand processing.
Conflict: NA
Reference: https://github.com/rpm-software-management/dnf/commit/118bd0c124377dad1a01e7bbd3ec58fb6700714c
---
dnf/repo.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dnf/repo.py b/dnf/repo.py
index bb422309d0..1822cf01ce 100644
--- a/dnf/repo.py
+++ b/dnf/repo.py
@@ -434,7 +434,7 @@ def __init__(self, name=None, parent_conf=None):
self._pkgdir = None
self._key_import = _NullKeyImport()
self.metadata = None # :api
- self._repo.setSyncStrategy(self.DEFAULT_SYNC)
+ self._repo.setSyncStrategy(SYNC_ONLY_CACHE if parent_conf and parent_conf.cacheonly else self.DEFAULT_SYNC)
if parent_conf:
self._repo.setSubstitutions(parent_conf.substitutions)
self._substitutions = dnf.conf.substitutions.Substitutions()

View File

@ -3,7 +3,7 @@
Name: dnf
Version: 4.10.0
Release: 4
Release: 5
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
@ -16,6 +16,7 @@ Patch9003: adapt-test-another-process.patch
Patch9004: fix-dnf-history-undo-error-when-history-sqlite-missing.patch
Patch6000: backport-fix-dnf-mark-error-when-history-sqlite-missing.patch
Patch6001: backport-Fix-Python-dnf-API-does-not-respect-cacheonly-RhBug1862970.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
@ -227,6 +228,12 @@ ln -sr %{buildroot}%{_sysconfdir}/%{name}/vars %{buildroot}%{_sysconfdir}/yum/v
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Thu May 05 2022 chenhaixing <chenhaixing@huawei.com> - 4.10.0-5
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix Python dnf API does not respect cacheonly
* Fri Apr 15 2022 yangcheng <yangcheng87@h-partners.com> - 4.10.0-4
- fix the problem of repeated packaging of man files and automatic service startup