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:
parent
f869670e78
commit
9fa806fea5
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue