diff options
author | Elena Reshetova <elena.reshetova@intel.com> | 2012-10-17 14:55:39 +0300 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-02-02 16:44:44 -0800 |
commit | dca7f1cdfdcdee92e0c4e835e40472f59660d2b4 (patch) | |
tree | 335d8b961ea7b755ea148e8458f1be7a542f6a8e /lib/transaction.c | |
parent | e5571e11ba2a08eda4c0d3917511d36eab9e2777 (diff) | |
download | librpm-tizen-dca7f1cdfdcdee92e0c4e835e40472f59660d2b4.tar.gz librpm-tizen-dca7f1cdfdcdee92e0c4e835e40472f59660d2b4.tar.bz2 librpm-tizen-dca7f1cdfdcdee92e0c4e835e40472f59660d2b4.zip |
Extending rpm plugin interface, part 1
This change adds a new type of the rpm plugin, called transaction plugin
and a set of initial hooks for this plugin. The hooks are:
PLUGINHOOK_TSM_PRE
Pre-transaction hook that is called before an rpm transaction begins
PLUGINHOOK_TSM_POST
Post-transaction hook that is called after an rpm transaction ends
PLUGINHOOK_PSM_PRE
Pre-transaction-element hook that is called before an rpm
transaction-element is processed
PLUGINHOOK_PSM_POST
Post-transaction-element hook that is called after an rpm
transaction-element is processed
PLUGINHOOK_SCRIPT_SETUP
Per-script hook that is called once for each rpm mainainers script
that is present in the package
Each hook is called for every plugin that have this hook registered.
The avaliable transaction plugins can be specified in macros.in via
transaction_plugins element.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Diffstat (limited to 'lib/transaction.c')
-rw-r--r-- | lib/transaction.c | 45 |
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); |