Initialize plugins much earlier
- Lazily initialize plugins when adding install or erase elements to the transaction already. Since this ensures the setup will always be performed, there's no need to do this from rpmtsRun() anymore, empty transaction would not get that far anyway. - This will allow adding hooks to the places where package header is still available (which is required for various things) and in general, before transaction is actually executed. - The downside here is that adding or removing packages to a transaction can now fail due to plugin initialization failure where its not easily distinguishable from other errors, but then they can also fail due to rpmdb open failure which kinda similar "shouldn't be here" issue. The alternative would be initializing the plugins in rpmtsCreate() but as that's not actually permitted to fail at all, its not an option really.
This commit is contained in:
parent
3420601fb5
commit
51b306686c
|
@ -395,6 +395,11 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
|
|||
int ec = 0;
|
||||
int oc = tsmem->orderCount;
|
||||
|
||||
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL) {
|
||||
ec = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Check for supported payload format if it's a package */
|
||||
if (key && headerCheckPayloadFormat(h) != RPMRC_OK) {
|
||||
ec = 1;
|
||||
|
@ -462,6 +467,8 @@ exit:
|
|||
|
||||
int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
|
||||
{
|
||||
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
|
||||
return 1;
|
||||
return removePackage(ts, h, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types);
|
|||
RPM_GNUC_INTERNAL
|
||||
int rpmtsSolve(rpmts ts, rpmds key);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
rpmRC rpmtsSetupTransactionPlugins(rpmts ts);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1415,13 +1415,21 @@ static int rpmtsProcess(rpmts ts)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
|
||||
rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
|
||||
{
|
||||
rpmRC rc = RPMRC_OK;
|
||||
char *plugins = NULL, *plugin = NULL;
|
||||
const char *delims = ",";
|
||||
rpmPlugins tsplugins;
|
||||
|
||||
/*
|
||||
* Assume allocated equals initialized. There are some oddball cases
|
||||
* (verification of non-installed package) where this is not true
|
||||
* currently but that's not a new issue.
|
||||
*/
|
||||
if (ts->plugins != NULL)
|
||||
return RPMRC_OK;
|
||||
|
||||
plugins = rpmExpand("%{?__transaction_plugins}", NULL);
|
||||
if (!plugins || rstreq(plugins, "")) {
|
||||
goto exit;
|
||||
|
@ -1475,10 +1483,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rpmtsSetupCollections(ts);
|
||||
|
||||
/* Check package set for problems */
|
||||
|
|
Loading…
Reference in New Issue