diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-04-03 10:28:59 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-04-03 14:39:40 +0300 |
commit | 422b3e0e7c51f0a3a36266cfc4d99f456b800dec (patch) | |
tree | f1cef9af83af859a555ad06ae72868aed34b2858 | |
parent | 48e1864be17d7ae2a7ed8a951a22b00cee115c2d (diff) | |
download | rpm-422b3e0e7c51f0a3a36266cfc4d99f456b800dec.tar.gz rpm-422b3e0e7c51f0a3a36266cfc4d99f456b800dec.tar.bz2 rpm-422b3e0e7c51f0a3a36266cfc4d99f456b800dec.zip |
Make sure installed files have state (rhbz#492947)
- rpmfsSetState() doesn't get called for skipped files like %ghost and
%config(noreplace), causing incorrect file state ("no state") getting
recorded in rpmdb, leading to inapproriate removal/rename on erase, ick
- For TR_ADDED, always default file states to RPMFILE_STATE_NORMAL, fsm
changes it as necessary for skipped colors and such. Lazy alloc on
rpmfsSetState() is not correct as rpmfsSetState() might not get called
at all.
- originally broken by commit 8d6c4b8c95b59f5a71d90c582c2e98f5c7ed7b9d
(cherry picked from commit c40f6d5dcabfe0b68b830d96b01eaedac0b2d18d)
-rw-r--r-- | lib/fsm.c | 2 | ||||
-rw-r--r-- | lib/rpmte.c | 12 | ||||
-rw-r--r-- | lib/rpmte_internal.h | 2 |
3 files changed, 7 insertions, 9 deletions
@@ -663,8 +663,6 @@ static int fsmMapPath(FSM_t fsm) break; case FA_COPYIN: case FA_CREATE: - if (rpmteType(te) == TR_ADDED) - rpmfsSetState(fs, i, RPMFILE_STATE_NORMAL); break; case FA_SKIPNSTATE: diff --git a/lib/rpmte.c b/lib/rpmte.c index bda5411fc..284cdd755 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -286,7 +286,7 @@ static void addTE(rpmts ts, rpmte p, Header h, struct rpmtd_s bnames; headerGet(h, RPMTAG_BASENAMES, &bnames, HEADERGET_MINMEM); - p->fs = rpmfsNew(rpmtdCount(&bnames)); + p->fs = rpmfsNew(rpmtdCount(&bnames), p->type); rpmtdFreeData(&bnames); } @@ -912,11 +912,15 @@ rpmfs rpmteGetFileStates(rpmte te) { return te->fs; } -rpmfs rpmfsNew(unsigned int fc) { +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; @@ -974,10 +978,6 @@ sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced) 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; } diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h index 3ce411294..60c52bd67 100644 --- a/lib/rpmte_internal.h +++ b/lib/rpmte_internal.h @@ -81,7 +81,7 @@ int rpmteHaveTransScript(rpmte te, rpmTag tag); rpmfs rpmteGetFileStates(rpmte te); RPM_GNUC_INTERNAL -rpmfs rpmfsNew(unsigned int fc); +rpmfs rpmfsNew(unsigned int fc, rpmElementType type); RPM_GNUC_INTERNAL rpmfs rpmfsFree(rpmfs fs); |