Skip to content

Commit

Permalink
[plugin] add plugin_fsm_file_install_func plugin hook
Browse files Browse the repository at this point in the history
This hook is to be called when installing individual files from the RPM.
  • Loading branch information
chantra committed Feb 9, 2022
1 parent 0138e4f commit e2d9754
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rpmplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ typedef rpmRC (*plugin_fsm_file_prepare_func)(rpmPlugin plugin, rpmfi fi,
const char* path,
const char *dest,
mode_t file_mode, rpmFsmOp op);
typedef rpmRC (*plugin_fsm_file_install_func)(rpmPlugin plugin, rpmfi fi,
const char* path,
mode_t file_mode, rpmFsmOp op);


typedef struct rpmPluginHooks_s * rpmPluginHooks;
struct rpmPluginHooks_s {
Expand All @@ -80,6 +84,7 @@ struct rpmPluginHooks_s {
plugin_fsm_file_pre_func fsm_file_pre;
plugin_fsm_file_post_func fsm_file_post;
plugin_fsm_file_prepare_func fsm_file_prepare;
plugin_fsm_file_install_func fsm_file_install;
};

#ifdef __cplusplus
Expand Down
37 changes: 37 additions & 0 deletions lib/rpmplugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,40 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins plugins, rpmfi fi,

return rc;
}

rpmRC rpmpluginsCallFsmFileInstall(rpmPlugins plugins, rpmfi fi,
const char *path, mode_t file_mode,
rpmFsmOp op)
{
plugin_fsm_file_install_func hookFunc;
int i;
rpmRC rc = RPMRC_OK;
rpmRC hook_rc;

for (i = 0; i < plugins->count; i++) {
rpmPlugin plugin = plugins->plugins[i];
RPMPLUGINS_SET_HOOK_FUNC(fsm_file_install);
if (hookFunc) {
hook_rc = hookFunc(plugin, fi, path, file_mode, op);
if (hook_rc == RPMRC_FAIL) {
rpmlog(RPMLOG_ERR, "Plugin %s: hook fsm_file_install failed\n", plugin->name);
rc = RPMRC_FAIL;
} else if (hook_rc == RPMRC_PLUGIN_CONTENTS && rc != RPMRC_FAIL) {
if (rc == RPMRC_PLUGIN_CONTENTS) {
/* Another plugin already said it'd handle contents. It's
* undefined how these would combine, so treat this as a
* failure condition.
*/
rc = RPMRC_FAIL;
} else {
/* Plugin will handle content */
rc = RPMRC_PLUGIN_CONTENTS;
}
}
}
}

return rc;
}


15 changes: 15 additions & 0 deletions lib/rpmplugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins plugins, rpmfi fi,
const char *path, const char *dest,
mode_t mode, rpmFsmOp op);

/** \ingroup rpmplugins
* Call the fsm file install plugin hook
* @param plugins plugins structure
* @param fi file info iterator (or NULL)
* @param path file object path
* @param file_mode file object mode
* @param op file operation + associated flags
* @return RPMRC_OK on success, RPMRC_FAIL otherwise
*/
RPM_GNUC_INTERNAL
rpmRC rpmpluginsCallFsmFileInstall(rpmPlugins plugins, rpmfi fi,
const char* path, mode_t file_mode,
rpmFsmOp op);


#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit e2d9754

Please sign in to comment.