summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2008-12-02 10:11:44 +0100
committerFlorian Festi <ffesti@redhat.com>2008-12-10 13:40:53 +0100
commit9c9410dc7afb3bfa9b47d2d4691fabd8f067c86b (patch)
tree7297968ff209db77a673e3f2bb6843da491fc8bc
parent8fa80b0f35574683beb19930264fa3b572c5ed24 (diff)
downloadlibrpm-tizen-9c9410dc7afb3bfa9b47d2d4691fabd8f067c86b.tar.gz
librpm-tizen-9c9410dc7afb3bfa9b47d2d4691fabd8f067c86b.tar.bz2
librpm-tizen-9c9410dc7afb3bfa9b47d2d4691fabd8f067c86b.zip
Move the run time part of fstates from rpmfi to rpmfs. Keep fstates in rpmfi as long as it is a real tag read from the rpmdb.
-rw-r--r--lib/fsm.c10
-rw-r--r--lib/psm.c8
-rw-r--r--lib/rpmfi.c20
-rw-r--r--lib/rpmfi_internal.h3
-rw-r--r--lib/rpmte.c29
-rw-r--r--lib/rpmte_internal.h18
6 files changed, 56 insertions, 32 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index b3f592047..64c83c506 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -15,6 +15,7 @@
#include "lib/fsm.h"
#define fsmUNSAFE fsmStage
#include "lib/rpmfi_internal.h" /* XXX fi->apath, ... */
+#include "lib/rpmte_internal.h" /* XXX rpmfs */
#include "lib/misc.h" /* XXX unameToUid() and gnameToGid() */
#include "debug.h"
@@ -636,6 +637,7 @@ static int fsmMapPath(FSM_t fsm)
i = fsm->ix;
if (fi && i >= 0 && i < fi->fc) {
rpmte te = fsmGetTe(fsm);
+ rpmfs fs = rpmteGetFileStates(te);
/* XXX these should use rpmfiFFlags() etc */
fsm->action = (fi->actions ? fi->actions[i] : FA_UNKNOWN);
fsm->fflags = (fi->fflags ? fi->fflags[i] : RPMFILE_NONE);
@@ -655,22 +657,22 @@ static int fsmMapPath(FSM_t fsm)
case FA_COPYIN:
case FA_CREATE:
if (rpmteType(te) == TR_ADDED)
- rpmfiSetFState(fi, i, RPMFILE_STATE_NORMAL);
+ rpmfsSetState(fs, i, RPMFILE_STATE_NORMAL);
break;
case FA_SKIPNSTATE:
if (rpmteType(te) == TR_ADDED)
- rpmfiSetFState(fi, i, RPMFILE_STATE_NOTINSTALLED);
+ rpmfsSetState(fs, i, RPMFILE_STATE_NOTINSTALLED);
break;
case FA_SKIPNETSHARED:
if (rpmteType(te) == TR_ADDED)
- rpmfiSetFState(fi, i, RPMFILE_STATE_NETSHARED);
+ rpmfsSetState(fs, i, RPMFILE_STATE_NETSHARED);
break;
case FA_SKIPCOLOR:
if (rpmteType(te) == TR_ADDED)
- rpmfiSetFState(fi, i, RPMFILE_STATE_WRONGCOLOR);
+ rpmfsSetState(fs, i, RPMFILE_STATE_WRONGCOLOR);
break;
case FA_BACKUP:
diff --git a/lib/psm.c b/lib/psm.c
index b26019ea2..7f68d4b08 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1401,11 +1401,13 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
if (psm->goal == PSM_PKGINSTALL) {
rpm_time_t installTime = (rpm_time_t) time(NULL);
- rpm_count_t fc = rpmfiFC(fi);
+ rpmfs fs = rpmteGetFileStates(psm->te);
+ rpm_count_t fc = rpmfsFC(fs);
+ char * fileStates = rpmfsGetStates(fs);
Header h = rpmteHeader(psm->te);
- if (fi->fstates != NULL && fc > 0) {
- headerPutChar(h, RPMTAG_FILESTATES, fi->fstates, fc);
+ if (fileStates != NULL && fc > 0) {
+ headerPutChar(h, RPMTAG_FILESTATES, fileStates, fc);
}
headerPutUint32(h, RPMTAG_INSTALLTIME, &installTime, 1);
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index 01625cbb4..067f2428d 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -1359,11 +1359,6 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags)
_hgfi(h, RPMTAG_FILEDEPENDSN, &td, scareFlags, fi->fddictn);
}
- /*
- * For installed packages, get the states here. For to-be-installed
- * packages fi->fstates is lazily created through rpmfiSetFState().
- * XXX file states not needed at all by TR_REMOVED.
- */
if (!(flags & RPMFI_NOFILESTATES))
_hgfi(h, RPMTAG_FILESTATES, &td, defFlags, fi->fstates);
@@ -1466,11 +1461,9 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0));
rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p)
{
- char * fstates = fi->fstates;
rpmFileAction * actions = fi->actions;
rpmte savep;
- fi->fstates = NULL;
fi->actions = NULL;
/* FIX: fi->actions is NULL */
fi = rpmfiFree(fi);
@@ -1479,25 +1472,12 @@ rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p)
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
(void) rpmtsSetRelocateElement(ts, savep);
- free(fi->fstates);
- fi->fstates = fstates;
free(fi->actions);
fi->actions = actions;
p->fi = fi;
return fi;
}
-void rpmfiSetFState(rpmfi fi, int ix, rpmfileState state)
-{
- if (fi != NULL && ix >= 0 && ix < fi->fc) {
- if (fi->fstates == NULL) {
- fi->fstates = xmalloc(sizeof(*fi->fstates) * fi->fc);
- memset(fi->fstates, RPMFILE_STATE_MISSING, fi->fc);
- }
- fi->fstates[ix] = state;
- }
-}
-
void rpmfiSetFReplacedSize(rpmfi fi, rpm_loff_t newsize)
{
if (fi != NULL && fi->i >= 0 && fi->i < fi->fc) {
diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h
index 1d50a5e09..9155c83bc 100644
--- a/lib/rpmfi_internal.h
+++ b/lib/rpmfi_internal.h
@@ -99,9 +99,6 @@ RPM_GNUC_INTERNAL
rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p);
RPM_GNUC_INTERNAL
-void rpmfiSetFState(rpmfi fi, int ix, rpmfileState state);
-
-RPM_GNUC_INTERNAL
void rpmfiSetFReplacedSize(rpmfi fi, rpm_loff_t newsize);
RPM_GNUC_INTERNAL
diff --git a/lib/rpmte.c b/lib/rpmte.c
index 43782a423..8a26fa1c8 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -755,17 +755,22 @@ rpmfs rpmfsNew(unsigned int fc) {
rpmfs fs = xmalloc(sizeof(*fs));
fs->fc = fc;
fs->replaced = NULL;
+ fs->states = NULL;
fs->numReplaced = fs->allocatedReplaced = 0;
return fs;
}
rpmfs rpmfsFree(rpmfs fs) {
fs->replaced = _free(fs->replaced);
-
+ fs->states = _free(fs->states);
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) {
@@ -800,3 +805,25 @@ sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced)
}
return NULL;
}
+
+void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state)
+{
+ assert(ix < fs->fc);
+ if (fs->states == NULL) {
+ fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
+ memset(fs->states, RPMFILE_STATE_MISSING, 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;
+}
+
+rpmfileState * rpmfsGetStates(rpmfs fs)
+{
+ return fs->states;
+}
diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h
index 53acacb2b..90b9d0352 100644
--- a/lib/rpmte_internal.h
+++ b/lib/rpmte_internal.h
@@ -92,10 +92,11 @@ struct rpmte_s {
struct rpmfs_s {
unsigned int fc;
+ rpmfileState * states;
+
sharedFileInfo replaced; /*!< (TR_ADDED) to be replaced files in the rpmdb */
int numReplaced;
int allocatedReplaced;
-
};
/**
@@ -130,6 +131,9 @@ 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
@@ -138,5 +142,17 @@ 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
+rpmfileState * rpmfsGetStates(rpmfs fs);
+
#endif /* _RPMTE_INTERNAL_H */