From d6f56a08b57c93ea08f76acd62f56eab4d5599a0 Mon Sep 17 00:00:00 2001 From: han_hui_hui Date: Mon, 28 Feb 2022 09:58:46 +0800 Subject: [PATCH] round self-developed patch (cherry picked from commit 61b9cd78631cf27ffabca0969062326f48a7efa5) --- adapt-test-another-process.patch | 25 ++++++++++ add-rpm-transaction-debuginfo.patch | 40 +++++++++++++++ dnf.spec | 10 +++- fix-pid-file-residue.patch | 50 +++++++++++++++++++ ...dfile-if-current-proccess-is-NOT-dnf.patch | 44 ++++++++++++++++ 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 adapt-test-another-process.patch create mode 100644 add-rpm-transaction-debuginfo.patch create mode 100644 fix-pid-file-residue.patch create mode 100644 unlock-pidfile-if-current-proccess-is-NOT-dnf.patch diff --git a/adapt-test-another-process.patch b/adapt-test-another-process.patch new file mode 100644 index 0000000..62d8584 --- /dev/null +++ b/adapt-test-another-process.patch @@ -0,0 +1,25 @@ +From 997310fff83c3701ffc5c3835979732b130679c0 Mon Sep 17 00:00:00 2001 +From: zhangrui +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 + diff --git a/add-rpm-transaction-debuginfo.patch b/add-rpm-transaction-debuginfo.patch new file mode 100644 index 0000000..993991c --- /dev/null +++ b/add-rpm-transaction-debuginfo.patch @@ -0,0 +1,40 @@ +From 9f3dec73c99873747a05419187b1f36147c5f7d0 Mon Sep 17 00:00:00 2001 +From: fengtao40 +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 + diff --git a/dnf.spec b/dnf.spec index 0b1253e..5a88f0f 100644 --- a/dnf.spec +++ b/dnf.spec @@ -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 - 4.10.0-2 +- round self-developed patch,adapt test_onother_process + * Wed Dec 29 2021 yangcheng - 4.10.0-1 - upgrade to 4.10.0 diff --git a/fix-pid-file-residue.patch b/fix-pid-file-residue.patch new file mode 100644 index 0000000..feb07ab --- /dev/null +++ b/fix-pid-file-residue.patch @@ -0,0 +1,50 @@ +From 0dfb26f901976a585ed29585d5cae694a11360d7 Mon Sep 17 00:00:00 2001 +From: zhangrui +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: diff --git a/unlock-pidfile-if-current-proccess-is-NOT-dnf.patch b/unlock-pidfile-if-current-proccess-is-NOT-dnf.patch new file mode 100644 index 0000000..5d18d5f --- /dev/null +++ b/unlock-pidfile-if-current-proccess-is-NOT-dnf.patch @@ -0,0 +1,44 @@ +From 7438ca37b6e688637a87cbdc87490e70a61e1829 Mon Sep 17 00:00:00 2001 +From: fengtao40 +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 +