Add priorities between file triggers and the other scriptlets.

File triggers defined with priority greater than or equal to 100000
will be executed before standard scriptlests. The other file triggers
will be executed after standard scriptlets.
This commit is contained in:
Lubos Kardos 2015-07-23 12:16:56 +02:00
parent afdfbb6006
commit 8100d663c1
4 changed files with 66 additions and 13 deletions

View File

@ -682,6 +682,17 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
rc = dbAdd(ts, psm->te);
if (rc) break;
/* Run upper file triggers i. e. with higher priorities */
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER, 1);
if (rc) break;
/* Run file triggers in this package other package(s) set off. */
rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER, 1);
if (rc) break;
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOST)) {
rc = runInstScript(psm, RPMTAG_POSTIN);
if (rc) break;
@ -696,14 +707,15 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
if (rc) break;
}
/* Run lower file triggers i. e. with lower priorities */
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER);
RPMSCRIPT_FILETRIGGER, 2);
if (rc) break;
/* Run file triggers in this package other package(s) set off. */
rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER);
RPMSCRIPT_FILETRIGGER, 2);
if (rc) break;
rc = markReplacedFiles(psm);
@ -724,12 +736,12 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
/* Run file triggers in this package other package(s) set off. */
rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
RPMSCRIPT_FILETRIGGER);
RPMSCRIPT_FILETRIGGER, 1);
if (rc) break;
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
RPMSCRIPT_FILETRIGGER);
RPMSCRIPT_FILETRIGGER, 1);
if (rc) break;
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
@ -745,9 +757,23 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPREUN))
rc = runInstScript(psm, RPMTAG_PREUN);
/* Run file triggers in this package other package(s) set off. */
rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
RPMSCRIPT_FILETRIGGER, 2);
if (rc) break;
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
RPMSCRIPT_FILETRIGGER, 2);
if (rc) break;
rc = rpmpsmRemove(psm);
if (rc) break;
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
RPMSCRIPT_FILETRIGGER, 1);
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOSTUN)) {
rc = runInstScript(psm, RPMTAG_POSTUN);
if (rc) break;
@ -761,7 +787,7 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
/* Run file triggers in other package(s) this package sets off. */
rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
RPMSCRIPT_FILETRIGGER);
RPMSCRIPT_FILETRIGGER, 2);
if (rc) break;
/* Prepare post transaction uninstall triggers */
@ -816,11 +842,11 @@ rpmRC rpmpsmRun(rpmts ts, rpmte te, pkgGoal goal)
break;
case PKG_TRANSFILETRIGGERIN:
rc = runImmedFileTriggers(ts, te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_TRANSFILETRIGGER);
RPMSCRIPT_TRANSFILETRIGGER, 0);
break;
case PKG_TRANSFILETRIGGERUN:
rc = runImmedFileTriggers(ts, te, RPMSENSE_TRIGGERUN,
RPMSCRIPT_TRANSFILETRIGGER);
RPMSCRIPT_TRANSFILETRIGGER, 0);
break;
default:
break;

View File

@ -12,6 +12,7 @@
#include "lib/rpmds_internal.h"
#include "lib/rpmfi_internal.h"
#define TRIGGER_PRIORITY_BOUND 10000
rpmtriggers rpmtriggersCreate(unsigned int hint)
{
@ -466,7 +467,7 @@ static int matchFilesInTran(rpmts ts, rpmte te, const char *pfx,
}
rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
rpmscriptTriggerModes tm)
rpmscriptTriggerModes tm, int priorityClass)
{
int nerrors = 0, i;
rpmdbIndexIterator ii;
@ -533,6 +534,14 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
/* Handle stored triggers */
for (i = 0; i < triggers->count; i++) {
if (priorityClass == 1) {
if (triggers->triggerInfo[i].priority < TRIGGER_PRIORITY_BOUND)
continue;
} else if (priorityClass == 2) {
if (triggers->triggerInfo[i].priority >= TRIGGER_PRIORITY_BOUND)
continue;
}
trigH = rpmdbGetHeaderAt(rpmtsGetRdb(ts), triggers->triggerInfo[i].hdrNum);
if (tm == RPMSCRIPT_FILETRIGGER)
nerrors += runHandleTriggersInPkg(ts, te, trigH, sense, tm, 0,
@ -548,7 +557,7 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
}
rpmRC runImmedFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
rpmscriptTriggerModes tm)
rpmscriptTriggerModes tm, int priorityClass)
{
int nerrors = 0;
int triggersCount, i;
@ -577,6 +586,14 @@ rpmRC runImmedFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
rpmtriggersSortAndUniq(triggers);
for (i = 0; i < triggersCount; i++) {
if (priorityClass == 1) {
if (triggers->triggerInfo[i].priority < TRIGGER_PRIORITY_BOUND)
continue;
} else if (priorityClass == 2) {
if (triggers->triggerInfo[i].priority >= TRIGGER_PRIORITY_BOUND)
continue;
}
nerrors += runHandleTriggersInPkg(ts, te, trigH, sense, tm, 2,
triggers->triggerInfo[i].tix);
}

View File

@ -51,21 +51,31 @@ int runPostUnTransFileTrigs(rpmts ts);
* @param te transaction entry
* @param sense defines which triggers should be set off (triggerin,
* triggerun, triggerpostun)
* @param triggerClass 1 to run triggers that should be executed before
* standard scriptlets
* 2 to run triggers that should be executed after
* standard scriptlets
* 0 to run all triggers
* @param tm trigger mode, (filetrigger/transfiletrigger)
*/
RPM_GNUC_INTERNAL
rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
rpmscriptTriggerModes tm);
rpmscriptTriggerModes tm, int upper);
/* Run file triggers in this te other package(s) set off.
* @param ts transaction set
* @param te transaction entry
* @param sense defines which triggers should be set off (triggerin,
* triggerun, triggerpostun)
* @param triggerClass 1 to run triggers that should be executed before
* standard scriptlets
* 2 to run triggers that should be executed after
* standard scriptlets
* 0 to run all triggers
* @param tm trigger mode, (filetrigger/transfiletrigger)
*/
rpmRC runImmedFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
rpmscriptTriggerModes tm);
rpmscriptTriggerModes tm, int upper);
#ifdef __cplusplus
}
#endif

View File

@ -1491,7 +1491,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
if (!rpmpsNumProblems(tsprobs)) {
/* Run file triggers in this package other package(s) set off. */
runFileTriggers(ts, NULL, RPMSENSE_TRIGGERUN,
RPMSCRIPT_TRANSFILETRIGGER);
RPMSCRIPT_TRANSFILETRIGGER, 0);
/* Run file triggers in other package(s) this package sets off. */
runTransScripts(ts, PKG_TRANSFILETRIGGERUN);
}
@ -1541,7 +1541,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
}
/* Run file triggers in other package(s) this package sets off. */
runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER);
runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER, 0);
runPostUnTransFileTrigs(ts);
/* Run file triggers in this package other package(s) set off. */