-/* a problem is an item on the solver's problem list. It can either be >0, in that
- * case it is a update rule, or it can be <0, which makes it refer to a job
- * consisting of multiple job rules.
- */
-
-static void
-disableproblem(Solver *solv, Id v)
-{
- Rule *r;
- int i;
- Id *jp;
-
- if (v > 0)
- {
- disablerule(solv, solv->rules + v);
- return;
- }
- v = -(v + 1);
- jp = solv->ruletojob.elements;
- for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
- if (*jp == v)
- disablerule(solv, r);
-}
-
-/*-------------------------------------------------------------------
- * enableproblem
- */
-
-static void
-enableproblem(Solver *solv, Id v)
-{
- Rule *r;
- int i;
- Id *jp;
-
- if (v > 0)
- {
- if (v >= solv->featurerules && v < solv->featurerules_end)
- {
- /* do not enable feature rule if update rule is enabled */
- r = solv->rules + (v - solv->featurerules + solv->updaterules);
- if (r->d >= 0)
- return;
- }
- enablerule(solv, solv->rules + v);
- if (v >= solv->updaterules && v < solv->updaterules_end)
- {
- /* disable feature rule when enabling update rule */
- r = solv->rules + (v - solv->updaterules + solv->featurerules);
- if (r->p)
- disablerule(solv, r);
- }
- return;
- }
- v = -(v + 1);
- jp = solv->ruletojob.elements;
- for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
- if (*jp == v)
- enablerule(solv, r);
-}
-
-
-/************************************************************************/
-
-/*
- * make assertion rules into decisions
- *
- * go through update and job rules and add direct assertions
- * to the decisionqueue. If we find a conflict, disable rules and
- * add them to problem queue.
- */
-
-static void
-makeruledecisions(Solver *solv)
-{
- Pool *pool = solv->pool;
- int i, ri, ii;
- Rule *r, *rr;
- Id v, vv;
- int decisionstart;
-
- POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions ; size decisionq: %d -----\n",solv->decisionq.count);
-
- decisionstart = solv->decisionq.count;
- for (ii = 0; ii < solv->ruleassertions.count; ii++)
- {
- ri = solv->ruleassertions.elements[ii];
- r = solv->rules + ri;
-
- if (r->d < 0 || !r->p || r->w2) /* disabled, dummy or no assertion */
- continue;
- /* do weak rules in phase 2 */
- if (ri < solv->learntrules && MAPTST(&solv->weakrulemap, ri))
- continue;
-
- v = r->p;
- vv = v > 0 ? v : -v;
-
- if (!solv->decisionmap[vv]) /* if not yet decided */
- {
- /*
- * decide !
- */
- queue_push(&solv->decisionq, v);
- queue_push(&solv->decisionq_why, r - solv->rules);
- solv->decisionmap[vv] = v > 0 ? 1 : -1;
- IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
- {
- Solvable *s = solv->pool->solvables + vv;
- if (v < 0)
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, "conflicting %s (assertion)\n", solvable2str(solv->pool, s));
- else
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, "installing %s (assertion)\n", solvable2str(solv->pool, s));
- }
- continue;
- }
- /*
- * check previous decision: is it sane ?
- */
-
- if (v > 0 && solv->decisionmap[vv] > 0) /* ok to install */
- continue;
- if (v < 0 && solv->decisionmap[vv] < 0) /* ok to remove */
- continue;
-
- /*
- * found a conflict!
- *
- * The rule (r) we're currently processing says something
- * different (v = r->p) than a previous decision (decisionmap[abs(v)])
- * on this literal
- */
-
- if (ri >= solv->learntrules)
- {
- /* conflict with a learnt rule */
- /* can happen when packages cannot be installed for
- * multiple reasons. */
- /* we disable the learnt rule in this case */
- disablerule(solv, r);
- continue;
- }
-
- /*
- * find the decision which is the "opposite" of the rule
- */
-
- for (i = 0; i < solv->decisionq.count; i++)
- if (solv->decisionq.elements[i] == -v)
- break;
- assert(i < solv->decisionq.count); /* assert that we found it */
-
- /*
- * conflict with system solvable ?
- */
-
- if (v == -SYSTEMSOLVABLE) {
- /* conflict with system solvable */
- queue_push(&solv->problems, solv->learnt_pool.count);
- queue_push(&solv->learnt_pool, ri);
- queue_push(&solv->learnt_pool, 0);
- POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflict with system solvable, disabling rule #%d\n", ri);
- if (ri >= solv->jobrules && ri < solv->jobrules_end)
- v = -(solv->ruletojob.elements[ri - solv->jobrules] + 1);
- else
- v = ri;
- queue_push(&solv->problems, v);
- queue_push(&solv->problems, 0);
- disableproblem(solv, v);
- continue;
- }
-
- assert(solv->decisionq_why.elements[i]);
-
- /*
- * conflict with an rpm rule ?
- */
-
- if (solv->decisionq_why.elements[i] < solv->rpmrules_end)
- {
- /* conflict with rpm rule assertion */
- queue_push(&solv->problems, solv->learnt_pool.count);
- queue_push(&solv->learnt_pool, ri);
- queue_push(&solv->learnt_pool, solv->decisionq_why.elements[i]);
- queue_push(&solv->learnt_pool, 0);
- assert(v > 0 || v == -SYSTEMSOLVABLE);
- POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflict with rpm rule, disabling rule #%d\n", ri);
- if (ri >= solv->jobrules && ri < solv->jobrules_end)
- v = -(solv->ruletojob.elements[ri - solv->jobrules] + 1);
- else
- v = ri;
- queue_push(&solv->problems, v);
- queue_push(&solv->problems, 0);
- disableproblem(solv, v);
- continue;
- }
-
- /*
- * conflict with another job or update/feature rule
- */
-
- /* record proof */
- queue_push(&solv->problems, solv->learnt_pool.count);
- queue_push(&solv->learnt_pool, ri);
- queue_push(&solv->learnt_pool, solv->decisionq_why.elements[i]);
- queue_push(&solv->learnt_pool, 0);
-
- POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflicting update/job assertions over literal %d\n", vv);
-
- /*
- * push all of our rules (can only be feature or job rules)
- * asserting this literal on the problem stack
- */
-
- for (i = solv->featurerules, rr = solv->rules + i; i < solv->learntrules; i++, rr++)
- {
- if (rr->d < 0 /* disabled */
- || rr->w2) /* or no assertion */
- continue;
- if (rr->p != vv /* not affecting the literal */
- && rr->p != -vv)
- continue;
- if (MAPTST(&solv->weakrulemap, i)) /* weak: silently ignore */
- continue;
-
- POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, " - disabling rule #%d\n", i);
-
- solver_printruleclass(solv, SAT_DEBUG_UNSOLVABLE, solv->rules + i);
-
- v = i;
- /* is is a job rule ? */
- if (i >= solv->jobrules && i < solv->jobrules_end)
- v = -(solv->ruletojob.elements[i - solv->jobrules] + 1);
-
- queue_push(&solv->problems, v);
- disableproblem(solv, v);
- }
- queue_push(&solv->problems, 0);
-
- /*
- * start over
- * (back up from decisions)
- */
- while (solv->decisionq.count > decisionstart)
- {
- v = solv->decisionq.elements[--solv->decisionq.count];
- --solv->decisionq_why.count;
- vv = v > 0 ? v : -v;
- solv->decisionmap[vv] = 0;
- }
- ii = -1; /* restarts loop at 0 */
- }
-
- /*
- * phase 2: now do the weak assertions
- */
- for (ii = 0; ii < solv->ruleassertions.count; ii++)
- {
- ri = solv->ruleassertions.elements[ii];
- r = solv->rules + ri;
- if (r->d < 0 || r->w2) /* disabled or no assertion */
- continue;
- if (!MAPTST(&solv->weakrulemap, ri)) /* skip non-weak */
- continue;
- v = r->p;
- vv = v > 0 ? v : -v;
- /*
- * decide !
- * (if not yet decided)
- */
- if (!solv->decisionmap[vv])
- {
- queue_push(&solv->decisionq, v);
- queue_push(&solv->decisionq_why, r - solv->rules);
- solv->decisionmap[vv] = v > 0 ? 1 : -1;
- IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
- {
- Solvable *s = solv->pool->solvables + vv;
- if (v < 0)
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, "conflicting %s (weak assertion)\n", solvable2str(solv->pool, s));
- else
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, "installing %s (weak assertion)\n", solvable2str(solv->pool, s));
- }
- continue;
- }
- /*
- * previously decided, sane ?
- */
- if (v > 0 && solv->decisionmap[vv] > 0)
- continue;
- if (v < 0 && solv->decisionmap[vv] < 0)
- continue;
-
- POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "assertion conflict, but I am weak, disabling ");
- solver_printrule(solv, SAT_DEBUG_UNSOLVABLE, r);
- disablerule(solv, r);
- }
-
- POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions end; size decisionq: %d -----\n",solv->decisionq.count);
-}
-
-
-/*-------------------------------------------------------------------
- * enable/disable learnt rules
- *
- * we have enabled or disabled some of our rules. We now reenable all
- * of our learnt rules but the ones that were learnt from rules that
- * are now disabled.
- */
-static void
-enabledisablelearntrules(Solver *solv)
-{
- Pool *pool = solv->pool;
- Rule *r;
- Id why, *whyp;
- int i;
-
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "enabledisablelearntrules called\n");
- for (i = solv->learntrules, r = solv->rules + i; i < solv->nrules; i++, r++)
- {
- whyp = solv->learnt_pool.elements + solv->learnt_why.elements[i - solv->learntrules];
- while ((why = *whyp++) != 0)
- {
- assert(why > 0 && why < i);
- if (solv->rules[why].d < 0)
- break;
- }
- /* why != 0: we found a disabled rule, disable the learnt rule */
- if (why && r->d >= 0)
- {
- IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
- {
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "disabling ");
- solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
- }
- disablerule(solv, r);
- }
- else if (!why && r->d < 0)
- {
- IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
- {
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "re-enabling ");
- solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
- }
- enablerule(solv, r);
- }
- }
-}
-
-
-/*-------------------------------------------------------------------
- * enable weak rules
- *
- * Enable all rules, except learnt rules, which are
- * - disabled and weak (set in weakrulemap)
- *
- */
-
-static void
-enableweakrules(Solver *solv)
-{
- int i;
- Rule *r;
-
- for (i = 1, r = solv->rules + i; i < solv->learntrules; i++, r++)
- {
- if (r->d >= 0) /* skip non-direct literals */
- continue;
- if (!MAPTST(&solv->weakrulemap, i))
- continue;
- enablerule(solv, r);
- }
-}
-
-
-/* FIXME: bad code ahead, replace as soon as possible */
-/* FIXME: should probably look at SOLVER_INSTALL|SOLVABLE_ONE_OF */
-
-/*-------------------------------------------------------------------
- * disable update rules
- */
-
-static void
-disableupdaterules(Solver *solv, Queue *job, int jobidx)
-{
- Pool *pool = solv->pool;
- int i, j;
- Id how, select, what, p, pp;
- Solvable *s;
- Repo *installed;
- Rule *r;
- Id lastjob = -1;
-
- installed = solv->installed;
- if (!installed)
- return;
-
- if (jobidx != -1)
- {
- how = job->elements[jobidx];
- select = how & SOLVER_SELECTMASK;
- switch (how & SOLVER_JOBMASK)
- {
- case SOLVER_ERASE:
- break;
- case SOLVER_INSTALL:
- if (select != SOLVER_SOLVABLE)
- return;
- break;
- default:
- return;
- }
- }
- /* go through all enabled job rules */
- MAPZERO(&solv->noupdate);
- for (i = solv->jobrules; i < solv->jobrules_end; i++)
- {
- r = solv->rules + i;
- if (r->d < 0) /* disabled? */
- continue;
- j = solv->ruletojob.elements[i - solv->jobrules];
- if (j == lastjob)
- continue;
- lastjob = j;
- how = job->elements[j];
- what = job->elements[j + 1];
- select = how & SOLVER_SELECTMASK;
- switch (how & SOLVER_JOBMASK)
- {
- case SOLVER_INSTALL:
- if (select != SOLVER_SOLVABLE)
- break;
- s = pool->solvables + what;
- if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, what))
- break;
- if (s->repo == installed)
- break;
- if (s->obsoletes)
- {
- Id obs, *obsp;
- obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- FOR_PROVIDES(p, pp, obs)
- {
- if (pool->solvables[p].repo != installed)
- continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
- continue;
- MAPSET(&solv->noupdate, p - installed->start);
- }
- }
- FOR_PROVIDES(p, pp, s->name)
- {
- if (!solv->implicitobsoleteusesprovides && pool->solvables[p].name != s->name)
- continue;
- if (pool->solvables[p].repo == installed)
- MAPSET(&solv->noupdate, p - installed->start);
- }
- break;
- case SOLVER_ERASE:
- FOR_JOB_SELECT(p, pp, select, what)
- if (pool->solvables[p].repo == installed)
- MAPSET(&solv->noupdate, p - installed->start);
- break;
- default:
- break;
- }
- }
-
- /* fixup update rule status */
- if (jobidx != -1)
- {
- /* we just disabled job #jobidx. enable all update rules
- * that aren't disabled by the remaining job rules */
- how = job->elements[jobidx];
- what = job->elements[jobidx + 1];
- select = how & SOLVER_SELECTMASK;
- switch (how & SOLVER_JOBMASK)
- {
- case SOLVER_INSTALL:
- if (select != SOLVER_SOLVABLE)
- break;
- s = pool->solvables + what;
- if (s->repo == installed)
- break;
- if (s->obsoletes)
- {
- Id obs, *obsp;
- obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- FOR_PROVIDES(p, pp, obs)
- {
- if (pool->solvables[p].repo != installed)
- continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
- continue;
- if (MAPTST(&solv->noupdate, p - installed->start))
- continue;
- r = solv->rules + solv->updaterules + (p - installed->start);
- if (r->d >= 0)
- continue;
- enablerule(solv, r);
- IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
- {
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
- solver_printrule(solv, SAT_DEBUG_SOLUTIONS, r);
- }
- }
- }
- FOR_PROVIDES(p, pp, s->name)
- {
- if (!solv->implicitobsoleteusesprovides && pool->solvables[p].name != s->name)
- continue;
- if (pool->solvables[p].repo != installed)
- continue;
- if (MAPTST(&solv->noupdate, p - installed->start))
- continue;
- r = solv->rules + solv->updaterules + (p - installed->start);
- if (r->d >= 0)
- continue;
- enablerule(solv, r);
- IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
- {
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
- solver_printrule(solv, SAT_DEBUG_SOLUTIONS, r);
- }
- }
- break;
- case SOLVER_ERASE:
- FOR_JOB_SELECT(p, pp, select, what)
- {
- if (pool->solvables[p].repo != installed)
- continue;
- if (MAPTST(&solv->noupdate, p - installed->start))
- continue;
- r = solv->rules + solv->updaterules + (p - installed->start);
- if (r->d >= 0)
- continue;
- enablerule(solv, r);
- IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
- {
- POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
- solver_printrule(solv, SAT_DEBUG_SOLUTIONS, r);
- }
- }
- break;
- default:
- break;
- }
- return;
- }
-
- for (i = 0; i < installed->nsolvables; i++)
- {
- r = solv->rules + solv->updaterules + i;
- if (r->d >= 0 && MAPTST(&solv->noupdate, i))
- disablerule(solv, r); /* was enabled, need to disable */
- r = solv->rules + solv->featurerules + i;
- if (r->d >= 0 && MAPTST(&solv->noupdate, i))
- disablerule(solv, r); /* was enabled, need to disable */
- }
-}
-
-
-/*
- * special multiversion patch conflict handling:
- * a patch conflict is also satisfied, if some other
- * version with the same name/arch that doesn't conflict
- * get's installed. The generated rule is thus:
- * -patch|-cpack|opack1|opack2|...
- */
-Id
-makemultiversionconflict(Solver *solv, Id n, Id con)
-{
- Pool *pool = solv->pool;
- Solvable *s, *sn;
- Queue q;
- Id p, pp, qbuf[64];
-
- sn = pool->solvables + n;
- queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
- queue_push(&q, -n);
- FOR_PROVIDES(p, pp, sn->name)
- {
- s = pool->solvables + p;
- if (s->name != sn->name || s->arch != sn->arch)
- continue;
- if (!MAPTST(&solv->noobsoletes, p))
- continue;
- if (pool_match_nevr(pool, pool->solvables + p, con))
- continue;
- /* here we have a multiversion solvable that doesn't conflict */
- /* thus we're not in conflict if it is installed */
- queue_push(&q, p);
- }
- if (q.count == 1)
- return -n; /* no other package found, generate normal conflict */
- return pool_queuetowhatprovides(pool, &q);
-}
-
-
-/*-------------------------------------------------------------------
- *
- * add (install) rules for solvable
- *
- * s: Solvable for which to add rules
- * m: m[s] = 1 for solvables which have rules, prevent rule duplication
- *
- * Algorithm: 'visit all nodes of a graph'. The graph nodes are
- * solvables, the edges their dependencies.
- * Starting from an installed solvable, this will create all rules
- * representing the graph created by the solvables dependencies.
- *
- * for unfulfilled requirements, conflicts, obsoletes,....
- * add a negative assertion for solvables that are not installable
- *
- * It will also create rules for all solvables referenced by 's'
- * i.e. descend to all providers of requirements of 's'
- *
- */
-
-static void
-addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
-{
- Pool *pool = solv->pool;
- Repo *installed = solv->installed;
-
- /* 'work' queue. keeps Ids of solvables we still have to work on.
- And buffer for it. */
- Queue workq;
- Id workqbuf[64];
-
- int i;
- /* if to add rules for broken deps ('rpm -V' functionality)
- * 0 = yes, 1 = no
- */
- int dontfix;
- /* Id var and pointer for each dependency
- * (not used in parallel)
- */
- Id req, *reqp;
- Id con, *conp;
- Id obs, *obsp;
- Id rec, *recp;
- Id sug, *sugp;
- /* var and ptr for loops */
- Id p, pp;
- /* ptr to 'whatprovides' */
- Id *dp;
- /* Id for current solvable 's' */
- Id n;
-
- POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable -----\n");
-
- queue_init_buffer(&workq, workqbuf, sizeof(workqbuf)/sizeof(*workqbuf));
- queue_push(&workq, s - pool->solvables); /* push solvable Id to work queue */
-
- /* loop until there's no more work left */
- while (workq.count)
- {
- /*
- * n: Id of solvable
- * s: Pointer to solvable
- */
-
- n = queue_shift(&workq); /* 'pop' next solvable to work on from queue */
- if (MAPTST(m, n)) /* continue if already visited */
- continue;
-
- MAPSET(m, n); /* mark as visited */
- s = pool->solvables + n; /* s = Solvable in question */
-
- dontfix = 0;
- if (installed /* Installed system available */
- && !solv->fixsystem /* NOT repair errors in rpm dependency graph */
- && s->repo == installed) /* solvable is installed? */
- {
- dontfix = 1; /* dont care about broken rpm deps */
- }
-
- if (!dontfix
- && s->arch != ARCH_SRC
- && s->arch != ARCH_NOSRC
- && !pool_installable(pool, s))
- {
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", solvable2str(pool, s), (Id)(s - pool->solvables));
- addrule(solv, -n, 0); /* uninstallable */
- }
-
- /*-----------------------------------------
- * check requires of s
- */
-
- if (s->requires)
- {
- reqp = s->repo->idarraydata + s->requires;
- while ((req = *reqp++) != 0) /* go through all requires */
- {
- if (req == SOLVABLE_PREREQMARKER) /* skip the marker */
- continue;
-
- /* find list of solvables providing 'req' */
- dp = pool->whatprovidesdata + pool_whatprovides(pool, req);
-
- if (*dp == SYSTEMSOLVABLE) /* always installed */
- continue;
-
- if (dontfix)
- {
- /* the strategy here is to not insist on dependencies
- * that are already broken. so if we find one provider
- * that was already installed, we know that the
- * dependency was not broken before so we enforce it */
-
- /* check if any of the providers for 'req' is installed */
- for (i = 0; (p = dp[i]) != 0; i++)
- {
- if (pool->solvables[p].repo == installed)
- break; /* provider was installed */
- }
- /* didn't find an installed provider: previously broken dependency */
- if (!p)
- {
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "ignoring broken requires %s of installed package %s\n", dep2str(pool, req), solvable2str(pool, s));
- continue;
- }
- }
-
- if (!*dp)
- {
- /* nothing provides req! */
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable (%s)\n", solvable2str(pool, s), (Id)(s - pool->solvables), dep2str(pool, req));
- addrule(solv, -n, 0); /* mark requestor as uninstallable */
- continue;
- }
-
- IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
- {
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION," %s requires %s\n", solvable2str(pool, s), dep2str(pool, req));
- for (i = 0; dp[i]; i++)
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvable2str(pool, pool->solvables + dp[i]));
- }
-
- /* add 'requires' dependency */
- /* rule: (-requestor|provider1|provider2|...|providerN) */
- addrule(solv, -n, dp - pool->whatprovidesdata);
-
- /* descend the dependency tree
- push all non-visited providers on the work queue */
- for (; *dp; dp++)
- {
- if (!MAPTST(m, *dp))
- queue_push(&workq, *dp);
- }
-
- } /* while, requirements of n */
-
- } /* if, requirements */
-
- /* that's all we check for src packages */
- if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
- continue;
-
- /*-----------------------------------------
- * check conflicts of s
- */
-
- if (s->conflicts)
- {
- int ispatch = 0;
-
- /* we treat conflicts in patches a bit differen:
- * - nevr matching
- * - multiversion handling
- * XXX: we should really handle this different, looking
- * at the name is a bad hack
- */
- if (!strncmp("patch:", id2str(pool, s->name), 6))
- ispatch = 1;
- conp = s->repo->idarraydata + s->conflicts;
- /* foreach conflicts of 's' */
- while ((con = *conp++) != 0)
- {
- /* foreach providers of a conflict of 's' */
- FOR_PROVIDES(p, pp, con)
- {
- if (ispatch && !pool_match_nevr(pool, pool->solvables + p, con))
- continue;
- /* dontfix: dont care about conflicts with already installed packs */
- if (dontfix && pool->solvables[p].repo == installed)
- continue;
- /* p == n: self conflict */
- if (p == n && !solv->allowselfconflicts)
- {
- if (ISRELDEP(con))
- {
- Reldep *rd = GETRELDEP(pool, con);
- if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_OTHERPROVIDERS)
- continue;
- }
- p = 0; /* make it a negative assertion, aka 'uninstallable' */
- }
- if (p && ispatch && solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p) && ISRELDEP(con))
- {
- /* our patch conflicts with a noobsoletes (aka multiversion) package */
- p = -makemultiversionconflict(solv, p, con);
- }
- /* rule: -n|-p: either solvable _or_ provider of conflict */
- addrule(solv, -n, -p);
- }
- }
- }
-
- /*-----------------------------------------
- * check obsoletes if not installed
- * (only installation will trigger the obsoletes in rpm)
- */
- if (!installed || pool->solvables[n].repo != installed)
- { /* not installed */
- int noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
- if (s->obsoletes && !noobs)
- {
- obsp = s->repo->idarraydata + s->obsoletes;
- /* foreach obsoletes */
- while ((obs = *obsp++) != 0)
- {
- /* foreach provider of an obsoletes of 's' */
- FOR_PROVIDES(p, pp, obs)
- {
- if (!solv->obsoleteusesprovides /* obsoletes are matched names, not provides */
- && !pool_match_nevr(pool, pool->solvables + p, obs))
- continue;
- addrule(solv, -n, -p);
- }
- }
- }
- FOR_PROVIDES(p, pp, s->name)