Initialize plugins based on DSO discovery

- %__transaction_plugins style configuration is problematic for plugins
  because we want plugins to be, well, pluggable. As in drop-in to
  enable, which is not achievable with a single macro entry. Look up
  all DSO's from the plugin dir and enable if a matching
  %__transaction_foo macro is defined.
- This isn't optimal but it'll buy us the drop-in capability, which
  is what matters most right now. We'll want to have forcability as
  well later on (ie it should be possible to require given plugins
  to be present)
This commit is contained in:
Panu Matilainen 2014-06-24 14:37:38 +03:00
parent 713914bde1
commit d8ebc90e64
2 changed files with 14 additions and 21 deletions

View File

@ -151,8 +151,9 @@ rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name
path = rpmExpand("%{?__", type, "_", name, "}", NULL);
if (!path || rstreq(path, "")) {
rpmlog(RPMLOG_ERR, _("Failed to expand %%__%s_%s macro\n"),
rpmlog(RPMLOG_DEBUG, _("Plugin %%__%s_%s not configured\n"),
type, name);
rc = RPMRC_NOTFOUND;
goto exit;
}

View File

@ -1352,9 +1352,9 @@ static int rpmtsProcess(rpmts ts)
rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
{
rpmRC rc = RPMRC_OK;
char *plugins = NULL, *plugin = NULL;
const char *delims = ",";
rpmPlugins tsplugins;
ARGV_t files = NULL;
int nfiles = 0;
char *dsoPath = NULL;
/*
* Assume allocated equals initialized. There are some oddball cases
@ -1364,27 +1364,19 @@ rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
if (ts->plugins != NULL)
return RPMRC_OK;
plugins = rpmExpand("%{?__transaction_plugins}", NULL);
if (!plugins || rstreq(plugins, "")) {
goto exit;
}
tsplugins = rpmtsPlugins(ts);
plugin = strtok(plugins, delims);
while(plugin != NULL) {
rpmlog(RPMLOG_DEBUG, "plugin is %s\n", plugin);
if (!rpmpluginsPluginAdded(tsplugins, plugin)) {
if (rpmpluginsAddPlugin(tsplugins, "transaction",
plugin) == RPMRC_FAIL) {
/* any configured plugin failing to load is a failure */
dsoPath = rpmExpand("%{__plugindir}/*.so", NULL);
if (rpmGlob(dsoPath, &nfiles, &files) == 0) {
rpmPlugins tsplugins = rpmtsPlugins(ts);
for (int i = 0; i < nfiles; i++) {
char *bn = basename(files[i]);
bn[strlen(bn)-strlen(".so")] = '\0';
if (rpmpluginsAddPlugin(tsplugins, "transaction", bn) == RPMRC_FAIL)
rc = RPMRC_FAIL;
}
}
plugin = strtok(NULL, delims);
files = argvFree(files);
}
free(dsoPath);
exit:
free(plugins);
return rc;
}