depends.c: pass dbProvCache parameter down to dbSatisfiesDepend
This is a bit ugly but this is probably still a bit better than extending the ts structure.
This commit is contained in:
parent
945417c34f
commit
d35a165dc3
@ -9,6 +9,7 @@
|
||||
|
||||
#include "depends.h"
|
||||
#include "al.h"
|
||||
#include "rpmhash.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@ -477,6 +478,7 @@ rpmDependencyConflict rpmdepFreeConflicts(rpmDependencyConflict conflicts,
|
||||
/* Cached rpmdb provide lookup, returns 0 if satisfied, 1 otherwise */
|
||||
static
|
||||
int dbSatisfiesDepend(rpmTransactionSet ts,
|
||||
hashTable dbProvCache,
|
||||
const char * keyName, const char * keyEVR, int keyFlags)
|
||||
{
|
||||
rpmdbMatchIterator mi;
|
||||
@ -520,6 +522,7 @@ int dbSatisfiesDepend(rpmTransactionSet ts,
|
||||
* @return 0 if satisfied, 1 if not satisfied, 2 if error
|
||||
*/
|
||||
static int tsSatisfiesDepend(rpmTransactionSet ts,
|
||||
hashTable dbProvCache,
|
||||
const char * keyType, const char * keyDepend,
|
||||
const char * keyName, const char * keyEVR, int keyFlags)
|
||||
/*@modifies ts @*/
|
||||
@ -544,7 +547,7 @@ static int tsSatisfiesDepend(rpmTransactionSet ts,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dbSatisfiesDepend(ts, keyName, keyEVR, keyFlags) == 0) {
|
||||
if (dbSatisfiesDepend(ts, dbProvCache, keyName, keyEVR, keyFlags) == 0) {
|
||||
rpmMessage(RPMMESS_DEBUG, _("%s: %-45s YES (rpmdb provides)\n"),
|
||||
keyType, keyDepend+2);
|
||||
return 0;
|
||||
@ -564,6 +567,7 @@ unsatisfied:
|
||||
* @return 0 no problems found
|
||||
*/
|
||||
static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp,
|
||||
hashTable dbProvCache,
|
||||
Header h, const char * keyName)
|
||||
/*@modifies ts, h, psp */
|
||||
{
|
||||
@ -605,7 +609,7 @@ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp,
|
||||
keyDepend = printDepend("R",
|
||||
requires[i], requiresEVR[i], requireFlags[i]);
|
||||
|
||||
rc = tsSatisfiesDepend(ts, " Requires", keyDepend,
|
||||
rc = tsSatisfiesDepend(ts, dbProvCache, " Requires", keyDepend,
|
||||
requires[i], requiresEVR[i], requireFlags[i]);
|
||||
|
||||
switch (rc) {
|
||||
@ -663,7 +667,7 @@ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp,
|
||||
|
||||
keyDepend = printDepend("C", conflicts[i], conflictsEVR[i], conflictFlags[i]);
|
||||
|
||||
rc = tsSatisfiesDepend(ts, "Conflicts", keyDepend,
|
||||
rc = tsSatisfiesDepend(ts, dbProvCache, "Conflicts", keyDepend,
|
||||
conflicts[i], conflictsEVR[i], conflictFlags[i]);
|
||||
|
||||
/* 1 == unsatisfied, 0 == satsisfied */
|
||||
@ -714,6 +718,7 @@ static int checkPackageDeps(rpmTransactionSet ts, problemsSet psp,
|
||||
* @return 0 no problems found
|
||||
*/
|
||||
static int checkDependent(rpmTransactionSet ts, problemsSet psp,
|
||||
hashTable dbProvCache,
|
||||
rpmTag tag, const char * key)
|
||||
/*@modifies ts, psp @*/
|
||||
{
|
||||
@ -723,7 +728,7 @@ static int checkDependent(rpmTransactionSet ts, problemsSet psp,
|
||||
Header h;
|
||||
int rc = 0;
|
||||
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
||||
if (checkPackageDeps(ts, psp, h, key)) {
|
||||
if (checkPackageDeps(ts, psp, dbProvCache, h, key)) {
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
@ -749,6 +754,9 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
*conflicts = NULL;
|
||||
*numConflicts = 0;
|
||||
|
||||
/* XXX figure some kind of heuristic for the cache size */
|
||||
hashTable dbProvCache = htCreate(1024, hashFunctionString, hashEqualityString);
|
||||
|
||||
/*
|
||||
* Look at all of the added packages and make sure their dependencies
|
||||
* are satisfied.
|
||||
@ -759,12 +767,12 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
|
||||
rpmMessage(RPMMESS_DEBUG, "========== +++ %s-%s-%s\n" ,
|
||||
p->name, p->version, p->release);
|
||||
rc = checkPackageDeps(ts, ps, p->h, NULL);
|
||||
rc = checkPackageDeps(ts, ps, dbProvCache, p->h, NULL);
|
||||
if (rc)
|
||||
goto exit;
|
||||
|
||||
/* Adding: check name against conflicts matches. */
|
||||
rc = checkDependent(ts, ps, RPMTAG_CONFLICTNAME, p->name);
|
||||
rc = checkDependent(ts, ps, dbProvCache, RPMTAG_CONFLICTNAME, p->name);
|
||||
if (rc)
|
||||
goto exit;
|
||||
|
||||
@ -774,7 +782,7 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
rc = 0;
|
||||
for (j = 0; j < p->providesCount; j++) {
|
||||
/* Adding: check provides key against conflicts matches. */
|
||||
if (!checkDependent(ts, ps, RPMTAG_CONFLICTNAME, p->provides[j]))
|
||||
if (!checkDependent(ts, ps, dbProvCache, RPMTAG_CONFLICTNAME, p->provides[j]))
|
||||
continue;
|
||||
rc = 1;
|
||||
/*@innerbreak@*/ break;
|
||||
@ -797,7 +805,7 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
name, version, release);
|
||||
|
||||
/* Erasing: check name against requiredby matches. */
|
||||
rc = checkDependent(ts, ps, RPMTAG_REQUIRENAME, name);
|
||||
rc = checkDependent(ts, ps, dbProvCache, RPMTAG_REQUIRENAME, name);
|
||||
if (rc)
|
||||
goto exit;
|
||||
}
|
||||
@ -812,7 +820,7 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
rc = 0;
|
||||
for (j = 0; j < providesCount; j++) {
|
||||
/* Erasing: check provides against requiredby matches. */
|
||||
if (!checkDependent(ts, ps, RPMTAG_REQUIRENAME, provides[j]))
|
||||
if (!checkDependent(ts, ps, dbProvCache, RPMTAG_REQUIRENAME, provides[j]))
|
||||
continue;
|
||||
rc = 1;
|
||||
/*@innerbreak@*/ break;
|
||||
@ -847,7 +855,7 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
*fileName = '\0';
|
||||
(void) stpcpy( stpcpy(fileName, dirNames[dirIndexes[j]]) , baseNames[j]);
|
||||
/* Erasing: check filename against requiredby matches. */
|
||||
if (!checkDependent(ts, ps, RPMTAG_REQUIRENAME, fileName))
|
||||
if (!checkDependent(ts, ps, dbProvCache, RPMTAG_REQUIRENAME, fileName))
|
||||
continue;
|
||||
rc = 1;
|
||||
/*@innerbreak@*/ break;
|
||||
@ -872,5 +880,6 @@ int rpmdepCheck(rpmTransactionSet ts,
|
||||
exit:
|
||||
ps->problems = _free(ps->problems);
|
||||
ps = _free(ps);
|
||||
dbProvCache = htFree(dbProvCache, NULL, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user