Esempio n. 1
0
rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
{
    rpmRC rc = RPMRC_OK;
    ARGV_t files = NULL;
    int nfiles = 0;
    char *dsoPath = NULL;

    /*
     * 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 ((rpmtsFlags(ts) & RPMTRANS_FLAG_NOPLUGINS) || ts->plugins != NULL)
	return RPMRC_OK;

    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;
	}
	files = argvFree(files);
    }
    free(dsoPath);

    return rc;
}
Esempio n. 2
0
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;
    }

    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 */
		rc = RPMRC_FAIL;
	    }
	}
	plugin = strtok(NULL, delims);
    }

exit:
    free(plugins);
    return rc;
}