-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>
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:
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;
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;
}
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;
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;
}
* 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
* 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
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);
tsprobs = checkProblems(ts);
/* Run pre transaction hook for all plugins */
+ TsmPreDone = 1;
if (rpmpluginsCallTsmPre(ts->plugins, ts) == RPMRC_FAIL) {
goto exit;
}
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);
/* per transaction plugin hooks */
rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts);
-rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts);
+rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res);
/* per transaction element plugin hooks */
rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te);
-rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te);
+rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res);
/*per scriptlet plugin hooks */
rpmRC PLUGINHOOK_SCRIPTLET_PRE_FUNC(const char *s_name, int type);