2010-08-31 04:32:27 +08:00
|
|
|
#include "plugin.h"
|
2010-06-22 05:04:40 +08:00
|
|
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2010-08-31 04:32:27 +08:00
|
|
|
static char * options;
|
|
|
|
static char * name;
|
2010-06-22 05:04:40 +08:00
|
|
|
|
2010-08-31 04:32:27 +08:00
|
|
|
rpmPluginHook PLUGIN_HOOKS = \
|
|
|
|
PLUGINHOOK_INIT | \
|
|
|
|
PLUGINHOOK_CLEANUP | \
|
|
|
|
PLUGINHOOK_COLL_POST_ANY;
|
|
|
|
|
|
|
|
rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
|
|
|
|
{
|
|
|
|
options = strdup(opts);
|
|
|
|
name = strdup(name);
|
|
|
|
return RPMRC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
|
|
|
|
{
|
|
|
|
options = _free(options);
|
|
|
|
name = _free(name);
|
|
|
|
return RPMRC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void)
|
2010-06-22 05:04:40 +08:00
|
|
|
{
|
2010-09-21 16:37:21 +08:00
|
|
|
rpmRC rc = RPMRC_FAIL;
|
2010-06-22 05:04:40 +08:00
|
|
|
|
|
|
|
if (rpmChrootIn()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
int status = system(options);
|
|
|
|
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
|
2010-08-31 04:32:27 +08:00
|
|
|
rpmlog(RPMLOG_ERR, "%s collection action failed\n", name);
|
2010-06-22 05:04:40 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = RPMRC_OK;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if (rpmChrootOut()) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|