[Rpm-maint] [PATCH 2/2] Sample plugin example for testing

Elena Reshetova elena.reshetova at intel.com
Wed Oct 17 12:50:30 UTC 2012


This patch contains a simple sample transaction plugin (sampleplugin) with empty hooks.
---
 macros.in               |    6 ++++++
 plugins/Makefile.am     |    5 +++++
 plugins/sample-plugin.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 plugins/sample-plugin.c

diff --git a/macros.in b/macros.in
index f55dcbe..bf49c0b 100644
--- a/macros.in
+++ b/macros.in
@@ -1031,6 +1031,12 @@ done \
 %__collection_sepolicy_flags	1
 
 #------------------------------------------------------------------------------
+# Transaction specific macros
+%__transaction_plugins          sampleplugin
+%__plugindir		        %{_libdir}/rpm-plugins
+%__transaction_sampleplugin	%{__plugindir}/sampleplugin.so
+
+#------------------------------------------------------------------------------
 # Macros for further automated spec %setup and patch application
 
 # default to plain patch
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a9c962c..838c21e 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -24,3 +24,8 @@ sepolicy_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmi
 
 plugins_LTLIBRARIES += sepolicy.la
 endif
+
+sampleplugin_la_SOURCES = plugin.h sample-plugin.c
+sampleplugin_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la
+
+plugins_LTLIBRARIES += sampleplugin.la
diff --git a/plugins/sample-plugin.c b/plugins/sample-plugin.c
new file mode 100644
index 0000000..df38960
--- /dev/null
+++ b/plugins/sample-plugin.c
@@ -0,0 +1,47 @@
+#include "plugin.h"
+
+rpmPluginHook PLUGIN_HOOKS = \
+	PLUGINHOOK_INIT | \
+	PLUGINHOOK_CLEANUP | \
+        PLUGINHOOK_TSM_PRE | \
+        PLUGINHOOK_TSM_POST | \
+        PLUGINHOOK_PSM_PRE | \			
+        PLUGINHOOK_PSM_POST | \		
+        PLUGINHOOK_SCRIPT_SETUP;
+
+rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te)
+{
+    return RPMRC_OK;
+}
+
+rpmRC PLUGINHOOK_SCRIPT_SETUP_FUNC(char* path)
+{
+    rpmlog(RPMLOG_INFO, "Executable path: %s\n", path);
+    return RPMRC_OK;
+}
+
-- 
1.7.9.5



More information about the Rpm-maint mailing list