!147 [sync] PR-145: fix dnf-data downgrade confilct with dnf

From: @openeuler-sync-bot 
Reviewed-by: @anonymous_z 
Signed-off-by: @anonymous_z
This commit is contained in:
openeuler-ci-bot 2022-12-13 13:53:54 +00:00 committed by Gitee
commit 75c636e576
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 50 additions and 15 deletions

View File

@ -3,7 +3,7 @@
Name: dnf
Version: 4.14.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
@ -14,6 +14,7 @@ Patch9001: fix-pid-file-residue.patch
Patch9002: add-rpm-transaction-debuginfo.patch
Patch9003: adapt-test-another-process.patch
Patch9004: fix-dnf-history-undo-error-when-history-sqlite-missing.patch
Patch9005: huawei-lock-file-add-verify-parameter.patch
%ifarch sw_64
Patch6000: dnf-4.10.0-sw.patch
@ -24,7 +25,7 @@ Patch6001: 0001-Add-loongarch-architecture-support.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
Requires: python3-%{name} = %{version}-%{release} libreport-filesystem
Requires: python3-%{name} = %{version}-%{release} libreport-filesystem
Recommends: (%{_bindir}/sqlite3 if bash-completion) (python3-dbus if NetworkManager)
Provides: dnf-command(alias) dnf-command(autoremove) dnf-command(check-update) dnf-command(clean)
Provides: dnf-command(distro-sync) dnf-command(downgrade) dnf-command(group) dnf-command(history)
@ -41,7 +42,7 @@ determines the actions required to install packages.DNF also makes it easier
to maintain groups of machines, eliminating the need to manually update each
one using rpm.
%package -n yum
%package -n yum
Requires: %{name} = %{version}-%{release}
Summary: Package manager
@ -59,7 +60,7 @@ Requires: python3-gpg %{name}-data = %{version}-%{release} libmodule
Requires: python3-hawkey >= 0.66.0 python3-libdnf >= %{relate_libdnf_version}
Requires: python3-libcomps >= 0.1.8 python3-rpm >= 4.14.0
Recommends: python3-unbound
Obsoletes: python2-%{name}
Obsoletes: python2-%{name}
%description -n python3-%{name}
Python 3 interface to DNF.
@ -67,7 +68,7 @@ Python 3 interface to DNF.
%package data
Summary: Common data and configuration files for DNF
Requires: libreport-filesystem
Obsoletes: %{name}-conf < %{version}-%{release}
Obsoletes: %{name}-conf < %{version}-%{release} %{name} < %{version}-%{release}
Provides: %{name}-conf = %{version}-%{release}
%description data
@ -144,35 +145,39 @@ popd
%post
%systemd_post dnf-makecache.timer
%preun
%systemd_preun dnf-makecache.timer
%postun
%systemd_postun_with_restart dnf-makecache.timer
%post automatic
%systemd_post dnf-automatic.timer
%systemd_post dnf-automatic-notifyonly.timer
%systemd_post dnf-automatic-download.timer
%systemd_post dnf-automatic-install.timer
%preun
%preun automatic
%systemd_preun dnf-automatic.timer
%systemd_preun dnf-makecache.timer
%systemd_preun dnf-automatic-notifyonly.timer
%systemd_preun dnf-automatic-download.timer
%systemd_preun dnf-automatic-install.timer
%postun
%systemd_postun_with_restart dnf-makecache.timer
%postun automatic
%systemd_postun_with_restart dnf-automatic.timer
%systemd_postun_with_restart dnf-automatic-notifyonly.timer
%systemd_postun_with_restart dnf-automatic-download.timer
%systemd_postun_with_restart dnf-automatic-install.timer
%files
%license COPYING PACKAGE-LICENSING
%doc AUTHORS README.rst
%{_bindir}/%{name}
%{_sysconfdir}/bash_completion.d/%{name}
%{_unitdir}/%{name}-makecache.timer
%{_unitdir}/%{name}-makecache.service
%{_var}/cache/%{name}/
%files -n yum
%files -n yum
%{_bindir}/yum
%{_sysconfdir}/yum/vars
%{_sysconfdir}/yum.conf
@ -190,7 +195,7 @@ popd
%files data
%license COPYING PACKAGE-LICENSING
%doc AUTHORS README.rst
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/modules.d
%dir %{_sysconfdir}/%{name}/modules.defaults.d
%dir %{_sysconfdir}/%{name}/plugins
@ -210,14 +215,12 @@ popd
%ghost %attr(644,-,-) %{_sharedstatedir}/%{name}/groups.json
%ghost %attr(755,-,-) %dir %{_sharedstatedir}/%{name}/yumdb
%ghost %attr(755,-,-) %dir %{_sharedstatedir}/%{name}/history
%{_mandir}/man5/%{name}.conf.5*
%{_tmpfilesdir}/%{name}.conf
%{_sysconfdir}/libreport/events.d/collect_dnf.conf
%files automatic
%{_bindir}/%{name}-automatic
%config(noreplace) %{_sysconfdir}/%{name}/automatic.conf
%{_mandir}/man8/%{name}-automatic.8*
%{_unitdir}/%{name}-automatic.service
%{_unitdir}/%{name}-automatic.timer
%{_unitdir}/%{name}-automatic-notifyonly.service
@ -243,6 +246,9 @@ popd
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Tue Dec 13 2022 chenhaixing <chenhaixing@huawei.com> - 4.14.0-5
- DESC:fix dnf-data downgrade confilct with dnf
* Fri Dec 9 2022 chenhaixing <chenhaixing@huawei.com> - 4.14.0-4
- DESC:add sw64 and loongarch support for dnf

View File

@ -0,0 +1,29 @@
From ec8644e42ec2e0d0f98ea1aee3859b2c510f0cc0 Mon Sep 17 00:00:00 2001
From: chenhaixing <chenhaixing@huawei.com>
Date: Sat, 4 Jun 2022 17:49:53 +0800
Subject: [PATCH] verify-parameter
---
dnf/lock.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dnf/lock.py b/dnf/lock.py
index ab05a3b..12378ec 100644
--- a/dnf/lock.py
+++ b/dnf/lock.py
@@ -116,7 +116,12 @@ class ProcessLock(object):
return pid
try:
- with open('/proc/%d/status' % old_pid) as f:
+ old_pid_path = f'/proc/{old_pid}/status'
+ true_old_pid_path = os.path.realpath(old_pid_path)
+ if not true_old_pid_path.startswith("/proc/"):
+ return old_pid
+
+ with open(true_old_pid_path) as f:
if not re.findall(r'Name:(.*)(dnf|yum)', f.read(), re.I):
os.write(fd, str(pid).encode('utf-8'))
return pid
--
2.27.0