dnf:backport some patches

(cherry picked from commit 7c67dd07fb9d765156111461e728ff3f9bf3b84c)
This commit is contained in:
chenhaxing 2023-02-13 16:24:09 +08:00 committed by openeuler-sync-bot
parent 69203eefc2
commit 432b0f824d
6 changed files with 242 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From b646ae4d713615e04f4acab4575fe5eff100f350 Mon Sep 17 00:00:00 2001
From: Nicola Sella <nsella@redhat.com>
Date: Tue, 15 Mar 2022 16:26:10 +0100
Subject: [PATCH] Fix remove when no repos are enabled (RhBz:2064341)
msg: When no repositories are enabled, dnf group exits and does not
remove an installed group.
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2064341
type: bugfix
Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/b646ae4d713615e04f4acab4575fe5eff100f350
---
dnf/cli/commands/group.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dnf/cli/commands/group.py b/dnf/cli/commands/group.py
index e25c9be..6de8baa 100644
--- a/dnf/cli/commands/group.py
+++ b/dnf/cli/commands/group.py
@@ -358,7 +358,8 @@ class GroupCommand(commands.Command):
else:
demands.available_repos = True
- commands._checkEnabledRepo(self.base)
+ if cmd not in ('remove'):
+ commands._checkEnabledRepo(self.base)
if cmd in ('install', 'upgrade'):
commands._checkGPGKey(self.base, self.cli)
--
2.27.0

View File

@ -0,0 +1,52 @@
From e2fbdc660fb4ef83905e127fd801025461c24710 Mon Sep 17 00:00:00 2001
From: Jan Kolarik <jkolarik@redhat.com>
Date: Wed, 23 Nov 2022 08:44:41 +0000
Subject: [PATCH] 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
Conflict:The content of "index" and "@@" are adapted
Reference:https://github.com/rpm-software-management/dnf/commit/e2fbdc660fb4ef83905e127fd801025461c24710
---
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 1281bdf..9d7442b 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.27.0

View File

@ -0,0 +1,66 @@
From d7bfd194129b496851ed07ac7efd07c6ddc0ab49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Wed, 7 Sep 2022 14:40:32 +0200
Subject: [PATCH] Pass whole URL in relativeUrl to PackageTarget for RPM URL
download
The PackageTarget supports baseUrl and relativeUrl on the API, but then
the relativeUrl is just a path fragment with no definition on whether it
should be encoded. It's being passed unencoded paths from other places,
and so there's a conditional encode (only if not full URL) in libdnf.
But full URLs are actually supported in relativeUrl (in that case
baseUrl should be empty) and in that case the URL is expected to be
encoded and is not encoded for the second time.
Hence, pass the full URL to relativeUrl instead of splitting it. We also
need to decode the file name we store, as on the filesystem the RPM file
name is also decoded.
= changelog =
msg: Don't double-encode RPM URLs passed on CLI
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103015
Conflict:@@ adapt: "@@ import string" and "@@ class RemoteRPMPayload(PackagePayload):" check is not 3e36c99d401530dc026712523a7c445da17ee299(commitID)
which is not backported
Reference:https://github.com/rpm-software-management/dnf/commit/d7bfd194129b496851ed07ac7efd07c6ddc0ab49
---
dnf/repo.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dnf/repo.py b/dnf/repo.py
index 1822cf0..8751de3 100644
--- a/dnf/repo.py
+++ b/dnf/repo.py
@@ -47,6 +47,7 @@ import string
import sys
import time
import traceback
+import urllib
_PACKAGES_RELATIVE_DIR = "packages"
_MIRRORLIST_FILENAME = "mirrorlist"
@@ -295,7 +296,7 @@ class RemoteRPMPayload(PackagePayload):
self.local_path = os.path.join(self.pkgdir, self.__str__().lstrip("/"))
def __str__(self):
- return os.path.basename(self.remote_location)
+ return os.path.basename(urllib.parse.unquote(self.remote_location))
def _progress_cb(self, cbdata, total, done):
self.remote_size = total
@@ -308,8 +309,8 @@ class RemoteRPMPayload(PackagePayload):
def _librepo_target(self):
return libdnf.repo.PackageTarget(
- self.conf._config, os.path.basename(self.remote_location),
- self.pkgdir, 0, None, 0, os.path.dirname(self.remote_location),
+ self.conf._config, self.remote_location,
+ self.pkgdir, 0, None, 0, None,
True, 0, 0, self.callbacks)
@property
--
2.27.0

View File

@ -0,0 +1,38 @@
From f8fed338a73f1780b394142e371250b9b8ee8f7c Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Mon, 11 Jul 2022 12:27:14 +0200
Subject: [PATCH] Set default value for variable to prevent crash
(RhBug:2091636)
It ensure that read of file ended successfully.
https://bugzilla.redhat.com/show_bug.cgi?id=2091636
Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/f8fed338a73f1780b394142e371250b9b8ee8f7c
---
dnf/conf/substitutions.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dnf/conf/substitutions.py b/dnf/conf/substitutions.py
index 703e4a4..1281bdf 100644
--- a/dnf/conf/substitutions.py
+++ b/dnf/conf/substitutions.py
@@ -53,6 +53,7 @@ class Substitutions(dict):
continue
for fsvar in fsvars:
filepath = os.path.join(dir_fsvars, fsvar)
+ val = None
if os.path.isfile(filepath):
try:
with open(filepath) as fp:
@@ -61,4 +62,5 @@ class Substitutions(dict):
val = val[:-1]
except (OSError, IOError):
continue
- self[fsvar] = val
+ if val is not None:
+ self[fsvar] = val
--
2.27.0

View File

@ -0,0 +1,41 @@
From 8f3f98ee710c9909f448c2d11143d9dffb919a46 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Tue, 4 Jan 2022 09:48:23 +0100
Subject: [PATCH] Switch install/remove parts of swap command (RhBug:2036434)
In case the install spec refers to a local rpm file the swap command
would fail with this error:
Error: Cannot add local packages, because transaction job already exists
Changing the order in which the installation and removal parts are
performed fixes the issue.
= changelog =
msg: Fix swap command to work with local rpm files correctly
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2036434
Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/8f3f98ee710c9909f448c2d11143d9dffb919a46
---
dnf/cli/commands/swap.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dnf/cli/commands/swap.py b/dnf/cli/commands/swap.py
index 5f23880..d44b3f4 100644
--- a/dnf/cli/commands/swap.py
+++ b/dnf/cli/commands/swap.py
@@ -58,5 +58,8 @@ class SwapCommand(commands.Command):
cmd.run()
def run(self):
- self._perform('remove', self.opts.remove_spec)
+ # The install part must be performed before the remove one because it can
+ # operate on local rpm files. Command line packages cannot be added
+ # to the sack once the goal is created.
self._perform('install', self.opts.install_spec)
+ self._perform('remove', self.opts.remove_spec)
--
2.27.0

View File

@ -3,7 +3,7 @@
Name: dnf
Version: 4.2.23
Release: 9
Release: 10
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
@ -23,6 +23,11 @@ Patch10: Fix-reporting-irrecoverable-errors-on-packages-downl.patch
Patch6000: backport-fix-dnf-mark-error-when-history-sqlite-missing.patch
Patch9000: fix-dnf-history-undo-error-when-history-sqlite-missing.patch
Patch6001: backport-switch-install-remove-parts-of-swap-command.patch
Patch6002: backport-fix-remove-when-no-repos-are-enabled.patch
Patch6003: backport-set-default-value-for-variable-to-prevent-crash.patch
Patch6004: backport-pass-whole-url-in-relativeUrl-to-packageTarget-for-rpm-url-download.patch
Patch6005: backport-ignore-processing-variable-files-with-unsupported-encoding.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
@ -213,6 +218,12 @@ popd
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Tue Feb 14 2023 chenhaixing <chenhaixing@huawei.com> - 4.2.23-10
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:dnf:backport some patches
* Thu Nov 10 2022 chenhaixing <chenhaixing@huawei.com> - 4.2.23-9
- DESC:correct the bad date in changelog