The patch description already says it all... It's a bit hacky perhaps, but skipDir is even worse a hack, and breaks stuff in nasty ways especially on multilib systems.
Paul, it seems that this was at some point included in Fedora RPM, do you remember any details why it was removed?
- Panu - --- Allow an "exclude" parameter for rpmdbFindFp, specifying a header that is to be excluded in the match. Used to speed up package erase operations. Also fixes the skipDir problem that made rpm incorrectly delete files even if another package still references them. rh#140055 Index: lib/transaction.c =================================================================== --- lib/transaction.c.orig +++ lib/transaction.c @@ -1745,7 +1745,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing f (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0); /* Extract file info for all files in this package from the database. */ matches = xcalloc(fc, sizeof(*matches)); - if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) { + if (rpmdbFindFpListExclude(rpmtsGetRdb(ts), fi->fps, matches, fc, rpmteType(p) == TR_REMOVED ? fi->record : 0)) { ps = rpmpsFree(ps); rpmtsFreeLock(lock); return 1; /* XXX WTFO? */ Index: rpmdb/fprint.h =================================================================== --- rpmdb/fprint.h.orig +++ rpmdb/fprint.h @@ -79,6 +79,12 @@ int rpmdbFindFpList(/[EMAIL PROTECTED]@*/ rpmdb db, /[EMAIL PROTECTED] db, *matchList, rpmGlobalMacroContext, fileSystem, internalState @*/; +int rpmdbFindFpListExclude(/[EMAIL PROTECTED]@*/ rpmdb db, fingerPrint * fpList, + /[EMAIL PROTECTED]@*/ dbiIndexSet * matchList, int numItems, unsigned int exclude) + /[EMAIL PROTECTED] rpmGlobalMacroContext, fileSystem, internalState @*/ + /[EMAIL PROTECTED] db, *matchList, rpmGlobalMacroContext, + fileSystem, internalState @*/; + /* Be carefull with the memory... assert(*fullName == '/' || !scareMemory) */ /** Index: rpmdb/rpmdb.c =================================================================== --- rpmdb/rpmdb.c.orig +++ rpmdb/rpmdb.c @@ -2358,7 +2358,7 @@ static void rpmdbSortIterator(/[EMAIL PROTECTED]@*/ } /[EMAIL PROTECTED]@*/ /* LCL: segfault */ -static int rpmdbGrowIterator(/[EMAIL PROTECTED]@*/ rpmdbMatchIterator mi, int fpNum) +static int rpmdbGrowIterator(/[EMAIL PROTECTED]@*/ rpmdbMatchIterator mi, int fpNum, unsigned int exclude) /[EMAIL PROTECTED] rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /[EMAIL PROTECTED] mi, rpmGlobalMacroContext, fileSystem, internalState @*/ { @@ -2369,7 +2369,7 @@ static int rpmdbGrowIterator(/[EMAIL PROTECTED]@*/ dbiIndexSet set; int rc; int xx; - int i; + int i, j; if (mi == NULL) return 1; @@ -2405,6 +2405,25 @@ static int rpmdbGrowIterator(/[EMAIL PROTECTED]@*/ set = NULL; (void) dbt2set(dbi, data, &set); + + /* prune the set against exclude */ + for (i = j = 0; i < set->count; i++) { + if (exclude && set->recs[i].hdrNum == exclude) + continue; + if (i != j) + set->recs[j] = set->recs[i]; + j++; + } + if (j == 0) { +#ifdef SQLITE_HACK + xx = dbiCclose(dbi, dbcursor, 0); + dbcursor = NULL; +#endif + set = dbiFreeIndexSet(set); + return DB_NOTFOUND; + } + set->count = j; + for (i = 0; i < set->count; i++) set->recs[i].fpNum = fpNum; @@ -3393,6 +3412,12 @@ static int skipDir(const char * dn) int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, int numItems) { + return rpmdbFindFpListExclude(db, fpList, matchList, numItems, 0); +} + +int rpmdbFindFpListExclude(rpmdb db, fingerPrint * fpList, dbiIndexSet * matchList, + int numItems, unsigned int exclude) +{ DBT * key; DBT * data; HGE_t hge = (HGE_t)headerGetEntryMinMemory; @@ -3424,10 +3449,13 @@ key->data = (void *) fpList[i].baseName; key->size = strlen((char *)key->data); if (key->size == 0) key->size++; /* XXX "/" fixup. */ - if (skipDir(fpList[i].entry->dirName)) + /* HACK HACK HACK: don't skip dirs while removing + * packages as we will loose files on conflicts. + * exclude is not zero when removing */ + if (!exclude && skipDir(fpList[i].entry->dirName)) continue; - xx = rpmdbGrowIterator(mi, i); + xx = rpmdbGrowIterator(mi, i, exclude); } _______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org https://lists.rpm.org/mailman/listinfo/rpm-maint