summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/rpmfs.c113
-rw-r--r--lib/rpmfs.h55
-rw-r--r--lib/rpmte.c98
-rw-r--r--lib/rpmte_internal.h73
5 files changed, 171 insertions, 170 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index fb7e7bfeb..8c8cf3a6b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -29,7 +29,7 @@ librpm_la_SOURCES = \
rpmal.c rpmal.h rpmchecksig.c rpmds.c rpmfi.c rpmfi_internal.h rpmgi.c \
rpminstall.c rpmts_internal.h \
rpmlead.c rpmlead.h rpmps.c rpmrc.c \
- rpmte.c rpmte_internal.h rpmts.c \
+ rpmte.c rpmte_internal.h rpmts.c rpmfs.h rpmfs.c \
rpmvercmp.c signature.c signature.h transaction.c \
verify.c rpmlock.c rpmlock.h misc.h \
rpmscript.h rpmscript.c legacy.c merge.c \
diff --git a/lib/rpmfs.c b/lib/rpmfs.c
new file mode 100644
index 000000000..50ed6d9f4
--- /dev/null
+++ b/lib/rpmfs.c
@@ -0,0 +1,113 @@
+#include "system.h"
+#include "lib/rpmfs.h"
+#include "debug.h"
+
+struct rpmfs_s {
+ unsigned int fc;
+
+ rpm_fstate_t * states;
+ rpmFileAction * actions; /*!< File disposition(s). */
+
+ sharedFileInfo replaced; /*!< (TR_ADDED) to be replaced files in the rpmdb */
+ int numReplaced;
+ int allocatedReplaced;
+};
+
+rpmfs rpmfsNew(unsigned int fc, rpmElementType type) {
+ rpmfs fs = xmalloc(sizeof(*fs));
+ fs->fc = fc;
+ fs->replaced = NULL;
+ fs->states = NULL;
+ if (type == TR_ADDED) {
+ fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
+ memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
+ }
+ fs->actions = xmalloc(fc * sizeof(*fs->actions));
+ memset(fs->actions, FA_UNKNOWN, fc * sizeof(*fs->actions));
+ fs->numReplaced = fs->allocatedReplaced = 0;
+ return fs;
+}
+
+rpmfs rpmfsFree(rpmfs fs) {
+ fs->replaced = _free(fs->replaced);
+ fs->states = _free(fs->states);
+ fs->actions = _free(fs->actions);
+
+ fs = _free(fs);
+ return fs;
+}
+
+rpm_count_t rpmfsFC(rpmfs fs) {
+ return fs->fc;
+}
+
+void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum)
+{
+ if (!fs->replaced) {
+ fs->replaced = xcalloc(3, sizeof(*fs->replaced));
+ fs->allocatedReplaced = 3;
+ }
+ if (fs->numReplaced>=fs->allocatedReplaced) {
+ fs->allocatedReplaced += (fs->allocatedReplaced>>1) + 2;
+ fs->replaced = xrealloc(fs->replaced, fs->allocatedReplaced*sizeof(*fs->replaced));
+ }
+ fs->replaced[fs->numReplaced].pkgFileNum = pkgFileNum;
+ fs->replaced[fs->numReplaced].otherPkg = otherPkg;
+ fs->replaced[fs->numReplaced].otherFileNum = otherFileNum;
+
+ fs->numReplaced++;
+}
+
+sharedFileInfo rpmfsGetReplaced(rpmfs fs)
+{
+ if (fs && fs->numReplaced)
+ return fs->replaced;
+ else
+ return NULL;
+}
+
+sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced)
+{
+ if (fs && replaced) {
+ replaced++;
+ if (replaced - fs->replaced < fs->numReplaced)
+ return replaced;
+ }
+ return NULL;
+}
+
+void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state)
+{
+ assert(ix < fs->fc);
+ fs->states[ix] = state;
+}
+
+rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix)
+{
+ assert(ix < fs->fc);
+ if (fs->states) return fs->states[ix];
+ return RPMFILE_STATE_MISSING;
+}
+
+rpm_fstate_t * rpmfsGetStates(rpmfs fs)
+{
+ return fs->states;
+}
+
+rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix)
+{
+ rpmFileAction action;
+ if (fs->actions != NULL && ix < fs->fc) {
+ action = fs->actions[ix];
+ } else {
+ action = FA_UNKNOWN;
+ }
+ return action;
+}
+
+void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action)
+{
+ if (fs->actions != NULL && ix < fs->fc) {
+ fs->actions[ix] = action;
+ }
+}
diff --git a/lib/rpmfs.h b/lib/rpmfs.h
new file mode 100644
index 000000000..c9ba8da53
--- /dev/null
+++ b/lib/rpmfs.h
@@ -0,0 +1,55 @@
+#ifndef _RPMFS_H
+#define _RPMFS_H
+
+#include <rpm/rpmfi.h>
+#include <rpm/rpmte.h>
+
+/** \ingroup rpmfs
+ * Transaction element file states.
+ */
+typedef struct rpmfs_s * rpmfs;
+typedef struct sharedFileInfo_s * sharedFileInfo;
+typedef char rpm_fstate_t;
+
+/* XXX psm needs access to these */
+struct sharedFileInfo_s {
+ int pkgFileNum;
+ int otherPkg;
+ int otherFileNum;
+};
+
+RPM_GNUC_INTERNAL
+rpmfs rpmfsNew(unsigned int fc, rpmElementType type);
+
+RPM_GNUC_INTERNAL
+rpmfs rpmfsFree(rpmfs fs);
+
+RPM_GNUC_INTERNAL
+rpm_count_t rpmfsFC(rpmfs fs);
+
+RPM_GNUC_INTERNAL
+void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum);
+
+RPM_GNUC_INTERNAL
+sharedFileInfo rpmfsGetReplaced(rpmfs fs);
+
+RPM_GNUC_INTERNAL
+sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced);
+
+RPM_GNUC_INTERNAL
+void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state);
+
+RPM_GNUC_INTERNAL
+rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix);
+
+/* May return NULL */
+RPM_GNUC_INTERNAL
+rpm_fstate_t * rpmfsGetStates(rpmfs fs);
+
+RPM_GNUC_INTERNAL
+rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
+
+/* XXX this should be internal too but build code needs for now */
+void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
+
+#endif /* _RPMFS_H */
diff --git a/lib/rpmte.c b/lib/rpmte.c
index c7ae0cbc0..9764c7c1e 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -735,101 +735,3 @@ rpmfs rpmteGetFileStates(rpmte te) {
return te->fs;
}
-rpmfs rpmfsNew(unsigned int fc, rpmElementType type) {
- rpmfs fs = xmalloc(sizeof(*fs));
- fs->fc = fc;
- fs->replaced = NULL;
- fs->states = NULL;
- if (type == TR_ADDED) {
- fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
- memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
- }
- fs->actions = xmalloc(fc * sizeof(*fs->actions));
- memset(fs->actions, FA_UNKNOWN, fc * sizeof(*fs->actions));
- fs->numReplaced = fs->allocatedReplaced = 0;
- return fs;
-}
-
-rpmfs rpmfsFree(rpmfs fs) {
- fs->replaced = _free(fs->replaced);
- fs->states = _free(fs->states);
- fs->actions = _free(fs->actions);
-
- fs = _free(fs);
- return fs;
-}
-
-rpm_count_t rpmfsFC(rpmfs fs) {
- return fs->fc;
-}
-
-void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum)
-{
- if (!fs->replaced) {
- fs->replaced = xcalloc(3, sizeof(*fs->replaced));
- fs->allocatedReplaced = 3;
- }
- if (fs->numReplaced>=fs->allocatedReplaced) {
- fs->allocatedReplaced += (fs->allocatedReplaced>>1) + 2;
- fs->replaced = xrealloc(fs->replaced, fs->allocatedReplaced*sizeof(*fs->replaced));
- }
- fs->replaced[fs->numReplaced].pkgFileNum = pkgFileNum;
- fs->replaced[fs->numReplaced].otherPkg = otherPkg;
- fs->replaced[fs->numReplaced].otherFileNum = otherFileNum;
-
- fs->numReplaced++;
-}
-
-sharedFileInfo rpmfsGetReplaced(rpmfs fs)
-{
- if (fs && fs->numReplaced)
- return fs->replaced;
- else
- return NULL;
-}
-
-sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced)
-{
- if (fs && replaced) {
- replaced++;
- if (replaced - fs->replaced < fs->numReplaced)
- return replaced;
- }
- return NULL;
-}
-
-void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state)
-{
- assert(ix < fs->fc);
- fs->states[ix] = state;
-}
-
-rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix)
-{
- assert(ix < fs->fc);
- if (fs->states) return fs->states[ix];
- return RPMFILE_STATE_MISSING;
-}
-
-rpm_fstate_t * rpmfsGetStates(rpmfs fs)
-{
- return fs->states;
-}
-
-rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix)
-{
- rpmFileAction action;
- if (fs->actions != NULL && ix < fs->fc) {
- action = fs->actions[ix];
- } else {
- action = FA_UNKNOWN;
- }
- return action;
-}
-
-void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action)
-{
- if (fs->actions != NULL && ix < fs->fc) {
- fs->actions[ix] = action;
- }
-}
diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h
index a3080b6ec..edf9a9f44 100644
--- a/lib/rpmte_internal.h
+++ b/lib/rpmte_internal.h
@@ -3,46 +3,13 @@
#include <rpm/rpmte.h>
#include <rpm/rpmds.h>
-
-/** \ingroup rpmte
- * Dependncy ordering information.
- */
-
-/**
- */
-typedef struct sharedFileInfo_s * sharedFileInfo;
+#include "lib/rpmfs.h"
/** \ingroup rpmte
* Transaction element ordering chain linkage.
*/
typedef struct tsortInfo_s * tsortInfo;
-/** \ingroup rpmte
- * Transaction element file states.
- */
-typedef struct rpmfs_s * rpmfs;
-
-/**
- */
-struct sharedFileInfo_s {
- int pkgFileNum;
- int otherPkg;
- int otherFileNum;
-};
-
-typedef char rpm_fstate_t;
-
-struct rpmfs_s {
- unsigned int fc;
-
- rpm_fstate_t * states;
- rpmFileAction * actions; /*!< File disposition(s). */
-
- sharedFileInfo replaced; /*!< (TR_ADDED) to be replaced files in the rpmdb */
- int numReplaced;
- int allocatedReplaced;
-};
-
RPM_GNUC_INTERNAL
rpmfi rpmteSetFI(rpmte te, rpmfi fi);
@@ -76,45 +43,9 @@ tsortInfo rpmteTSI(rpmte te);
RPM_GNUC_INTERNAL
void rpmteSetTSI(rpmte te, tsortInfo tsi);
-//RPM_GNUC_INTERNAL
+/* XXX should be internal too but build code needs for now... */
rpmfs rpmteGetFileStates(rpmte te);
-RPM_GNUC_INTERNAL
-rpmfs rpmfsNew(unsigned int fc, rpmElementType type);
-
-RPM_GNUC_INTERNAL
-rpmfs rpmfsFree(rpmfs fs);
-
-RPM_GNUC_INTERNAL
-rpm_count_t rpmfsFC(rpmfs fs);
-
-RPM_GNUC_INTERNAL
-void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum);
-
-RPM_GNUC_INTERNAL
-sharedFileInfo rpmfsGetReplaced(rpmfs fs);
-
-RPM_GNUC_INTERNAL
-sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced);
-
-RPM_GNUC_INTERNAL
-void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state);
-
-RPM_GNUC_INTERNAL
-rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix);
-
-/*
- * May return NULL
- */
-RPM_GNUC_INTERNAL
-rpm_fstate_t * rpmfsGetStates(rpmfs fs);
-
-RPM_GNUC_INTERNAL
-rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
-
-//RPM_GNUC_INTERNAL
-void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
-
/* XXX here for now... */
/**
* Relocate files in header.