!179 dnf:fix undo error when include rollback of group upgrade and fix can't download package when url have characters encoded

From: @chen-haixing-hw 
Reviewed-by: @anonymous_z 
Signed-off-by: @anonymous_z
This commit is contained in:
openeuler-ci-bot 2023-03-08 02:54:53 +00:00 committed by Gitee
commit 2f8085f3fa
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 124 additions and 2 deletions

View File

@ -0,0 +1,50 @@
From e027e02efe57706de5867d42505ea01fb8d494de Mon Sep 17 00:00:00 2001
From: Jan Kolarik <jkolarik@redhat.com>
Date: Tue, 13 Sep 2022 13:55:35 +0200
Subject: [PATCH] Add support for rollback of group upgrade rollback
(RhBug:2016070)
= changelog =
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2016070
Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/e027e02efe57706de5867d42505ea01fb8d494de
---
dnf/transaction_sr.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dnf/transaction_sr.py b/dnf/transaction_sr.py
index 5d403a3..cf74b80 100644
--- a/dnf/transaction_sr.py
+++ b/dnf/transaction_sr.py
@@ -553,9 +553,11 @@ class TransactionReplay(object):
if action == "Install":
self._swdb_group_install(group_id, pkg_types, group_data["packages"])
- elif action == "Upgrade":
+ # Groups are not versioned, but a reverse transaction could be applied,
+ # therefore we treat both actions the same way
+ elif action == "Upgrade" or action == "Upgraded":
self._swdb_group_upgrade(group_id, pkg_types, group_data["packages"])
- elif action == "Downgraded":
+ elif action == "Downgrade" or action == "Downgraded":
self._swdb_group_downgrade(group_id, pkg_types, group_data["packages"])
elif action == "Removed":
self._swdb_group_remove(group_id, pkg_types, group_data["packages"])
@@ -584,9 +586,11 @@ class TransactionReplay(object):
if action == "Install":
self._swdb_environment_install(env_id, pkg_types, env_data["groups"])
- elif action == "Upgrade":
+ # Environments are not versioned, but a reverse transaction could be applied,
+ # therefore we treat both actions the same way
+ elif action == "Upgrade" or action == "Upgraded":
self._swdb_environment_upgrade(env_id, pkg_types, env_data["groups"])
- elif action == "Downgraded":
+ elif action == "Downgrade" or action == "Downgraded":
self._swdb_environment_downgrade(env_id, pkg_types, env_data["groups"])
elif action == "Removed":
self._swdb_environment_remove(env_id, pkg_types, env_data["groups"])
--
2.27.0

View File

@ -0,0 +1,64 @@
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:NA
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

@ -3,7 +3,7 @@
Name: dnf
Version: 4.14.0
Release: 11
Release: 12
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
@ -27,7 +27,9 @@ Patch6000: dnf-4.10.0-sw.patch
Patch6001: 0001-Add-loongarch-architecture-support.patch
%endif
Patch6002: backport-fix-plugins-unit-tests-unload-plugins-upon-their-deletion.patch
Patch6003: backport-ignore-processing-variable-files-with-unsupported-encoding.patch
Patch6003: backport-pass-whole-url-in-relativeUrl-to-packageTarget-for-rpm-url-download.patch
Patch6004: backport-add-support-for-rollback-of-group-upgrade-rollback.patch
Patch6005: backport-ignore-processing-variable-files-with-unsupported-encoding.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
@ -252,6 +254,12 @@ popd
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Tue Mar 7 2023 chenhaixing <chenhaixing@huawei.com> 4.14.0-12
- CVE:NA
- SUG:NA
- DESC:dnf:fix undo error when include rollback of group upgrade
fix can't download package when url have characters encoded
* Wed Feb 22 2023 xiasenlin <xiasenlin1@huawei.com> - 4.14.0-11
- DESC:Add exception capture to get-lockfile-exists-before-unlick.patch