!105 [sync] PR-95: round self-developed patch

From: @openeuler-sync-bot 
Reviewed-by: @t_feng 
Signed-off-by: @t_feng
This commit is contained in:
openeuler-ci-bot 2022-03-29 11:13:20 +00:00 committed by Gitee
commit d4d29f1418
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 168 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From 997310fff83c3701ffc5c3835979732b130679c0 Mon Sep 17 00:00:00 2001
From: zhangrui <zhangrui182@huawei.com>
Date: Wed, 29 Dec 2021 14:59:18 +0800
Subject: [PATCH] adapt-test-another-process
---
tests/test_lock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_lock.py b/tests/test_lock.py
index ce9806b..c075005 100644
--- a/tests/test_lock.py
+++ b/tests/test_lock.py
@@ -112,7 +112,7 @@ class ProcessLockTest(tests.support.TestCase):
with l1:
process.start()
process.join()
- self.assertIsInstance(process.queue.get(), ProcessLockError)
+ self.assertEqual(process.queue.empty(), True)
def test_another_process_blocking(self):
l1 = build_lock(blocking=True)
--
2.27.0

View File

@ -0,0 +1,40 @@
From 9f3dec73c99873747a05419187b1f36147c5f7d0 Mon Sep 17 00:00:00 2001
From: fengtao40 <fengtao40@huawei.com>
Date: Tue, 7 Jul 2020 20:29:48 +0800
Subject: [PATCH] huawei add rpm transaction debuginfo
---
dnf/base.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dnf/base.py b/dnf/base.py
index 0443443..81e5f6f 100644
--- a/dnf/base.py
+++ b/dnf/base.py
@@ -981,6 +981,7 @@ class Base(object):
except:
pass
dnf.util._sync_rpm_trans_with_swdb(self._ts, self._transaction)
+ logger.log(dnf.logging.DDEBUG, 'RPM transaction sync swdb over.')
if errors is None:
pass
@@ -1018,6 +1019,7 @@ class Base(object):
# keep install_set status because _verify_transaction will clean it
self._trans_install_set = bool(self._transaction.install_set)
+ logger.log(dnf.logging.DDEBUG, 'RPM transaction TsFlag is %s' % self._ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST))
# sync up what just happened versus what is in the rpmdb
if not self._ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST):
self._verify_transaction(cb.verify_tsi_package)
@@ -1040,6 +1042,7 @@ class Base(object):
count = 0
rpmdb_sack = dnf.sack.rpmdb_sack(self)
+ logger.log(dnf.logging.DDEBUG, 'verify transaction rpmdb_sack over.')
# mark group packages that are installed on the system as installed in the db
q = rpmdb_sack.query().installed()
--
2.18.4

View File

@ -3,12 +3,17 @@
Name: dnf
Version: 4.10.0
Release: 1
Release: 2
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
Source0: https://github.com/rpm-software-management/dnf/archive/%{version}/%{name}-%{version}.tar.gz
Patch9000: unlock-pidfile-if-current-proccess-is-NOT-dnf.patch
Patch9001: fix-pid-file-residue.patch
Patch9002: add-rpm-transaction-debuginfo.patch
Patch9003: adapt-test-another-process.patch
BuildArch: noarch
BuildRequires: cmake gettext systemd bash-completion python3-sphinx
Requires: python3-%{name} = %{version}-%{release} libreport-filesystem
@ -217,6 +222,9 @@ ln -sr %{buildroot}%{_sysconfdir}/%{name}/vars %{buildroot}%{_sysconfdir}/yum/v
%{_mandir}/man8/%{name}-automatic.8*
%changelog
* Sat Feb 26 2022 hanhuihui <hanhuihui5@huawei.com> - 4.10.0-2
- round self-developed patch,adapt test_onother_process
* Wed Dec 29 2021 yangcheng <yangcheng87@huawei.com> - 4.10.0-1
- upgrade to 4.10.0

View File

@ -0,0 +1,50 @@
From 0dfb26f901976a585ed29585d5cae694a11360d7 Mon Sep 17 00:00:00 2001
From: zhangrui <zhangrui182@huawei.com>
Dare: Mon, 21 Feb 2022 11:18:06 +0800
Subject: [PATCH] fix-pid-file-residue
---
dnf/lock.py | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff -urNp a/dnf/lock.py b/dnf/lock.py
--- a/dnf/lock.py 2020-07-14 20:33:25.746000000 +0800
+++ b/dnf/lock.py 2020-07-14 20:51:17.378000000 +0800
@@ -108,26 +108,25 @@ class ProcessLock(object):
# already locked by this process
return pid
+ if not os.access('/proc/%d/stat' % old_pid, os.F_OK):
+ # locked by a dead process, write our pid
+ os.lseek(fd, 0, os.SEEK_SET)
+ os.ftruncate(fd, 0)
+ os.write(fd, str(pid).encode('utf-8'))
+ return pid
+
try:
with open('/proc/%d/status' % old_pid) as f:
- for line in f:
- if not re.match(r'Name:(.*)(dnf|yum)$', line, re.I):
- os.write(fd, str(pid).encode('utf-8'))
- return pid
- except Exception as e:
+ if not re.findall(r'Name:(.*)(dnf|yum)', f.read(), re.I):
+ os.write(fd, str(pid).encode('utf-8'))
+ return pid
+ except OSError as e:
msg = _('Malformed lock file found: %s.\n'
'But pid in lock file is invalid '
'Ensure no other dnf/yum process is running and '
'remove the lock file manually.') % (self.target)
raise LockError(msg)
- if not os.access('/proc/%d/stat' % old_pid, os.F_OK):
- # locked by a dead process, write our pid
- os.lseek(fd, 0, os.SEEK_SET)
- os.ftruncate(fd, 0)
- os.write(fd, str(pid).encode('utf-8'))
- return pid
-
return old_pid
finally:

View File

@ -0,0 +1,44 @@
From 7438ca37b6e688637a87cbdc87490e70a61e1829 Mon Sep 17 00:00:00 2001
From: fengtao40 <fengtao40@huawei.com>
Date: Sat, 13 Jun 2020 16:54:09 +0800
Subject: [PATCH] unlock-pidfile-if-current-proccess-is-NOT-dnf
---
dnf/lock.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dnf/lock.py b/dnf/lock.py
index 13d8c27..589aa0a 100644
--- a/dnf/lock.py
+++ b/dnf/lock.py
@@ -32,6 +32,7 @@ import logging
import os
import threading
import time
+import re
logger = logging.getLogger("dnf")
@@ -106,6 +107,19 @@ class ProcessLock(object):
if old_pid == pid:
# already locked by this process
return pid
+
+ try:
+ with open('/proc/%d/status' % old_pid) as f:
+ for line in f:
+ if not re.match(r'Name:(.*)(dnf|yum)$', line, re.I):
+ os.write(fd, str(pid).encode('utf-8'))
+ return pid
+ except Exception as e:
+ msg = _('Malformed lock file found: %s.\n'
+ 'But pid in lock file is invalid '
+ 'Ensure no other dnf/yum process is running and '
+ 'remove the lock file manually.') % (self.target)
+ raise LockError(msg)
if not os.access('/proc/%d/stat' % old_pid, os.F_OK):
# locked by a dead process, write our pid
--
2.18.2