2006-12-19 00:17:44 +01:00
|
|
|
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
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -1758,7 +1758,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing f
|
2006-12-19 00:17:44 +01:00
|
|
|
(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(/*@null@*/ rpmdb db,
|
|
|
|
/*@modifies db, *matchList, rpmGlobalMacroContext,
|
|
|
|
fileSystem, internalState @*/;
|
|
|
|
|
|
|
|
+int rpmdbFindFpListExclude(/*@null@*/ rpmdb db, fingerPrint * fpList,
|
|
|
|
+ /*@out@*/ dbiIndexSet * matchList, int numItems, unsigned int exclude)
|
|
|
|
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
+ /*@modifies db, *matchList, rpmGlobalMacroContext,
|
|
|
|
+ fileSystem, internalState @*/;
|
|
|
|
+
|
|
|
|
/* Be carefull with the memory... assert(*fullName == '/' || !scareMemory) */
|
|
|
|
|
|
|
|
/**
|
|
|
|
Index: rpmdb/rpmdb.c
|
|
|
|
===================================================================
|
|
|
|
--- rpmdb/rpmdb.c.orig
|
|
|
|
+++ rpmdb/rpmdb.c
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -2390,7 +2390,7 @@ static void rpmdbSortIterator(/*@null@*/
|
2006-12-19 00:17:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*@-bounds@*/ /* LCL: segfault */
|
|
|
|
-static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, int fpNum)
|
|
|
|
+static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, int fpNum, unsigned int exclude)
|
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
|
|
|
/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
{
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -2401,7 +2401,7 @@ static int rpmdbGrowIterator(/*@null@*/
|
2006-12-19 00:17:44 +01:00
|
|
|
dbiIndexSet set;
|
|
|
|
int rc;
|
|
|
|
int xx;
|
|
|
|
- int i;
|
|
|
|
+ int i, j;
|
|
|
|
|
|
|
|
if (mi == NULL)
|
|
|
|
return 1;
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -2437,6 +2437,25 @@ static int rpmdbGrowIterator(/*@null@*/
|
2006-12-19 00:17:44 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -3412,6 +3431,12 @@ static int skipDir(const char * dn)
|
2006-12-19 00:17:44 +01:00
|
|
|
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;
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -3443,10 +3468,13 @@ key->data = (void *) fpList[i].baseName;
|
2006-12-19 00:17:44 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|