From: Changqing Li <[email protected]>

dnf has a bug, refer [1], it causes that log_lock.pid may not removed
after dnf exit. And for native dnf, since we change the lock file path
to /, it will never be removed, and make the rootfs not clean,refer
[2][3].  This patch is a workaround to fix above issue.

[1] https://github.com/rpm-software-management/dnf/issues/1963
[2] 
https://git.openembedded.org/openembedded-core/commit/?id=742a1b71249f4da1c8d8e13e270b0eb6128a3f66
[3] 
https://github.com/rpm-software-management/dnf/blob/master/etc/tmpfiles.d/dnf.conf

Signed-off-by: Changqing Li <[email protected]>
---
 ...n.py-remove-log_lock.pid-before-exit.patch | 41 +++++++++++++++++++
 meta/recipes-devtools/dnf/dnf_4.18.2.bb       |  3 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 
meta/recipes-devtools/dnf/dnf/0001-main.py-remove-log_lock.pid-before-exit.patch

diff --git 
a/meta/recipes-devtools/dnf/dnf/0001-main.py-remove-log_lock.pid-before-exit.patch
 
b/meta/recipes-devtools/dnf/dnf/0001-main.py-remove-log_lock.pid-before-exit.patch
new file mode 100644
index 0000000000..2dd4969d57
--- /dev/null
+++ 
b/meta/recipes-devtools/dnf/dnf/0001-main.py-remove-log_lock.pid-before-exit.patch
@@ -0,0 +1,41 @@
+From bdf17281385cf33ad59267fe75a9e427e6e2ffc4 Mon Sep 17 00:00:00 2001
+From: Changqing Li <[email protected]>
+Date: Thu, 7 Mar 2024 14:03:07 +0800
+Subject: [PATCH] main.py: remove log_lock.pid before exit
+
+dnf has a bug, refer [1], it causes that log_lock.pid may not removed
+after dnf exit. And for native dnf, since we change the lock file path
+to /, it will never be removed, and make the rootfs not clean,refer
+[2][3].  This patch is a workaround to fix above issue.
+
+[1] https://github.com/rpm-software-management/dnf/issues/1963
+[2] 
https://git.openembedded.org/openembedded-core/commit/?id=742a1b71249f4da1c8d8e13e270b0eb6128a3f66
+[3] 
https://github.com/rpm-software-management/dnf/blob/master/etc/tmpfiles.d/dnf.conf
+
+Upstream-Status: Inappropriate [oe specific workaround]
+
+Signed-off-by: Changqing Li <[email protected]>
+---
+ dnf/cli/main.py | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/dnf/cli/main.py b/dnf/cli/main.py
+index 2a7f92d54..2f672cff2 100644
+--- a/dnf/cli/main.py
++++ b/dnf/cli/main.py
+@@ -200,6 +200,12 @@ def user_main(args, exit_code=False):
+ 
+     errcode = main(args)
+     if exit_code:
++        for arg in args:
++            if arg.startswith("--installroot="):
++                root=arg.split("=")[1]
++                if os.path.exists(os.path.join(root, "log_lock.pid")):
++                    os.unlink(os.path.join(root, "log_lock.pid"))
++                break
+         sys.exit(errcode)
+     return errcode
+ 
+-- 
+2.25.1
+
diff --git a/meta/recipes-devtools/dnf/dnf_4.18.2.bb 
b/meta/recipes-devtools/dnf/dnf_4.18.2.bb
index dc0c18be5e..7770c9d7e0 100644
--- a/meta/recipes-devtools/dnf/dnf_4.18.2.bb
+++ b/meta/recipes-devtools/dnf/dnf_4.18.2.bb
@@ -17,7 +17,8 @@ SRC_URI = 
"git://github.com/rpm-software-management/dnf.git;branch=master;protoc
            file://0001-set-python-path-for-completion_helper.patch \
            "
 
-SRC_URI:append:class-native = 
"file://0001-dnf-write-the-log-lock-to-root.patch"
+SRC_URI:append:class-native = 
"file://0001-dnf-write-the-log-lock-to-root.patch \
+                               
file://0001-main.py-remove-log_lock.pid-before-exit.patch"
 
 SRCREV = "1c43d0999178d492381ad0b43917ffd9c74016f8"
 UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)"
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#196780): 
https://lists.openembedded.org/g/openembedded-core/message/196780
Mute This Topic: https://lists.openembedded.org/mt/104784184/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to