#include <rpm/rpmstring.h>
#include <rpm/rpmts.h>
-#include <rpm/rpmplugins.h>
+#include "lib/rpmplugins.h"
#define STR1(x) #x
#define STR(x) STR1(x)
rpmRC rpmpluginsAdd(rpmPlugins plugins, const char *name, const char *path,
const char *opts)
{
- rpmPluginHook *supportedHooks;
char *error;
void *handle = dlopen(path, RTLD_LAZY);
}
/* make sure the plugin has the supported hooks flag */
- supportedHooks = (rpmPluginHook *) dlsym(handle, STR(PLUGIN_HOOKS));
+ (void) dlsym(handle, STR(PLUGIN_HOOKS));
if ((error = dlerror()) != NULL) {
rpmlog(RPMLOG_ERR, _("Failed to resolve symbol %s: %s\n"),
STR(PLUGIN_HOOKS), error);
return rpmpluginsCallInit(plugins, name, opts);
}
-rpmRC rpmpluginsAddCollectionPlugin(rpmPlugins plugins, const char *name)
+rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name)
{
char *path;
char *options;
rpmRC rc = RPMRC_FAIL;
- path = rpmExpand("%{?__collection_", name, "}", NULL);
+ path = rpmExpand("%{?__", type, "_", name, "}", NULL);
if (!path || rstreq(path, "")) {
- rpmlog(RPMLOG_ERR, _("Failed to expand %%__collection_%s macro\n"),
- name);
+ rpmlog(RPMLOG_ERR, _("Failed to expand %%__%s_%s macro\n"),
+ type, name);
goto exit;
}
RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_COLL_PRE_REMOVE);
return hookFunc();
}
+
+rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts)
+{
+ rpmRC (*hookFunc)(rpmts);
+ 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_PRE);
+ if (hookFunc(ts) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res)
+{
+ 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, res) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te)
+{
+ rpmRC (*hookFunc)(rpmte);
+ 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_PRE);
+ if (hookFunc(te) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res)
+{
+ 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, res) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallScriptletPre(rpmPlugins plugins, const char *s_name, int type)
+{
+ rpmRC (*hookFunc)(const char*, 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_SCRIPTLET_PRE);
+ if (hookFunc(s_name, type) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallScriptletForkPost(rpmPlugins plugins, const char *path, int type)
+{
+ rpmRC (*hookFunc)(const char*, 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_SCRIPTLET_FORK_POST);
+ if (hookFunc(path, type) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallScriptletPost(rpmPlugins plugins, const char *s_name, int type, int res)
+{
+ rpmRC (*hookFunc)(const char*, int, 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_SCRIPTLET_POST);
+ if (hookFunc(s_name, type, res) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallVerify(rpmPlugins plugins, rpmKeyring keyring, rpmtd sigtd,
+ pgpDigParams sig, DIGEST_CTX ctx, int res)
+{
+ rpmRC (*hookFunc)(rpmKeyring, rpmtd, pgpDigParams, DIGEST_CTX, 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_VERIFY);
+ if (hookFunc(keyring, sigtd, sig, ctx, res) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallFsmInit(rpmPlugins plugins, const char* path,
+ mode_t mode)
+{
+ rpmRC (*hookFunc)(const char*, mode_t);
+ 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_FSM_INIT);
+ if (hookFunc(path, mode) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallFsmCommit(rpmPlugins plugins, const char* path,
+ mode_t mode, int type)
+{
+ rpmRC (*hookFunc)(const char*, mode_t, 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_FSM_COMMIT);
+ if (hookFunc(path, mode, type) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}
+
+rpmRC rpmpluginsCallFileConflict(rpmPlugins plugins, rpmts ts, char* path,
+ Header oldHeader, rpmfi oldFi, int res)
+{
+ rpmRC (*hookFunc)(rpmts, char*, Header, rpmfi, 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_FILE_CONFLICT);
+ if (hookFunc(ts, path, oldHeader, oldFi, res) == RPMRC_FAIL)
+ rc = RPMRC_FAIL;
+ }
+
+ return rc;
+}