RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Dec-2009 21:24:46 Branch: HEAD Handle: 2009121420244401 Modified files: rpm CHANGES rpm/lib rpmfi.c rpmfi.h transaction.c rpm/rpmdb fprint.c Log: - rpm.org: port addFingerprints. Summary: Revision Changes Path 1.3201 +1 -0 rpm/CHANGES 2.153 +20 -0 rpm/lib/rpmfi.c 2.78 +16 -3 rpm/lib/rpmfi.h 1.412 +99 -5 rpm/lib/transaction.c 1.33 +1 -2 rpm/rpmdb/fprint.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3200 -r1.3201 CHANGES --- rpm/CHANGES 14 Dec 2009 18:19:22 -0000 1.3200 +++ rpm/CHANGES 14 Dec 2009 20:24:44 -0000 1.3201 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 + - rpm.org: port addFingerprints. - rpm.org: port a copy of fpLookupSubdir. - jbj: rpmdb: Stub-in RPMDBI_REPACKAGES/RPMDBI_REPOSITORY stores. - jbj: rpmdb: Eliminate RPMDBI_LABEL. Use RPMTAG_NVRA instead. @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.c ============================================================================ $ cvs diff -u -r2.152 -r2.153 rpmfi.c --- rpm/lib/rpmfi.c 10 Dec 2009 18:52:18 -0000 2.152 +++ rpm/lib/rpmfi.c 14 Dec 2009 20:24:45 -0000 2.153 @@ -20,6 +20,9 @@ #include <rpmtypes.h> #include <rpmtag.h> +#define _FPRINT_INTERNAL +#include "fprint.h" + #define _IOSM_INTERNAL #define _RPMFI_INTERNAL #include "fsm.h" /* XXX newFSM() */ @@ -459,6 +462,23 @@ return (fi != NULL ? fi->ninclude : 0); } +struct fingerPrint_s * rpmfiFpsIndex(rpmfi fi, int ix) +{ + struct fingerPrint_s * fps = NULL; + if (fi != NULL && fi->fps != NULL && ix >= 0 && ix < (int)fi->fc) { + fps = fi->fps + ix; + } + return fps; +} + +void rpmfiFpLookup(rpmfi fi, fingerPrintCache fpc) +{ + if (fi->fc > 0 && fi->fps == NULL) { + fi->fps = xcalloc(fi->fc, sizeof(*fi->fps)); + } + fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps); +} + int rpmfiNext(rpmfi fi) { int i = -1; @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.h ============================================================================ $ cvs diff -u -r2.77 -r2.78 rpmfi.h --- rpm/lib/rpmfi.h 14 Dec 2009 18:19:23 -0000 2.77 +++ rpm/lib/rpmfi.h 14 Dec 2009 20:24:45 -0000 2.78 @@ -189,9 +189,6 @@ /*...@unused@*/ rpmuint32_t * odil; /*!< Original dirindex(s) (from header) */ -/*...@only@*/ /*...@null@*/ - void * _fps; /*!< File fingerprint(s). */ - /*...@only@*/ /*...@relnull@*/ unsigned char * digests; /*!< File digest(s) in binary. */ rpmuint32_t digestalgo; /*!< File digest algorithm. */ @@ -595,6 +592,22 @@ int rpmfiNInclude(/*...@null@*/ const rpmfi fi) /*...@*/; +#if defined(_RPMFI_INTERNAL) +#include "fprint.h" +/** + * Return fingerprint from file info set. + * @param fi file info set + * @param ix + * @return fingerprint, NULL on invalid + */ +/*...@null@*/ +struct fingerPrint_s * rpmfiFpsIndex(rpmfi fi, int ix) + /*...@*/; + +void rpmfiFpLookup(rpmfi fi, fingerPrintCache fpc) + /*...@*/; +#endif + /** * Return next file iterator index. * @param fi file info set @@ . patch -p0 <<'@@ .' Index: rpm/lib/transaction.c ============================================================================ $ cvs diff -u -r1.411 -r1.412 transaction.c --- rpm/lib/transaction.c 11 Dec 2009 02:59:06 -0000 1.411 +++ rpm/lib/transaction.c 14 Dec 2009 20:24:45 -0000 1.412 @@ -924,6 +924,93 @@ /*...@=compdef =refcounttrans =usereleased @*/ } +/* ================================================================= */ + +/* Add fingerprint for each file not skipped. */ +static void addFingerprints(rpmts ts, uint32_t fileCount, hashTable ht, + fingerPrintCache fpc) +{ + rpmtsi pi; + rpmte p; + rpmfi fi; + int i; + +#ifdef REFERENCE + hashTable symlinks = htCreate(fileCount/16+16, 0, 0, fpHashFunction, fpEqual); +#endif + + pi = rpmtsiInit(ts); + while ((p = rpmtsiNext(pi, 0)) != NULL) { + (void) rpmdbCheckSignals(); + + if (p->isSource) continue; + if ((fi = rpmtsiFi(pi)) == NULL) + continue; /* XXX can't happen */ + + (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); + + rpmfiFpLookup(fi, fpc); + + /* Collect symlinks. */ + fi = rpmfiInit(fi, 0); + if (fi != NULL) /* XXX lclint */ + while ((i = rpmfiNext(fi)) >= 0) { +#ifdef REFERENCE + char const *linktarget; + linktarget = rpmfiFLink(fi); + if (!(linktarget && *linktarget != '\0')) + continue; +#endif + if (iosmFileActionSkipped(fi->actions[i])) + /*...@innercontinue@*/ continue; +#ifdef REFERENCE + { struct rpmffi_s ffi; + ffi.p = p; + ffi.fileno = i; + htAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi); + } +#else + /*...@-dependenttrans@*/ + htAddEntry(ts->ht, fi->fps + i, (void *) fi); + /*...@=dependenttrans@*/ +#endif + } + + (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), rpmfiFC(fi)); + + } + pi = rpmtsiFree(pi); + +#ifdef REFERENCE + /* =============================================== + * Check fingerprints if they contain symlinks + * and add them to the hash table + */ + + pi = rpmtsiInit(ts); + while ((p = rpmtsiNext(pi, 0)) != NULL) { + (void) rpmdbCheckSignals(); + + if ((fi = rpmteFI(p)) == NULL) + continue; /* XXX can't happen */ + fi = rpmfiInit(fi, 0); + (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); + while ((i = rpmfiNext(fi)) >= 0) { + if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i))) + continue; + fpLookupSubdir(symlinks, ht, fpc, p, i); + } + (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); + } + pi = rpmtsiFree(pi); + + symlinks = htFree(symlinks); +#endif + +} + +/* ================================================================= */ + /** * Force add a failed package into the rpmdb. * @param ts current transaction set @@ -1387,6 +1474,7 @@ /* Get available space on mounted file systems. */ xx = rpmtsInitDSI(ts); + totalFileCount = 0; /* =============================================== * For packages being installed: * - verify package epoch:version-release is newer. @@ -1620,9 +1708,12 @@ ts->ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual); fpc = fpCacheCreate(totalFileCount); + ptr = rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount); + /* =============================================== * Add fingerprint for each file not skipped. */ +#ifdef DYING pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, 0)) != NULL) { int fc; @@ -1649,8 +1740,9 @@ } pi = rpmtsiFree(pi); - - ptr = rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount); +#else + addFingerprints(ts, totalFileCount, ts->ht, fpc); +#endif /* =============================================== * Compute file disposition for each package in transaction set. @@ -1904,13 +1996,14 @@ 7, numRemoved); } - /* =============================================== - * Install and remove packages. - */ #ifdef NOTYET xx = rpmtxnBegin(rpmtsGetRdb(ts), NULL, &ts->txn); #endif + /* =============================================== + * Install and remove packages. + */ + /*...@-nullpass@*/ pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, 0)) != NULL) { @@ -2162,6 +2255,7 @@ } lock = rpmtsFreeLock(lock); + if (sx != NULL) sx = rpmsxFree(sx); /*...@-nullstate@*/ /* FIX: ts->flList may be NULL */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/fprint.c ============================================================================ $ cvs diff -u -r1.32 -r1.33 fprint.c --- rpm/rpmdb/fprint.c 14 Dec 2009 18:19:23 -0000 1.32 +++ rpm/rpmdb/fprint.c 14 Dec 2009 20:24:45 -0000 1.33 @@ -300,8 +300,7 @@ { struct fingerPrint_s * fps = NULL; if (fi != NULL && fi->fps != NULL && ix >= 0 && ix < (int)fi->fc) { - struct fingerPrint_s * fi_fps = fi->_fps; - fps = fi_fps + ix; + fps = fi->fps + ix; } return fps; } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org