|
|
2f13d7 |
From 5c97d7f83f56015d6a37934cee4e55ed8d747890 Mon Sep 17 00:00:00 2001
|
|
|
2f13d7 |
From: chantra <chantr4@gmail.com>
|
|
|
2f13d7 |
Date: Tue, 8 Feb 2022 16:57:25 -0800
|
|
|
2f13d7 |
Subject: [PATCH 13/30] [plugin] add `plugin_fsm_file_install_func` plugin hook
|
|
|
2f13d7 |
|
|
|
2f13d7 |
This hook is to be called when installing individual files from the RPM.
|
|
|
2f13d7 |
---
|
|
|
bd9c00 |
lib/Makefile.in | 51 ++++++++++++++++++++++++++----------------------
|
|
|
2f13d7 |
lib/rpmplugin.h | 5 +++++
|
|
|
bd9c00 |
lib/rpmplugins.c | 37 +++++++++++++++++++++++++++++++++++
|
|
|
bd9c00 |
lib/rpmplugins.h | 15 ++++++++++++++
|
|
|
bd9c00 |
4 files changed, 85 insertions(+), 23 deletions(-)
|
|
|
2f13d7 |
|
|
|
bd9c00 |
diff --git a/lib/Makefile.in b/lib/Makefile.in
|
|
|
bd9c00 |
index e1965d8..c4bba25 100644
|
|
|
bd9c00 |
--- a/lib/Makefile.in
|
|
|
bd9c00 |
+++ b/lib/Makefile.in
|
|
|
bd9c00 |
@@ -173,10 +173,11 @@ am__librpm_la_SOURCES_DIST = backend/dbi.c backend/dbi.h \
|
|
|
bd9c00 |
rpmlock.c rpmlock.h misc.h relocation.c rpmscript.h \
|
|
|
bd9c00 |
rpmscript.c rpmchroot.c rpmchroot.h rpmplugins.c rpmplugins.h \
|
|
|
bd9c00 |
rpmplugin.h rpmug.c rpmug.h rpmtriggers.h rpmtriggers.c \
|
|
|
bd9c00 |
- rpmvs.c rpmvs.h backend/db3.c backend/bdb_ro.c \
|
|
|
bd9c00 |
- backend/ndb/glue.c backend/ndb/rpmpkg.c backend/ndb/rpmpkg.h \
|
|
|
bd9c00 |
- backend/ndb/rpmidx.c backend/ndb/rpmidx.h backend/ndb/rpmxdb.c \
|
|
|
bd9c00 |
- backend/ndb/rpmxdb.h backend/sqlite.c
|
|
|
bd9c00 |
+ rpmvs.c rpmvs.h rpmextents.c rpmextents_internal.h \
|
|
|
bd9c00 |
+ backend/db3.c backend/bdb_ro.c backend/ndb/glue.c \
|
|
|
bd9c00 |
+ backend/ndb/rpmpkg.c backend/ndb/rpmpkg.h backend/ndb/rpmidx.c \
|
|
|
bd9c00 |
+ backend/ndb/rpmidx.h backend/ndb/rpmxdb.c backend/ndb/rpmxdb.h \
|
|
|
bd9c00 |
+ backend/sqlite.c
|
|
|
bd9c00 |
am__dirstamp = $(am__leading_dot)dirstamp
|
|
|
bd9c00 |
@BDB_TRUE@am__objects_1 = backend/db3.lo
|
|
|
bd9c00 |
@BDB_RO_TRUE@am__objects_2 = backend/bdb_ro.lo
|
|
|
bd9c00 |
@@ -192,8 +193,8 @@ am_librpm_la_OBJECTS = backend/dbi.lo backend/dummydb.lo \
|
|
|
bd9c00 |
rpmlead.lo rpmps.lo rpmprob.lo rpmrc.lo rpmte.lo rpmts.lo \
|
|
|
bd9c00 |
rpmfs.lo signature.lo transaction.lo verify.lo rpmlock.lo \
|
|
|
bd9c00 |
relocation.lo rpmscript.lo rpmchroot.lo rpmplugins.lo rpmug.lo \
|
|
|
bd9c00 |
- rpmtriggers.lo rpmvs.lo $(am__objects_1) $(am__objects_2) \
|
|
|
bd9c00 |
- $(am__objects_3) $(am__objects_4)
|
|
|
bd9c00 |
+ rpmtriggers.lo rpmvs.lo rpmextents.lo $(am__objects_1) \
|
|
|
bd9c00 |
+ $(am__objects_2) $(am__objects_3) $(am__objects_4)
|
|
|
bd9c00 |
librpm_la_OBJECTS = $(am_librpm_la_OBJECTS)
|
|
|
bd9c00 |
AM_V_lt = $(am__v_lt_@AM_V@)
|
|
|
bd9c00 |
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
|
|
bd9c00 |
@@ -228,21 +229,21 @@ am__depfiles_remade = ./$(DEPDIR)/cpio.Plo ./$(DEPDIR)/depends.Plo \
|
|
|
bd9c00 |
./$(DEPDIR)/relocation.Plo ./$(DEPDIR)/rpmal.Plo \
|
|
|
bd9c00 |
./$(DEPDIR)/rpmchecksig.Plo ./$(DEPDIR)/rpmchroot.Plo \
|
|
|
bd9c00 |
./$(DEPDIR)/rpmdb.Plo ./$(DEPDIR)/rpmds.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmfi.Plo ./$(DEPDIR)/rpmfs.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmgi.Plo ./$(DEPDIR)/rpminstall.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmlead.Plo ./$(DEPDIR)/rpmlock.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmplugins.Plo ./$(DEPDIR)/rpmprob.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmps.Plo ./$(DEPDIR)/rpmrc.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmscript.Plo ./$(DEPDIR)/rpmtd.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmte.Plo ./$(DEPDIR)/rpmtriggers.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmts.Plo ./$(DEPDIR)/rpmug.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/rpmvs.Plo ./$(DEPDIR)/signature.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/tagexts.Plo ./$(DEPDIR)/tagname.Plo \
|
|
|
bd9c00 |
- ./$(DEPDIR)/transaction.Plo ./$(DEPDIR)/verify.Plo \
|
|
|
bd9c00 |
- backend/$(DEPDIR)/bdb_ro.Plo backend/$(DEPDIR)/db3.Plo \
|
|
|
bd9c00 |
- backend/$(DEPDIR)/dbi.Plo backend/$(DEPDIR)/dbiset.Plo \
|
|
|
bd9c00 |
- backend/$(DEPDIR)/dummydb.Plo backend/$(DEPDIR)/sqlite.Plo \
|
|
|
bd9c00 |
- backend/ndb/$(DEPDIR)/glue.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmextents.Plo ./$(DEPDIR)/rpmfi.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmfs.Plo ./$(DEPDIR)/rpmgi.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpminstall.Plo ./$(DEPDIR)/rpmlead.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmlock.Plo ./$(DEPDIR)/rpmplugins.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmprob.Plo ./$(DEPDIR)/rpmps.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmrc.Plo ./$(DEPDIR)/rpmscript.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmtd.Plo ./$(DEPDIR)/rpmte.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmtriggers.Plo ./$(DEPDIR)/rpmts.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/rpmug.Plo ./$(DEPDIR)/rpmvs.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/signature.Plo ./$(DEPDIR)/tagexts.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/tagname.Plo ./$(DEPDIR)/transaction.Plo \
|
|
|
bd9c00 |
+ ./$(DEPDIR)/verify.Plo backend/$(DEPDIR)/bdb_ro.Plo \
|
|
|
bd9c00 |
+ backend/$(DEPDIR)/db3.Plo backend/$(DEPDIR)/dbi.Plo \
|
|
|
bd9c00 |
+ backend/$(DEPDIR)/dbiset.Plo backend/$(DEPDIR)/dummydb.Plo \
|
|
|
bd9c00 |
+ backend/$(DEPDIR)/sqlite.Plo backend/ndb/$(DEPDIR)/glue.Plo \
|
|
|
bd9c00 |
backend/ndb/$(DEPDIR)/rpmidx.Plo \
|
|
|
bd9c00 |
backend/ndb/$(DEPDIR)/rpmpkg.Plo \
|
|
|
bd9c00 |
backend/ndb/$(DEPDIR)/rpmxdb.Plo
|
|
|
bd9c00 |
@@ -589,8 +590,9 @@ librpm_la_SOURCES = backend/dbi.c backend/dbi.h backend/dummydb.c \
|
|
|
bd9c00 |
signature.h transaction.c verify.c rpmlock.c rpmlock.h misc.h \
|
|
|
bd9c00 |
relocation.c rpmscript.h rpmscript.c rpmchroot.c rpmchroot.h \
|
|
|
bd9c00 |
rpmplugins.c rpmplugins.h rpmplugin.h rpmug.c rpmug.h \
|
|
|
bd9c00 |
- rpmtriggers.h rpmtriggers.c rpmvs.c rpmvs.h $(am__append_1) \
|
|
|
bd9c00 |
- $(am__append_4) $(am__append_5) $(am__append_8)
|
|
|
bd9c00 |
+ rpmtriggers.h rpmtriggers.c rpmvs.c rpmvs.h rpmextents.c \
|
|
|
bd9c00 |
+ rpmextents_internal.h $(am__append_1) $(am__append_4) \
|
|
|
bd9c00 |
+ $(am__append_5) $(am__append_8)
|
|
|
bd9c00 |
librpm_la_LDFLAGS = -version-info $(rpm_version_info)
|
|
|
bd9c00 |
librpm_la_LIBADD = $(top_builddir)/rpmio/librpmio.la @WITH_POPT_LIB@ \
|
|
|
bd9c00 |
@WITH_CAP_LIB@ @WITH_ACL_LIB@ @LIBINTL@ $(am__append_2) \
|
|
|
bd9c00 |
@@ -751,6 +753,7 @@ distclean-compile:
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmchroot.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmdb.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmds.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmextents.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmfi.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmfs.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmgi.Plo@am__quote@ # am--include-marker
|
|
|
bd9c00 |
@@ -981,6 +984,7 @@ distclean: distclean-am
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmchroot.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmdb.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmds.Plo
|
|
|
bd9c00 |
+ -rm -f ./$(DEPDIR)/rpmextents.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmfi.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmfs.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmgi.Plo
|
|
|
bd9c00 |
@@ -1080,6 +1084,7 @@ maintainer-clean: maintainer-clean-am
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmchroot.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmdb.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmds.Plo
|
|
|
bd9c00 |
+ -rm -f ./$(DEPDIR)/rpmextents.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmfi.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmfs.Plo
|
|
|
bd9c00 |
-rm -f ./$(DEPDIR)/rpmgi.Plo
|
|
|
2f13d7 |
diff --git a/lib/rpmplugin.h b/lib/rpmplugin.h
|
|
|
2f13d7 |
index fd81aec8d..877db81f3 100644
|
|
|
2f13d7 |
--- a/lib/rpmplugin.h
|
|
|
2f13d7 |
+++ b/lib/rpmplugin.h
|
|
|
2f13d7 |
@@ -60,6 +60,10 @@ typedef rpmRC (*plugin_fsm_file_prepare_func)(rpmPlugin plugin, rpmfi fi,
|
|
|
bd9c00 |
int fd, const char* path,
|
|
|
2f13d7 |
const char *dest,
|
|
|
2f13d7 |
mode_t file_mode, rpmFsmOp op);
|
|
|
2f13d7 |
+typedef rpmRC (*plugin_fsm_file_install_func)(rpmPlugin plugin, rpmfi fi,
|
|
|
2f13d7 |
+ const char* path,
|
|
|
2f13d7 |
+ mode_t file_mode, rpmFsmOp op);
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
|
|
|
2f13d7 |
typedef struct rpmPluginHooks_s * rpmPluginHooks;
|
|
|
2f13d7 |
struct rpmPluginHooks_s {
|
|
|
2f13d7 |
@@ -80,6 +84,7 @@ struct rpmPluginHooks_s {
|
|
|
2f13d7 |
plugin_fsm_file_pre_func fsm_file_pre;
|
|
|
2f13d7 |
plugin_fsm_file_post_func fsm_file_post;
|
|
|
2f13d7 |
plugin_fsm_file_prepare_func fsm_file_prepare;
|
|
|
2f13d7 |
+ plugin_fsm_file_install_func fsm_file_install;
|
|
|
2f13d7 |
};
|
|
|
2f13d7 |
|
|
|
2f13d7 |
#ifdef __cplusplus
|
|
|
2f13d7 |
diff --git a/lib/rpmplugins.c b/lib/rpmplugins.c
|
|
|
2f13d7 |
index 3da3097af..850a025a0 100644
|
|
|
2f13d7 |
--- a/lib/rpmplugins.c
|
|
|
2f13d7 |
+++ b/lib/rpmplugins.c
|
|
|
bd9c00 |
@@ -435,3 +435,40 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins plugins, rpmfi fi,
|
|
|
2f13d7 |
|
|
|
2f13d7 |
return rc;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
+rpmRC rpmpluginsCallFsmFileInstall(rpmPlugins plugins, rpmfi fi,
|
|
|
2f13d7 |
+ const char *path, mode_t file_mode,
|
|
|
2f13d7 |
+ rpmFsmOp op)
|
|
|
2f13d7 |
+{
|
|
|
2f13d7 |
+ plugin_fsm_file_install_func hookFunc;
|
|
|
2f13d7 |
+ int i;
|
|
|
2f13d7 |
+ rpmRC rc = RPMRC_OK;
|
|
|
2f13d7 |
+ rpmRC hook_rc;
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
+ for (i = 0; i < plugins->count; i++) {
|
|
|
2f13d7 |
+ rpmPlugin plugin = plugins->plugins[i];
|
|
|
2f13d7 |
+ RPMPLUGINS_SET_HOOK_FUNC(fsm_file_install);
|
|
|
2f13d7 |
+ if (hookFunc) {
|
|
|
2f13d7 |
+ hook_rc = hookFunc(plugin, fi, path, file_mode, op);
|
|
|
2f13d7 |
+ if (hook_rc == RPMRC_FAIL) {
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, "Plugin %s: hook fsm_file_install failed\n", plugin->name);
|
|
|
2f13d7 |
+ rc = RPMRC_FAIL;
|
|
|
2f13d7 |
+ } else if (hook_rc == RPMRC_PLUGIN_CONTENTS && rc != RPMRC_FAIL) {
|
|
|
2f13d7 |
+ if (rc == RPMRC_PLUGIN_CONTENTS) {
|
|
|
2f13d7 |
+ /* Another plugin already said it'd handle contents. It's
|
|
|
2f13d7 |
+ * undefined how these would combine, so treat this as a
|
|
|
2f13d7 |
+ * failure condition.
|
|
|
2f13d7 |
+ */
|
|
|
2f13d7 |
+ rc = RPMRC_FAIL;
|
|
|
2f13d7 |
+ } else {
|
|
|
2f13d7 |
+ /* Plugin will handle content */
|
|
|
2f13d7 |
+ rc = RPMRC_PLUGIN_CONTENTS;
|
|
|
2f13d7 |
+ }
|
|
|
2f13d7 |
+ }
|
|
|
2f13d7 |
+ }
|
|
|
2f13d7 |
+ }
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
+ return rc;
|
|
|
2f13d7 |
+}
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
diff --git a/lib/rpmplugins.h b/lib/rpmplugins.h
|
|
|
2f13d7 |
index 39762c376..5365cf698 100644
|
|
|
2f13d7 |
--- a/lib/rpmplugins.h
|
|
|
2f13d7 |
+++ b/lib/rpmplugins.h
|
|
|
bd9c00 |
@@ -168,6 +168,21 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins plugins, rpmfi fi,
|
|
|
bd9c00 |
int fd, const char *path, const char *dest,
|
|
|
2f13d7 |
mode_t mode, rpmFsmOp op);
|
|
|
2f13d7 |
|
|
|
2f13d7 |
+/** \ingroup rpmplugins
|
|
|
2f13d7 |
+ * Call the fsm file install plugin hook
|
|
|
2f13d7 |
+ * @param plugins plugins structure
|
|
|
2f13d7 |
+ * @param fi file info iterator (or NULL)
|
|
|
2f13d7 |
+ * @param path file object path
|
|
|
2f13d7 |
+ * @param file_mode file object mode
|
|
|
2f13d7 |
+ * @param op file operation + associated flags
|
|
|
2f13d7 |
+ * @return RPMRC_OK on success, RPMRC_FAIL otherwise
|
|
|
2f13d7 |
+ */
|
|
|
2f13d7 |
+RPM_GNUC_INTERNAL
|
|
|
2f13d7 |
+rpmRC rpmpluginsCallFsmFileInstall(rpmPlugins plugins, rpmfi fi,
|
|
|
2f13d7 |
+ const char* path, mode_t file_mode,
|
|
|
2f13d7 |
+ rpmFsmOp op);
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
+
|
|
|
2f13d7 |
#ifdef __cplusplus
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
#endif
|
|
|
2f13d7 |
--
|
|
|
2f13d7 |
2.35.1
|
|
|
2f13d7 |
|