summaryrefslogtreecommitdiff
path: root/lib/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/transaction.c')
-rw-r--r--lib/transaction.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/transaction.c b/lib/transaction.c
index 5e43880ab..87287478b 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -22,6 +22,8 @@
#include "lib/rpmts_internal.h"
#include "rpmio/rpmhook.h"
+#include "lib/rpmplugins.h"
+
/* XXX FIXME: merge with existing (broken?) tests in system.h */
/* portability fiddles */
#if STATFS_IN_SYS_STATVFS
@@ -1436,6 +1438,35 @@ static int rpmtsProcess(rpmts ts)
return rc;
}
+static rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
+{
+ rpmRC rc = RPMRC_OK;
+ char *plugins = NULL, *plugin = NULL;
+ const char *delims = ",";
+
+ plugins = rpmExpand("%{?__transaction_plugins}", NULL);
+ if (!plugins || rstreq(plugins, "")) {
+ goto exit;
+ }
+
+ plugin = strtok(plugins, delims);
+ while(plugin != NULL) {
+ rpmlog(RPMLOG_DEBUG, "plugin is %s\n", plugin);
+ if (!rpmpluginsPluginAdded(ts->plugins, (const char*)plugin)) {
+ if (rpmpluginsAddPlugin(ts->plugins, "transaction",
+ (const char*)plugin) == RPMRC_FAIL) {
+ /* any configured plugin failing to load is a failure */
+ rc = RPMRC_FAIL;
+ }
+ }
+ plugin = strtok(NULL, delims);
+ }
+
+exit:
+ free(plugins);
+ return rc;
+}
+
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
{
int rc = -1; /* assume failure */
@@ -1463,11 +1494,20 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
goto exit;
}
+ if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL) {
+ goto exit;
+ }
+
rpmtsSetupCollections(ts);
/* Check package set for problems */
tsprobs = checkProblems(ts);
+ /* Run pre transaction hook for all plugins */
+ if (rpmpluginsCallTsmPre(ts->plugins, ts) == RPMRC_FAIL) {
+ goto exit;
+ }
+
/* Run pre-transaction scripts, but only if there are no known
* problems up to this point and not disabled otherwise. */
if (!((rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_NOPRE))
@@ -1511,6 +1551,11 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
runTransScripts(ts, PKG_POSTTRANS);
}
+ /* Run post transaction hook for all plugins */
+ if (rpmpluginsCallTsmPost(ts->plugins, ts) == RPMRC_FAIL) {
+ goto exit;
+ }
+
exit:
/* Finish up... */
(void) umask(oldmask);