Add plugin parser plugin to generate /etc/skel image 52/322852/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 16 Apr 2025 13:53:09 +0000 (15:53 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 16 Apr 2025 14:20:42 +0000 (16:20 +0200)
To be used to make adding subsession faster.  They way it's inteded to be is

 1. Template image from /etc/skel is generated per each user (FIXME) after any package is installed
  - check case if no package is installed during image build (FIXME)
  - file has to be generated in some sensible directory, not /tmp (FIXME)

 2. sessiond add will copy the image file instead of creating their own (TODO)
  - sessiond has to resize the image to users specified size (TODO)

Change-Id: I2b859f71174c690fa2c1658f2986fad60dd803e9

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

index 300df5ce31861f9212aed1a98d12d52d538d5635..01463c9cfecfe2376a80c06209c1485227c41243 100644 (file)
@@ -13,6 +13,11 @@ 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)
+BuildRequires: pkgconfig(pkgmgr-info)
 %description
 
 %package -n libsessiond
@@ -84,6 +89,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..7abe90b
--- /dev/null
@@ -0,0 +1,17 @@
+FIND_PACKAGE(PkgConfig)
+INCLUDE(GNUInstallDirs)
+
+pkg_check_modules(deps REQUIRED
+                  dlog
+                  capi-system-info
+                  libxml-2.0
+                  pkgmgr-info
+                  )
+
+ADD_LIBRARY(libsessiond-update-skelimg SHARED sessiond-update-skelimg.c)
+TARGET_COMPILE_OPTIONS(libsessiond-update-skelimg PUBLIC -fPIC)
+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/sessiond-update-skelimg.c b/src/tpkplugin/sessiond-update-skelimg.c
new file mode 100644 (file)
index 0000000..507b884
--- /dev/null
@@ -0,0 +1,78 @@
+#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) {
+
+       return !!system("/usr/sbin/mkfs.ext2 -E root_owner=5001 -m0 -d /etc/skel /tmp/etc-skel-5001.img");
+}
+
+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"