diff options
author | Florian Festi <ffesti@redhat.com> | 2008-12-01 21:34:59 +0100 |
---|---|---|
committer | Florian Festi <ffesti@redhat.com> | 2008-12-10 13:40:53 +0100 |
commit | 8fa80b0f35574683beb19930264fa3b572c5ed24 (patch) | |
tree | aabf3312b5139dcef857a0315559fc97e8ad721b /lib/rpmte.c | |
parent | 196cc2ad71a6af90961ab62f9f32fc14f7c61878 (diff) | |
download | librpm-tizen-8fa80b0f35574683beb19930264fa3b572c5ed24.tar.gz librpm-tizen-8fa80b0f35574683beb19930264fa3b572c5ed24.tar.bz2 librpm-tizen-8fa80b0f35574683beb19930264fa3b572c5ed24.zip |
Create a new datastructure rpmfs aka File States that contains the information what to do with the files of an transaction element.
This patch moves rpmfi->replaced over to rpmfs. Move struct members to follow.
Diffstat (limited to 'lib/rpmte.c')
-rw-r--r-- | lib/rpmte.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/rpmte.c b/lib/rpmte.c index 2f50ff764..43782a423 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -60,6 +60,8 @@ static void delTE(rpmte p) p->NEVRA = _free(p->NEVRA); p->h = headerFree(p->h); + p->fs = rpmfsFree(p->fs); + memset(p, 0, sizeof(*p)); /* XXX trash and burn */ /* FIX: p->{NEVR,name} annotations */ @@ -142,6 +144,17 @@ static void addTE(rpmts ts, rpmte p, Header h, fiflags = (p->type == TR_ADDED) ? (RPMFI_NOHEADER | RPMFI_FLAGS_INSTALL) : (RPMFI_NOHEADER | RPMFI_FLAGS_ERASE); + + { + // get number of files by hand as rpmfiNew needs p->fs + struct rpmtd_s bnames; + headerGet(h, RPMTAG_BASENAMES, &bnames, HEADERGET_MINMEM); + + p->fs = rpmfsNew(rpmtdCount(&bnames)); + + rpmtdFreeData(&bnames); + } + savep = rpmtsSetRelocateElement(ts, p); p->fi = rpmfiNew(ts, h, RPMTAG_BASENAMES, fiflags); (void) rpmtsSetRelocateElement(ts, savep); @@ -193,6 +206,7 @@ rpmte rpmteNew(const rpmts ts, Header h, /* nothing to do */ break; } + return p; } @@ -732,3 +746,57 @@ int rpmteHaveTransScript(rpmte te, rpmTag tag) } return rc; } + +rpmfs rpmteGetFileStates(rpmte te) { + return te->fs; +} + +rpmfs rpmfsNew(unsigned int fc) { + rpmfs fs = xmalloc(sizeof(*fs)); + fs->fc = fc; + fs->replaced = NULL; + fs->numReplaced = fs->allocatedReplaced = 0; + return fs; +} + +rpmfs rpmfsFree(rpmfs fs) { + fs->replaced = _free(fs->replaced); + + fs = _free(fs); + return fs; +} + +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; +} |