File PackageKit-bsc1169739.patch of Package PackageKit.17504

From 68b4e17d24b508d799691e03445833fcdbdd671c Mon Sep 17 00:00:00 2001
From: Jonathan Kang <jonathankang@gnome.org>
Date: Mon, 30 Nov 2020 11:19:25 +0800
Subject: [PATCH] main: notify the service manager when it's beginning to
 shutdown

This makes sure that the main process won't get SIGTERM on shutdown,
for example timed exit after idling for a while. This fix the problem
that libzypp fails to clean up some temporary files when packagekitd
quits.
---
 configure.ac  | 1 +
 src/pk-main.c | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/configure.ac b/configure.ac
index 069dc3c88..b23ac2785 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,6 +217,7 @@ if test x$enable_systemd = xyes; then
 		    [has_systemdsystemunitdir=$with_systemdsystemunitdir],
 		    [has_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
 	AC_DEFINE(HAVE_SYSTEMD,1,[Build systemd code])
+    AC_DEFINE(HAVE_SYSTEMD_SD_DAEMON_H,1,[Have systemd sd-daemon.h])
 	AC_SUBST([systemdsystemunitdir], [$has_systemdsystemunitdir])
 fi
 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$has_systemdsystemunitdir"])
diff --git a/src/pk-main.c b/src/pk-main.c
index f21767734..03639b81f 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -32,6 +32,9 @@
 #include <glib-unix.h>
 #include <glib/gi18n.h>
 #include <packagekit-glib2/pk-debug.h>
+#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#include <systemd/sd-daemon.h>
+#endif
 
 #include "pk-engine.h"
 #include "pk-shared.h"
@@ -259,6 +262,10 @@ out:
 	syslog (LOG_DAEMON | LOG_DEBUG, "daemon quit");
 	closelog ();
 
+#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+    sd_notify (0, "STOPPING=1");
+#endif
+
 	if (timer_id > 0)
 		g_source_remove (timer_id);
 	if (loop != NULL)
-- 
2.28.0

From ff092d0e5742f02ab1aeeafefeaaa558d32ab0b0 Mon Sep 17 00:00:00 2001
From: Jonathan Kang <jonathankang@gnome.org>
Date: Tue, 1 Dec 2020 16:18:12 +0800
Subject: [PATCH] Revert "Revert "zypp: Clean up temporary files when PK
 quits""

packagekitd.service will be stopped on system shutdown and by manually
doing so. Thus the main process will be killed eventually and we have
to manually clean those tmporary libzypp files.

This reverts commit d8dd484ddfcea4750495fa92dcd2f580149432e7.

https://bugzilla.opensuse.org/show_bug.cgi?id=1169739
---
 backends/zypp/pk-backend-zypp.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index b1ce76915..9404abb1a 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1840,6 +1840,8 @@ pk_backend_destroy (PkBackend *backend)
 {
 	g_debug ("zypp_backend_destroy");
 
+	filesystem::recursive_rmdir (zypp::myTmpDir ());
+
 	g_free (_repoName);
 	delete priv;
 }
-- 
2.26.2

openSUSE Build Service is sponsored by