diff options
author | Elena Reshetova <elena.reshetova@intel.com> | 2012-11-30 18:35:44 +0200 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-02-02 16:44:45 -0800 |
commit | 86e7c4ecfd94737f5ede5cadcc2600ea654c399f (patch) | |
tree | f775ce105008011df57ea4eca7d55159bdb253c0 /lib | |
parent | 78b3ad646be7c502f0e9b7d1b76de76ba50601ca (diff) | |
download | rpm-86e7c4ecfd94737f5ede5cadcc2600ea654c399f.tar.gz rpm-86e7c4ecfd94737f5ede5cadcc2600ea654c399f.tar.bz2 rpm-86e7c4ecfd94737f5ede5cadcc2600ea654c399f.zip |
Making pre/post tsm/psm hooks more consistent.
-All post hooks take an additional rc argument that indicates general return code from operation.
-All post hooks are always called if correspoding pre hook has been called.
-The return value from post hooks is curently ignored
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psm.c | 25 | ||||
-rw-r--r-- | lib/rpmplugins.c | 12 | ||||
-rw-r--r-- | lib/rpmplugins.h | 6 | ||||
-rw-r--r-- | lib/transaction.c | 10 |
4 files changed, 29 insertions, 24 deletions
@@ -1048,21 +1048,22 @@ rpmRC rpmpsmRun(rpmts ts, rpmte te, pkgGoal goal) case PKG_INSTALL: case PKG_ERASE: /* Run pre transaction element hook for all plugins */ - if (rpmpluginsCallPsmPre(ts->plugins, te) == RPMRC_FAIL) - break; - op = (goal == PKG_INSTALL) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE; - rpmswEnter(rpmtsOp(psm->ts, op), 0); + if (rpmpluginsCallPsmPre(ts->plugins, te) != RPMRC_FAIL) { - rc = rpmpsmNext(psm, PSM_INIT); - if (!rc) rc = rpmpsmNext(psm, PSM_PRE); - if (!rc) rc = rpmpsmNext(psm, PSM_PROCESS); - if (!rc) rc = rpmpsmNext(psm, PSM_POST); - (void) rpmpsmNext(psm, PSM_FINI); + op = (goal == PKG_INSTALL) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE; + rpmswEnter(rpmtsOp(psm->ts, op), 0); - rpmswExit(rpmtsOp(psm->ts, op), 0); - /* Run post transaction element hook for all plugins */ - if (!rc) rc = rpmpluginsCallPsmPost(ts->plugins, te); + rc = rpmpsmNext(psm, PSM_INIT); + if (!rc) rc = rpmpsmNext(psm, PSM_PRE); + if (!rc) rc = rpmpsmNext(psm, PSM_PROCESS); + if (!rc) rc = rpmpsmNext(psm, PSM_POST); + (void) rpmpsmNext(psm, PSM_FINI); + rpmswExit(rpmtsOp(psm->ts, op), 0); + } + + /* Run post transaction element hook for all plugins */ + rpmpluginsCallPsmPost(ts->plugins, te, rc); break; case PKG_PRETRANS: case PKG_POSTTRANS: diff --git a/lib/rpmplugins.c b/lib/rpmplugins.c index c721cadbc..d5ab09a9d 100644 --- a/lib/rpmplugins.c +++ b/lib/rpmplugins.c @@ -213,9 +213,9 @@ rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts) return rc; } -rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts) +rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res) { - rpmRC (*hookFunc)(rpmts); + rpmRC (*hookFunc)(rpmts, int); int i; rpmRC rc = RPMRC_OK; const char *name = NULL; @@ -223,7 +223,7 @@ rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts) for (i = 0; i < plugins->count; i++) { name = plugins->names[i]; RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_TSM_POST); - if (hookFunc(ts) == RPMRC_FAIL) + if (hookFunc(ts, res) == RPMRC_FAIL) rc = RPMRC_FAIL; } @@ -247,9 +247,9 @@ rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te) return rc; } -rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te) +rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res) { - rpmRC (*hookFunc)(rpmte); + rpmRC (*hookFunc)(rpmte, int); int i; rpmRC rc = RPMRC_OK; const char *name = NULL; @@ -257,7 +257,7 @@ rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te) for (i = 0; i < plugins->count; i++) { name = plugins->names[i]; RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_PSM_POST); - if (hookFunc(te) == RPMRC_FAIL) + if (hookFunc(te, res) == RPMRC_FAIL) rc = RPMRC_FAIL; } diff --git a/lib/rpmplugins.h b/lib/rpmplugins.h index ffb8fe161..cff3e6cc1 100644 --- a/lib/rpmplugins.h +++ b/lib/rpmplugins.h @@ -157,9 +157,10 @@ rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts); * Call the post transaction plugin hook * @param plugins plugins structure * @param ts processed transaction + * @param res transaction result code * @return RPMRC_OK on success, RPMRC_FAIL otherwise */ -rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts); +rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res); /** \ingroup rpmplugins * Call the pre transaction element plugin hook @@ -173,9 +174,10 @@ rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te); * Call the post transaction element plugin hook * @param plugins plugins structure * @param te processed transaction element + * @param res transaction element result code * @return RPMRC_OK on success, RPMRC_FAIL otherwise */ -rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te); +rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res); /** \ingroup rpmplugins * Call the pre scriptlet execution plugin hook diff --git a/lib/transaction.c b/lib/transaction.c index 87287478b..3a7cb740c 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1473,6 +1473,8 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) tsMembers tsmem = rpmtsMembers(ts); rpmlock lock = NULL; rpmps tsprobs = NULL; + int TsmPreDone = 0; /* TsmPre hook hasn't been called */ + /* Force default 022 umask during transaction for consistent results */ mode_t oldmask = umask(022); @@ -1504,6 +1506,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) tsprobs = checkProblems(ts); /* Run pre transaction hook for all plugins */ + TsmPreDone = 1; if (rpmpluginsCallTsmPre(ts->plugins, ts) == RPMRC_FAIL) { goto exit; } @@ -1551,12 +1554,11 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) runTransScripts(ts, PKG_POSTTRANS); } +exit: /* Run post transaction hook for all plugins */ - if (rpmpluginsCallTsmPost(ts->plugins, ts) == RPMRC_FAIL) { - goto exit; - } + if (TsmPreDone) /* If TsmPre hook has been called, call the TsmPost hook */ + rpmpluginsCallTsmPost(ts->plugins, ts, rc); -exit: /* Finish up... */ (void) umask(oldmask); (void) rpmtsFinish(ts); |