Eliminate now unnecessary init + cleanup hooks in exec plugin

- Since the plugin remembers its name and options and we get a handle
  to self, there's no more need to do this in the plugin itself.
This commit is contained in:
Panu Matilainen 2013-04-03 12:06:32 +03:00
parent f869670e78
commit 9fa806fea5
1 changed files with 3 additions and 20 deletions

View File

@ -5,26 +5,10 @@
#include "lib/rpmchroot.h"
#include "debug.h"
static char * options;
static char * name;
static rpmRC PLUGINHOOK_INIT_FUNC(rpmPlugin plugin,
rpmts ts, const char *name, const char *opts)
{
options = strdup(opts);
name = strdup(name);
return RPMRC_OK;
}
static void PLUGINHOOK_CLEANUP_FUNC(rpmPlugin plugin)
{
options = _free(options);
name = _free(name);
}
static rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(rpmPlugin plugin)
{
rpmRC rc = RPMRC_FAIL;
const char *options = rpmPluginOpts(plugin);
if (rpmChrootIn()) {
goto exit;
@ -33,7 +17,8 @@ static rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(rpmPlugin plugin)
if (options) {
int status = system(options);
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
rpmlog(RPMLOG_ERR, "%s collection action failed\n", name);
rpmlog(RPMLOG_ERR, "%s collection action failed\n",
rpmPluginName(plugin));
goto exit;
}
}
@ -49,7 +34,5 @@ static rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(rpmPlugin plugin)
}
struct rpmPluginHooks_s exec_hooks = {
.init = PLUGINHOOK_INIT_FUNC,
.cleanup = PLUGINHOOK_CLEANUP_FUNC,
.coll_post_any = PLUGINHOOK_COLL_POST_ANY_FUNC,
};