From: Michael Schroeder Date: Tue, 6 May 2008 16:22:12 +0000 (+0000) Subject: - add pool_match_nevr() to match a single solvable's nevr against X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7dd7d799bcd9ea87dc11dc6d0a53035efb92df2;p=thirdparty%2Flibsolv.git - add pool_match_nevr() to match a single solvable's nevr against a dependency (that's also how rpm4 handles obsoletes). - use it for obsoetes and _NAME jobs --- diff --git a/src/policy.c b/src/policy.c index 3e397452..48b2f26c 100644 --- a/src/policy.c +++ b/src/policy.c @@ -22,16 +22,6 @@ #include "poolarch.h" -static inline Id dep2name(Pool *pool, Id dep) -{ - while (ISRELDEP(dep)) - { - Reldep *rd = rd = GETRELDEP(pool, dep); - dep = rd->name; - } - return dep; -} - static Solver *prune_best_version_arch_sortcmp_data; /*-----------------------------------------------------------------*/ @@ -258,12 +248,11 @@ prune_to_best_version(Solver *solv, Queue *plist) obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { if (pool->solvables[p].name == s->name) continue; - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; for (j = 0; j < plist->count; j++) { @@ -448,10 +437,9 @@ policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allowall) obsp = ps->repo->idarraydata + ps->obsoletes; while ((obs = *obsp++) != 0) /* for all obsoletes */ { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p2, pp2, obs) /* and all matching providers of the obsoletes */ { - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p2].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs)) continue; if (p2 == n) /* match ! */ break; diff --git a/src/pool.c b/src/pool.c index 13f985a6..613c9b01 100644 --- a/src/pool.c +++ b/src/pool.c @@ -403,6 +403,52 @@ pool_queuetowhatprovides(Pool *pool, Queue *q) /*************************************************************************/ +/* check if a package's nevr matches a dependency */ + +int +pool_match_nevr_rel(Pool *pool, Solvable *s, Id d) +{ + Reldep *rd = GETRELDEP(pool, d); + Id name = rd->name; + Id evr = rd->evr; + int flags = rd->flags; + + if (flags > 7) + { + switch (flags) + { + case REL_ARCH: + if (s->arch != evr) + return 0; + return pool_match_nevr(pool, s, name); + case REL_OR: + if (pool_match_nevr(pool, s, name)) + return 1; + return pool_match_nevr(pool, s, evr); + case REL_AND: + case REL_WITH: + if (!pool_match_nevr(pool, s, name)) + return 0; + return pool_match_nevr(pool, s, evr); + default: + return 0; + } + } + if (!pool_match_nevr(pool, s, name)) + return 0; + if (evr == s->evr) + return flags & 2 ? 1 : 0; + if (!flags) + return 0; + if (flags == 7) + return 1; + if (flags != 2 && flags != 5) + flags ^= 5; + if ((flags & (1 << (1 + evrcmp(pool, s->evr, evr, EVRCMP_MATCH_RELEASE)))) != 0) + return 1; + return 0; +} + /* * addrelproviders * diff --git a/src/pool.h b/src/pool.h index 1f9485e8..113347fb 100644 --- a/src/pool.h +++ b/src/pool.h @@ -183,6 +183,15 @@ int solvable_trivial_installable_queue(Solvable *s, Queue *installed); void pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap); +int pool_match_nevr_rel(Pool *pool, Solvable *s, Id d); + +static inline int pool_match_nevr(Pool *pool, Solvable *s, Id d) +{ + if (!ISRELDEP(d)) + return d == s->name; + else + return pool_match_nevr_rel(pool, s, d); +} /** diff --git a/src/solver.c b/src/solver.c index 08a7a5d6..afcdd592 100644 --- a/src/solver.c +++ b/src/solver.c @@ -35,16 +35,6 @@ * */ -static inline Id dep2name(Pool *pool, Id dep) -{ - while (ISRELDEP(dep)) - { - Reldep *rd = rd = GETRELDEP(pool, dep); - dep = rd->name; - } - return dep; -} - int solver_splitprovides(Solver *solv, Id dep) { @@ -744,7 +734,7 @@ disableupdaterules(Solver *solv, Queue *job, int jobidx) { Pool *pool = solv->pool; int i, j; - Id name, how, what, p, *pp; + Id how, what, p, *pp; Solvable *s; Repo *installed; Rule *r; @@ -800,15 +790,9 @@ disableupdaterules(Solver *solv, Queue *job, int jobidx) break; case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */ case SOLVER_ERASE_SOLVABLE_PROVIDES: - name = (how == SOLVER_ERASE_SOLVABLE_NAME) ? what : 0; - while (ISRELDEP(name)) - { - Reldep *rd = GETRELDEP(pool, name); - name = rd->name; - } FOR_PROVIDES(p, pp, what) { - if (name && pool->solvables[p].name != name) + if (how == SOLVER_ERASE_SOLVABLE_NAME && !pool_match_nevr(pool, pool->solvables + p, what)) continue; if (pool->solvables[p].repo == installed) MAPSET(&solv->noupdate, p - installed->start); @@ -867,16 +851,10 @@ disableupdaterules(Solver *solv, Queue *job, int jobidx) break; case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */ case SOLVER_ERASE_SOLVABLE_PROVIDES: - name = (how == SOLVER_ERASE_SOLVABLE_NAME) ? what : 0; - while (ISRELDEP(name)) - { - Reldep *rd = GETRELDEP(pool, name); - name = rd->name; - } FOR_PROVIDES(p, pp, what) { - if (name && pool->solvables[p].name != name) - continue; + if (how == SOLVER_ERASE_SOLVABLE_NAME && !pool_match_nevr(pool, pool->solvables + p, what)) + continue; if (pool->solvables[p].repo != installed) continue; if (MAPTST(&solv->noupdate, p - installed->start)) @@ -1125,10 +1103,9 @@ addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m) obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; addrule(solv, -n, -p); } @@ -2949,12 +2926,11 @@ solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { if (p != -r->w2) continue; - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; *depp = obs; *sourcep = -r->p; @@ -2968,12 +2944,11 @@ solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, obsp = s2->repo->idarraydata + s2->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { if (p != -r->p) continue; - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; *depp = obs; *sourcep = -r->w2; @@ -3149,14 +3124,13 @@ create_obsolete_index(Solver *solv) obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { if (pool->solvables[p].repo != installed) continue; if (pool->solvables[p].name == s->name) continue; - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; obsoletes[p - installed->start]++; } @@ -3181,14 +3155,13 @@ create_obsolete_index(Solver *solv) obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { if (pool->solvables[p].repo != installed) continue; if (pool->solvables[p].name == s->name) continue; - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; p -= installed->start; if (obsoletes_data[obsoletes[p]] != i) @@ -3327,7 +3300,7 @@ solver_solve(Solver *solv, Queue *job) int i; int oldnrules; Map addedmap; /* '1' == have rpm-rules for solvable */ - Id how, what, weak, name, p, *pp, d; + Id how, what, weak, p, *pp, d; Queue q, redoq; Solvable *s; int goterase; @@ -3391,16 +3364,10 @@ solver_solve(Solver *solv, Queue *job) break; case SOLVER_INSTALL_SOLVABLE_NAME: case SOLVER_INSTALL_SOLVABLE_PROVIDES: - name = (how == SOLVER_INSTALL_SOLVABLE_NAME) ? what : 0; - while (ISRELDEP(name)) - { - Reldep *rd = GETRELDEP(pool, name); - name = rd->name; - } FOR_PROVIDES(p, pp, what) { /* if by name, ensure that the name matches */ - if (name && pool->solvables[p].name != name) + if (how == SOLVER_INSTALL_SOLVABLE_NAME && !pool_match_nevr(pool, pool->solvables + p, what)) continue; addrpmrulesforsolvable(solv, pool->solvables + p, &addedmap); } @@ -3578,16 +3545,10 @@ solver_solve(Solver *solv, Queue *job) if (how == SOLVER_INSTALL_SOLVABLE_PROVIDES) POOL_DEBUG(SAT_DEBUG_JOB, "job: %sinstall provides %s\n", weak ? "weak " : "", dep2str(pool, what)); queue_empty(&q); - name = (how == SOLVER_INSTALL_SOLVABLE_NAME) ? what : 0; - while (ISRELDEP(name)) - { - Reldep *rd = GETRELDEP(pool, name); - name = rd->name; - } FOR_PROVIDES(p, pp, what) { /* if by name, ensure that the name matches */ - if (name && pool->solvables[p].name != name) + if (how == SOLVER_INSTALL_SOLVABLE_NAME && !pool_match_nevr(pool, pool->solvables + p, what)) continue; queue_push(&q, p); } @@ -3613,16 +3574,10 @@ solver_solve(Solver *solv, Queue *job) POOL_DEBUG(SAT_DEBUG_JOB, "job: %serase name %s\n", weak ? "weak " : "", dep2str(pool, what)); if (how == SOLVER_ERASE_SOLVABLE_PROVIDES) POOL_DEBUG(SAT_DEBUG_JOB, "job: %serase provides %s\n", weak ? "weak " : "", dep2str(pool, what)); - name = (how == SOLVER_ERASE_SOLVABLE_NAME) ? what : 0; - while (ISRELDEP(name)) - { - Reldep *rd = GETRELDEP(pool, name); - name = rd->name; - } FOR_PROVIDES(p, pp, what) { /* if by name, ensure that the name matches */ - if (name && pool->solvables[p].name != name) + if (how == SOLVER_ERASE_SOLVABLE_NAME && !pool_match_nevr(pool, pool->solvables + p, what)) continue; addrule(solv, -p, 0); /* add 'remove' rule */ queue_push(&solv->ruletojob, i); diff --git a/src/solverdebug.c b/src/solverdebug.c index 24acd4fa..3c9ec41f 100644 --- a/src/solverdebug.c +++ b/src/solverdebug.c @@ -36,16 +36,6 @@ * */ -static inline Id dep2name(Pool *pool, Id dep) -{ - while (ISRELDEP(dep)) - { - Reldep *rd = rd = GETRELDEP(pool, dep); - dep = rd->name; - } - return dep; -} - Id * solver_create_decisions_obsoletesmap(Solver *solv) { @@ -99,10 +89,9 @@ solver_create_decisions_obsoletesmap(Solver *solv) obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { - Id obsname = dep2name(pool, obs); FOR_PROVIDES(p, pp, obs) { - if (!solv->obsoleteusesprovides && obsname != pool->solvables[p].name) + if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs)) continue; if (pool->solvables[p].repo == installed && !obsoletesmap[p]) {