Accepting request 18841 from Base:System
Copy from Base:System/rpm based on submit request 18841 from user mlschroe OBS-URL: https://build.opensuse.org/request/show/18841 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=84
This commit is contained in:
committed by
Git OBS Bridge
parent
bd5319d2fe
commit
25f00b6cb5
@@ -1,12 +1,12 @@
|
||||
The taggedfileindex patch. Speeds up database searches, but breaks
|
||||
fingerprint semantics. Needs findfplistexclude.diff.
|
||||
fingerprint semantics.
|
||||
rh#103204
|
||||
|
||||
Index: rpmdb/rpmdb.c
|
||||
Index: lib/rpmdb.c
|
||||
===================================================================
|
||||
--- rpmdb/rpmdb.c.orig
|
||||
+++ rpmdb/rpmdb.c
|
||||
@@ -1215,6 +1215,16 @@ int rpmdbVerify(const char * prefix)
|
||||
--- lib/rpmdb.c.orig
|
||||
+++ lib/rpmdb.c
|
||||
@@ -1107,6 +1107,16 @@ int rpmdbVerify(const char * prefix)
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ Index: rpmdb/rpmdb.c
|
||||
/**
|
||||
* Find file matches in database.
|
||||
* @param db rpm database
|
||||
@@ -1294,6 +1304,11 @@ if (key->size == 0) key->size++; /* XXX
|
||||
if (rc == 0)
|
||||
(void) dbt2set(dbi, data, &allMatches);
|
||||
@@ -1169,6 +1179,11 @@ static int rpmdbFindByFile(rpmdb db, con
|
||||
if (rc == 0)
|
||||
(void) dbt2set(dbi, data, &allMatches);
|
||||
|
||||
+ /* strip off directory tags */
|
||||
+ if (allMatches != NULL)
|
||||
@@ -35,85 +35,153 @@ Index: rpmdb/rpmdb.c
|
||||
xx = dbiCclose(dbi, dbcursor, 0);
|
||||
dbcursor = NULL;
|
||||
} else
|
||||
@@ -2411,7 +2426,7 @@ static void rpmdbSortIterator(/*@null@*/
|
||||
@@ -2172,7 +2187,7 @@ void rpmdbSortIterator(rpmdbMatchIterato
|
||||
}
|
||||
|
||||
/*@-bounds@*/ /* LCL: segfault */
|
||||
-static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, int fpNum, unsigned int exclude)
|
||||
+static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, int fpNum, unsigned int exclude, unsigned int tag)
|
||||
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
||||
/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/
|
||||
/* LCL: segfault */
|
||||
-static int rpmdbGrowIterator(rpmdbMatchIterator mi)
|
||||
+static int rpmdbGrowIterator(rpmdbMatchIterator mi, unsigned int tag)
|
||||
{
|
||||
@@ -2459,10 +2474,16 @@ static int rpmdbGrowIterator(/*@null@*/
|
||||
set = NULL;
|
||||
(void) dbt2set(dbi, data, &set);
|
||||
DBC * dbcursor;
|
||||
DBT * key;
|
||||
@@ -2222,6 +2237,27 @@ static int rpmdbGrowIterator(rpmdbMatchI
|
||||
dbcursor = NULL;
|
||||
#endif
|
||||
|
||||
- /* prune the set against exclude */
|
||||
+ /* prune the set against exclude and tag */
|
||||
for (i = j = 0; i < set->count; i++) {
|
||||
if (exclude && set->recs[i].hdrNum == exclude)
|
||||
continue;
|
||||
+ if (set->recs[i].tagNum & 0x80000000) {
|
||||
+ /* tagged entry */
|
||||
+ if ((set->recs[i].tagNum & 0xffff0000) != tag)
|
||||
+ continue;
|
||||
+ set->recs[i].tagNum &= 0x0000ffff;
|
||||
+ if (tag) {
|
||||
+ int i, j;
|
||||
+ /* prune the set against the tag */
|
||||
+ for (i = j = 0; i < set->count; i++) {
|
||||
+ if (set->recs[i].tagNum & 0x80000000) {
|
||||
+ /* tagged entry */
|
||||
+ if ((set->recs[i].tagNum & 0xffff0000) != tag)
|
||||
+ continue;
|
||||
+ set->recs[i].tagNum &= 0x0000ffff;
|
||||
+ }
|
||||
+ if (i != j)
|
||||
+ set->recs[j] = set->recs[i];
|
||||
+ j++;
|
||||
+ }
|
||||
if (i != j)
|
||||
set->recs[j] = set->recs[i];
|
||||
j++;
|
||||
@@ -2987,7 +3008,9 @@ DBT * data = alloca(sizeof(*data));
|
||||
HFD_t hfd = headerFreeData;
|
||||
sigset_t signalMask;
|
||||
const char ** baseNames;
|
||||
- rpmTagType bnt;
|
||||
+ const char ** dirNames;
|
||||
+ int_32 * dirIndexes, *dirs;
|
||||
+ rpmTagType bnt, dit, dnt;
|
||||
int count = 0;
|
||||
dbiIndex dbi;
|
||||
int dbix;
|
||||
@@ -3027,6 +3050,13 @@ memset(data, 0, sizeof(*data));
|
||||
*/
|
||||
|
||||
xx = hge(h, RPMTAG_BASENAMES, &bnt, (void **) &baseNames, &count);
|
||||
+ xx = hge(h, RPMTAG_DIRINDEXES, &dit, (void **) &dirIndexes, NULL);
|
||||
+ xx = hge(h, RPMTAG_DIRNAMES, &dnt, (void **) &dirNames, NULL);
|
||||
+ set->count = j;
|
||||
+ if (j == 0) {
|
||||
+ set = dbiFreeIndexSet(set);
|
||||
+ return DB_NOTFOUND;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* save dirIndexes, because expandFilelist may free it */
|
||||
+ dirs = alloca(count * sizeof(*dirs));
|
||||
+ for (xx = 0; xx < count; xx++)
|
||||
+ dirs[xx] = dirIndexes[xx];
|
||||
if (mi->mi_set == NULL) {
|
||||
mi->mi_set = set;
|
||||
} else {
|
||||
@@ -2403,7 +2439,15 @@ int rpmdbExtendIterator(rpmdbMatchIterat
|
||||
{
|
||||
mi->mi_key.data = (void *) keyp;
|
||||
mi->mi_key.size = keylen ? keylen : strlen(keyp);
|
||||
- return rpmdbGrowIterator(mi);
|
||||
+ return rpmdbGrowIterator(mi, 0);
|
||||
+}
|
||||
+
|
||||
+int rpmdbExtendIteratorDirtag(rpmdbMatchIterator mi,
|
||||
+ const void * keyp, size_t keylen, const char *dirname)
|
||||
+{
|
||||
+ mi->mi_key.data = (void *) keyp;
|
||||
+ mi->mi_key.size = keylen ? keylen : strlen(keyp);
|
||||
+ return rpmdbGrowIterator(mi, dirname ? taghash(dirname) : 0);
|
||||
}
|
||||
|
||||
if (_noDirTokens)
|
||||
expandFilelist(h);
|
||||
@@ -3240,6 +3270,11 @@ data->size = 0;
|
||||
/*
|
||||
@@ -2798,8 +2842,16 @@ int rpmdbAdd(rpmdb db, int iid, Header h
|
||||
|
||||
if (hdrNum)
|
||||
{
|
||||
+ struct rpmtd_s dn, di;
|
||||
+ const char ** dirNames;
|
||||
+ uint32_t * dirIndexes;
|
||||
dbiIndexItem rec = dbiIndexNewItem(hdrNum, 0);
|
||||
|
||||
+ headerGet(h, RPMTAG_DIRNAMES, &dn, HEADERGET_MINMEM);
|
||||
+ headerGet(h, RPMTAG_DIRINDEXES, &di, HEADERGET_MINMEM);
|
||||
+ dirNames = dn.data;
|
||||
+ dirIndexes = di.data;
|
||||
+
|
||||
if (dbiTags.tags != NULL)
|
||||
for (dbix = 0; dbix < dbiTags.max; dbix++) {
|
||||
rpmTag rpmtag;
|
||||
@@ -2891,6 +2943,10 @@ int rpmdbAdd(rpmdb db, int iid, Header h
|
||||
*/
|
||||
rec->tagNum = i;
|
||||
switch (dbi->dbi_rpmtag) {
|
||||
i = rec->tagNum = rpmtdGetIndex(&tagdata);
|
||||
switch (rpmtag) {
|
||||
+ case RPMTAG_BASENAMES:
|
||||
+ /* tag index entry with directory hash */
|
||||
+ if (i < 0x010000)
|
||||
+ rec->tagNum |= taghash(dirNames[dirs[i]]);
|
||||
+ /*@switchbreak@*/ break;
|
||||
case RPMTAG_PUBKEYS:
|
||||
/*@switchbreak@*/ break;
|
||||
case RPMTAG_FILEMD5S:
|
||||
@@ -3414,6 +3449,8 @@ if (key->size == 0) key->size++; /* XXX
|
||||
+ rec->tagNum |= taghash(dirNames[dirIndexes[i]]);
|
||||
+ break;
|
||||
case RPMTAG_REQUIRENAME: {
|
||||
/* Filter out install prerequisites. */
|
||||
rpm_flag_t *rflag = rpmtdNextUint32(&reqflags);
|
||||
@@ -2976,6 +3032,9 @@ cont:
|
||||
if (ret == 0) {
|
||||
headerSetInstance(h, hdrNum);
|
||||
}
|
||||
+
|
||||
+ rpmtdFreeData(&dn);
|
||||
+ rpmtdFreeData(&di);
|
||||
}
|
||||
|
||||
exit:
|
||||
+ dirIndexes = hfd(dirIndexes, dit);
|
||||
+ dirNames = hfd(dirNames, dnt);
|
||||
(void) unblockSignals(db, &signalMask);
|
||||
Index: lib/rpmdb_internal.h
|
||||
===================================================================
|
||||
--- lib/rpmdb_internal.h.orig
|
||||
+++ lib/rpmdb_internal.h
|
||||
@@ -540,6 +540,9 @@ unsigned int dbiIndexRecordFileNumber(db
|
||||
int rpmdbExtendIterator(rpmdbMatchIterator mi,
|
||||
const void * keyp, size_t keylen);
|
||||
|
||||
return ret;
|
||||
@@ -3495,7 +3532,7 @@ if (key->size == 0) key->size++; /* XXX
|
||||
if (!exclude && skipDir(fpList[i].entry->dirName))
|
||||
continue;
|
||||
+int rpmdbExtendIteratorDirtag(rpmdbMatchIterator mi,
|
||||
+ const void * keyp, size_t keylen, const char *);
|
||||
+
|
||||
/** \ingroup rpmdb
|
||||
* sort the iterator by (recnum, filenum)
|
||||
* Return database iterator.
|
||||
Index: lib/transaction.c
|
||||
===================================================================
|
||||
--- lib/transaction.c.orig
|
||||
+++ lib/transaction.c
|
||||
@@ -609,9 +609,12 @@ rpmdbMatchIterator rpmFindBaseNamesInDB(
|
||||
rpmdbMatchIterator mi;
|
||||
int i, xx;
|
||||
const char * baseName;
|
||||
+ const char * dirName;
|
||||
|
||||
- xx = rpmdbGrowIterator(mi, i, exclude);
|
||||
+ xx = rpmdbGrowIterator(mi, i, exclude, taghash(fpList[i].entry->dirName));
|
||||
+#if 0
|
||||
rpmStringSet baseNames = rpmStringSetCreate(fileCount,
|
||||
hashFunctionString, strcmp, NULL);
|
||||
+#endif
|
||||
|
||||
mi = rpmdbInitIterator(rpmtsGetRdb(ts), RPMTAG_BASENAMES, NULL, 0);
|
||||
|
||||
@@ -629,18 +632,25 @@ rpmdbMatchIterator rpmFindBaseNamesInDB(
|
||||
while ((i = rpmfiNext(fi)) >= 0) {
|
||||
size_t keylen;
|
||||
baseName = rpmfiBN(fi);
|
||||
+ dirName = rpmfiDN(fi);
|
||||
+#if 0
|
||||
if (rpmStringSetHasEntry(baseNames, baseName))
|
||||
continue;
|
||||
+#endif
|
||||
|
||||
keylen = strlen(baseName);
|
||||
if (keylen == 0)
|
||||
keylen++; /* XXX "/" fixup. */
|
||||
- xx = rpmdbExtendIterator(mi, baseName, keylen);
|
||||
+ xx = rpmdbExtendIteratorDirtag(mi, baseName, keylen, dirName);
|
||||
+#if 0
|
||||
rpmStringSetAddEntry(baseNames, baseName);
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
pi = rpmtsiFree(pi);
|
||||
+#if 0
|
||||
rpmStringSetFree(baseNames);
|
||||
+#endif
|
||||
|
||||
rpmdbSortIterator(mi);
|
||||
/* iterator is now sorted by (recnum, filenum) */
|
||||
|
Reference in New Issue
Block a user