Add tpk plugin to regenerate skel templates 58/324258/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 14 May 2025 12:55:15 +0000 (14:55 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 20 May 2025 17:33:17 +0000 (19:33 +0200)
Change-Id: I8271937ffaed46e4fba0b7e395081b905319942b

packaging/sessiond.spec
src/CMakeLists.txt
src/tpkplugin/CMakeLists.txt [new file with mode: 0644]
src/tpkplugin/plugin.c [new file with mode: 0644]
src/tpkplugin/sessiond-update-skelimg.info [new file with mode: 0644]

index c5d90e366d65ae880daf4e561b3771026831cafc..f3b8625aa28376430d94f37960877345dbe7562f 100644 (file)
@@ -13,6 +13,9 @@ BuildRequires: gtest-devel
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(libsyscommon-plugin-api-sessiond)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(libxml-2.0)
+BuildRequires: pkgconfig(pkgmgr-info)
 
 Requires:   /usr/sbin/mkfs.ext4
 
@@ -87,6 +90,8 @@ popd
 %{_unitdir}/sessiond.service
 %{_datadir}/dbus-1/system-services/org.tizen.system.sessiond.service
 /etc/dbus-1/system.d/org.tizen.sessiond.conf
+/etc/package-manager/parserlib/libsessiond-update-skelimg.so
+/usr/share/parser-plugins/sessiond-update-skelimg.info
 
 %files -n libsessiond
 %manifest sessiond.manifest
index fa8cc96a56c6dc818dd288e9c06f59daae6c0c7f..fda2a665101f858d221de9a4ae744fb2c8c39294 100644 (file)
@@ -1,3 +1,4 @@
 add_subdirectory(common)
 add_subdirectory(library)
 add_subdirectory(service)
+add_subdirectory(tpkplugin)
diff --git a/src/tpkplugin/CMakeLists.txt b/src/tpkplugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..eae3d9b
--- /dev/null
@@ -0,0 +1,16 @@
+FIND_PACKAGE(PkgConfig)
+INCLUDE(GNUInstallDirs)
+
+pkg_check_modules(deps REQUIRED
+                  dlog
+                  capi-system-info
+                  pkgmgr-info
+                  )
+
+ADD_LIBRARY(libsessiond-update-skelimg SHARED plugin.c)
+TARGET_COMPILE_OPTIONS(libsessiond-update-skelimg PUBLIC -fPIC ${deps_CFLAGS})
+TARGET_LINK_LIBRARIES(libsessiond-update-skelimg PRIVATE ${deps_LDFLAGS})
+
+INSTALL(TARGETS libsessiond-update-skelimg LIBRARY DESTINATION /etc/package-manager/parserlib/)
+INSTALL(FILES sessiond-update-skelimg.info DESTINATION /usr/share/parser-plugins/)
+
diff --git a/src/tpkplugin/plugin.c b/src/tpkplugin/plugin.c
new file mode 100644 (file)
index 0000000..ba7e9cc
--- /dev/null
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <dlog.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <pkgmgr-info.h>
+#include <stdlib.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "SESSIOND_GEN_SKEL_IMG"
+
+int gen_skel(void) {
+       // The logic for skel generation is not in plugin to make it possible to call it also manually during image build
+       return system("/usr/sbin/sessiond --regenerate-skel");
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char* packageId)
+{
+       SLOGD("Generate sessiond skel image for fast session add - triggered by %s package installation", packageId);
+       return gen_skel();
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char* packageId)
+{
+       SLOGD("Generate sessiond skel image for fast session add - triggered by %s package deinstallation", packageId);
+       return gen_skel();
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char* packageId)
+{
+       return 0;
+}
+
+EXPORT_API
+int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char* packageId)
+{
+       SLOGD("Generate sessiond skel image for fast session add - triggered by %s package upgrade", packageId);
+       return gen_skel();
+}
diff --git a/src/tpkplugin/sessiond-update-skelimg.info b/src/tpkplugin/sessiond-update-skelimg.info
new file mode 100644 (file)
index 0000000..20026c4
--- /dev/null
@@ -0,0 +1 @@
+type="tag";name="sessiond";path="/etc/package-manager/parserlib/libsessiond-update-skelimg.so"