continue;
if (solv->weakrulemap.size && MAPTST(&solv->weakrulemap, i)) /* weak: silently ignore */
continue;
-
+
POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, " - disabling rule #%d\n", i);
solver_printruleclass(solv, SOLV_DEBUG_UNSOLVABLE, solv->rules + i);
solver_recordproblem(solv, i);
disable_recommendsrules(Solver *solv, Queue *weakq)
{
Pool *pool = solv->pool;
- int i;
+ int i, rid;
for (i = 0; i < weakq->count; i++)
{
- Rule *r;
- if (!queue_contains(solv->recommendsruleq, weakq->elements[i]))
- continue;
- r = solv->rules + weakq->elements[i];
- if (r->d >= 0)
+ rid = weakq->elements[i];
+ if ((rid >= solv->recommendsrules && rid < solv->recommendsrules_end) || queue_contains(solv->recommendsruleq, rid))
{
- POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, "disabling ");
- solver_printruleclass(solv, SOLV_DEBUG_UNSOLVABLE, r);
- solver_disablerule(solv, r);
+ Rule *r = solv->rules + rid;
+ if (r->d >= 0)
+ {
+ POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, "disabling ");
+ solver_printruleclass(solv, SOLV_DEBUG_UNSOLVABLE, r);
+ solver_disablerule(solv, r);
+ }
}
}
}
solver_recordproblem(solv, why);
}
+/* fix a problem by disabling one or more weak rules */
+static void
+disable_weakrules(Solver *solv, Queue *weakq)
+{
+ Pool *pool = solv->pool;
+ int i;
+ Id lastweak = 0;
+ for (i = 0; i < weakq->count; i++)
+ if (weakq->elements[i] > lastweak)
+ lastweak = weakq->elements[i];
+ if (lastweak >= solv->recommendsrules && lastweak < solv->recommendsrules_end)
+ {
+ lastweak = 0;
+ for (i = 0; i < weakq->count; i++)
+ if (weakq->elements[i] < solv->recommendsrules && weakq->elements[i] > lastweak)
+ lastweak = weakq->elements[i];
+ if (lastweak < solv->pkgrules_end)
+ {
+ disable_recommendsrules(solv, weakq);
+ return;
+ }
+ }
+ if (lastweak < solv->pkgrules_end && solv->strongrecommends && solv->recommendsruleq && queue_contains(solv->recommendsruleq, lastweak))
+ {
+ disable_recommendsrules(solv, weakq);
+ return;
+ }
+ POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, "disabling ");
+ solver_printruleclass(solv, SOLV_DEBUG_UNSOLVABLE, solv->rules + lastweak);
+ /* choice rules need special handling */
+ if (lastweak >= solv->choicerules && lastweak < solv->choicerules_end)
+ solver_disablechoicerules(solv, solv->rules + lastweak);
+ else
+ solver_fixproblem(solv, lastweak);
+}
/*-------------------------------------------------------------------
*
Map rseen;
Queue weakq;
Id pp, v, vv, why;
- int i, idx;
+ int idx;
Id *decisionmap = solv->decisionmap;
int oldproblemcount;
int oldlearntpoolcount;
if (weakq.count)
{
- Id lastweak;
/* revert problems */
solv->problems.count = oldproblemcount;
solv->learnt_pool.count = oldlearntpoolcount;
- /* find last weak */
- lastweak = 0;
- for (i = 0; i < weakq.count; i++)
- if (weakq.elements[i] > lastweak)
- lastweak = weakq.elements[i];
- if (lastweak < solv->pkgrules_end && solv->strongrecommends && solv->recommendsruleq && queue_contains(solv->recommendsruleq, lastweak))
- {
- disable_recommendsrules(solv, &weakq);
- queue_free(&weakq);
- solver_reset(solv);
- return 0;
- }
+ /* disable some weak rules */
+ disable_weakrules(solv, &weakq);
queue_free(&weakq);
- POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, "disabling ");
- solver_printruleclass(solv, SOLV_DEBUG_UNSOLVABLE, solv->rules + lastweak);
- if (lastweak >= solv->choicerules && lastweak < solv->choicerules_end)
- solver_disablechoicerules(solv, solv->rules + lastweak);
- solver_fixproblem(solv, lastweak);
solver_reset(solv);
return 0;
}
/*-------------------------------------------------------------------
*
* branch handling
+ *
+ * format is:
+ * [ -p1 p2 p3 .. pn opt_pkg opt_data size level ]
+ *
+ * pkgs are negative if we tried them (to prevent inifinite recursion)
+ * opt_pkg: recommends: package with the recommends
+ * rule: 0
+ * opt_data: recommends: depid
+ * rule: ruleid
*/
static void
queuep_free(&solv->recommendscplxq);
queuep_free(&solv->suggestscplxq);
queuep_free(&solv->brokenorphanrules);
- queuep_free(&solv->favorq);
queuep_free(&solv->recommendsruleq);
map_free(&solv->recommendsmap);
map_free(&solv->droporphanedmap);
map_free(&solv->cleandepsmap);
map_free(&solv->allowuninstallmap);
- map_free(&solv->favormap);
- map_free(&solv->isdisfavormap);
+ solv_free(solv->favormap);
solv_free(solv->decisionmap);
solv_free(solv->rules);
solv_free(solv->watches);
solv_free(solv->obsoletes);
solv_free(solv->obsoletes_data);
solv_free(solv->specialupdaters);
- solv_free(solv->choicerules_ref);
- solv_free(solv->bestrules_pkg);
+ solv_free(solv->choicerules_info);
+ solv_free(solv->bestrules_info);
solv_free(solv->yumobsrules_info);
+ solv_free(solv->recommendsrules_info);
solv_free(solv->instbuddy);
solv_free(solv);
}
return solv->strongrecommends;
case SOLVER_FLAG_INSTALL_ALSO_UPDATES:
return solv->install_also_updates;
+ case SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED:
+ return solv->only_namespace_recommended;
default:
break;
}
case SOLVER_FLAG_INSTALL_ALSO_UPDATES:
solv->install_also_updates = value;
break;
+ case SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED:
+ solv->only_namespace_recommended = value;
+ break;
default:
break;
}
{
if (specialupdaters && (d = specialupdaters[i - installed->start]) != 0)
{
+ int j;
/* special multiversion handling, make sure best version is chosen */
if (rr->p == i && solv->decisionmap[i] >= 0)
queue_push(dq, i);
while ((p = pool->whatprovidesdata[d++]) != 0)
if (solv->decisionmap[p] >= 0)
queue_push(dq, p);
+ for (j = 0; j < dq->count; j++)
+ {
+ Id p2 = dq->elements[j];
+ if (pool->solvables[p2].repo != installed)
+ continue;
+ d = specialupdaters[i - installed->start];
+ while ((p = pool->whatprovidesdata[d++]) != 0)
+ {
+ if (solv->decisionmap[p] >= 0 || pool->solvables[p].repo == installed)
+ continue;
+ if (solvable_identical(pool->solvables + p, pool->solvables + p2))
+ queue_push(dq, p); /* identical to installed, put it on the list so we have a repo prio */
+ }
+ }
if (dq->count && solv->update_targets && solv->update_targets->elements[i - installed->start])
prune_to_update_targets(solv, solv->update_targets->elements + solv->update_targets->elements[i - installed->start], dq);
if (dq->count)
Rule *r;
int origlevel = level;
Id p, *dp;
+ int focusbest = solv->focus_best && solv->do_extra_reordering;
+ Repo *installed = solv->installed;
/*
* decide
}
if (i == solv->nrules)
i = 1;
- if (solv->focus_best && solv->do_extra_reordering && i >= solv->featurerules)
+ if (focusbest && i >= solv->featurerules)
continue;
r = solv->rules + i;
if (r->d < 0) /* ignore disabled rules */
if (r->d == 0 || solv->decisionmap[-r->p] <= 0)
continue;
}
+ if (focusbest && r->d != 0 && installed)
+ {
+ /* make sure at least one negative literal is from a new package */
+ if (!(r->p < 0 && pool->solvables[-r->p].repo != installed))
+ {
+ dp = pool->whatprovidesdata + r->d;
+ while ((p = *dp++) != 0)
+ if (p < 0 && solv->decisionmap[-p] > 0 && pool->solvables[-p].repo != installed)
+ break;
+ if (!p)
+ continue; /* sorry */
+ }
+ }
if (dq->count)
queue_empty(dq);
if (r->d == 0)
prune_disfavored(Solver *solv, Queue *plist)
{
int i, j;
- if (!solv->isdisfavormap.size)
- return;
- for (i = j = 0; i < plist->count; i++)
- {
+ for (i = j = 0; i < plist->count; i++)
+ {
Id p = plist->elements[i];
- if (!MAPTST(&solv->isdisfavormap, p))
- plist->elements[j++] = p;
- }
+ if (solv->favormap[p] >= 0)
+ plist->elements[j++] = p;
+ }
if (i != j)
queue_truncate(plist, j);
}
Id *recp, rec, pp, p;
if (!solv->addalreadyrecommended && s->repo == solv->installed)
continue;
- /* XXX need to special case AND ? */
if (s->recommends)
{
recp = s->repo->idarraydata + s->recommends;
while ((rec = *recp++) != 0)
{
+ /* cheat: we just look if there is REL_NAMESPACE in the dep */
+ if (solv->only_namespace_recommended && !solver_is_namespace_dep(solv, rec))
+ continue;
#ifdef ENABLE_COMPLEX_DEPS
if (pool_is_complex_dep(pool, rec))
{
continue;
if (solv->process_orphans && solv->installed && s->repo == solv->installed && (solv->droporphanedmap_all || (solv->droporphanedmap.size && MAPTST(&solv->droporphanedmap, i - solv->installed->start))))
continue;
- if (solv->isdisfavormap.size && MAPTST(&solv->isdisfavormap, i))
+ if (solv->havedisfavored && solv->favormap[i] < 0)
continue; /* disfavored supplements, do not install */
queue_push(dqs, i);
}
}
/* filter out disfavored recommended packages */
- if (dq->count && solv->isdisfavormap.size)
+ if (dq->count && solv->havedisfavored)
prune_disfavored(solv, dq);
/* filter out all packages obsoleted by installed packages */
}
/* filter out all already supplemented packages if requested */
- if (!solv->addalreadyrecommended && dqs->count)
+ if ((!solv->addalreadyrecommended || solv->only_namespace_recommended) && dqs->count)
{
/* filter out old supplements */
for (i = j = 0; i < dqs->count; i++)
policy_filter_unwanted(solv, dq, POLICY_MODE_CHOOSE);
/* if we have multiple candidates we open a branch */
if (dq->count > 1)
- createbranch(solv, level, dq, s - pool->solvables, rec);
+ createbranch(solv, level, dq, s - pool->solvables, rec);
p = dq->elements[0];
POOL_DEBUG(SOLV_DEBUG_POLICY, "installing recommended %s\n", pool_solvid2str(pool, p));
olevel = level;
break;
}
*rerunp = 1;
+ return level;
}
}
return level;
if (rerun)
continue;
}
-
+
/* one final pass to make sure we decided all installed packages */
if (solv->installed)
{
lastsi = -1;
break;
}
- if (solv->isdisfavormap.size && MAPTST(&solv->isdisfavormap, p))
+ if (solv->havedisfavored && solv->favormap[p] < 0)
continue;
if (lastsi < 0 && (MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
lastsi = i;
if (lastsi >= 0)
{
/* we have a recommended package that could not be installed */
- /* take it if our current selection is not recommended */
+ /* find current selection and take new one if it is not recommended */
for (i = starti; i < endi - 4; i++)
{
p = -solv->branches.elements[i];
if (p <= 0 || solv->decisionmap[p] != l + 1)
continue;
- if (solv->favormap.size && MAPTST(&solv->favormap, p))
- if (!(solv->isdisfavormap.size && MAPTST(&solv->isdisfavormap, p)))
- continue; /* current selection is favored */
+ if (solv->favormap && solv->favormap[p] > solv->favormap[solv->branches.elements[lastsi]])
+ continue; /* current selection is more favored */
if (!(MAPTST(&solv->recommendsmap, p) || solver_is_supplementing(solv, pool->solvables + p)))
{
lasti = lastsi;
Pool *pool = solv->pool;
Solvable *s = pool->solvables + p;
Repo *installed = solv->installed;
- Id pi, pip;
+ Id pi, pip, identicalp;
+ int startcnt, endcnt;
+
if (!solv->update_targets)
{
solv->update_targets = solv_calloc(1, sizeof(Queue));
queue_push2(solv->update_targets, p, p);
return;
}
+ identicalp = 0;
+ startcnt = solv->update_targets->count;
FOR_PROVIDES(pi, pip, s->name)
{
Solvable *si = pool->solvables + pi;
if (how & SOLVER_CLEANDEPS)
add_cleandeps_updatepkg(solv, pi);
queue_push2(solv->update_targets, pi, p);
- /* check if it's ok to keep the installed package */
+ /* remember an installed package that is identical to p */
if (s->evr == si->evr && solvable_identical(s, si))
- queue_push2(solv->update_targets, pi, pi);
+ identicalp = pi;
}
if (s->obsoletes)
{
}
}
}
+ /* also allow upgrading to an identical installed package */
+ if (identicalp)
+ {
+ for (endcnt = solv->update_targets->count; startcnt < endcnt; startcnt += 2)
+ queue_push2(solv->update_targets, solv->update_targets->elements[startcnt], identicalp);
+ }
}
static int
for (; i < pool->nsolvables; i++)
if (MAPTST(addedmap, i))
queue_push(&solv->addedmap_deduceq, i);
- j = 0;
- for (i = 2; i < pool->nsolvables; i++)
- if (MAPTST(addedmap, i))
- j++;
}
static void
}
#endif
-/* sort by package id, last entry wins */
-static int
-setup_favormaps_cmp(const void *ap, const void *bp, void *dp)
-{
- const Id *a = ap, *b = bp;
- if ((*a - *b) != 0)
- return *a - *b;
- return (b[1] < 0 ? -b[1] : b[1]) - (a[1] < 0 ? -a[1] : a[1]);
-}
-
static void
-setup_favormaps(Solver *solv)
+setup_favormap(Solver *solv)
{
- Queue *q = solv->favorq;
+ Queue *job = &solv->job;
Pool *pool = solv->pool;
- int i;
- Id oldp = 0;
- if (q->count > 2)
- solv_sort(q->elements, q->count / 2, 2 * sizeof(Id), setup_favormaps_cmp, solv);
- map_grow(&solv->favormap, pool->nsolvables);
- for (i = 0; i < q->count; i += 2)
+ int i, idx;
+ Id p, pp, how, what, select;
+
+ solv_free(solv->favormap);
+ solv->favormap = solv_calloc(pool->nsolvables, sizeof(Id));
+ for (i = 0; i < job->count; i += 2)
{
- Id p = q->elements[i];
- if (p == oldp)
+ how = job->elements[i];
+ if ((how & SOLVER_JOBMASK) != SOLVER_FAVOR && (how & SOLVER_JOBMASK) != SOLVER_DISFAVOR)
continue;
- oldp = p;
- MAPSET(&solv->favormap, p);
- if (q->elements[i + 1] < 0)
+ what = job->elements[i + 1];
+ select = how & SOLVER_SELECTMASK;
+ idx = (how & SOLVER_JOBMASK) == SOLVER_FAVOR ? i + 1 : -(i + 1);
+ if (select == SOLVER_SOLVABLE_REPO)
+ {
+ Repo *repo = pool_id2repo(pool, what);
+ if (repo)
+ {
+ Solvable *s;
+ FOR_REPO_SOLVABLES(repo, p, s)
+ {
+ solv->favormap[p] = idx;
+ if (idx < 0)
+ solv->havedisfavored = 1;
+ }
+ }
+ }
+ FOR_JOB_SELECT(p, pp, select, what)
{
- if (!solv->isdisfavormap.size)
- map_grow(&solv->isdisfavormap, pool->nsolvables);
- MAPSET(&solv->isdisfavormap, p);
+ solv->favormap[p] = idx;
+ if (idx < 0)
+ solv->havedisfavored = 1;
}
}
}
int now, solve_start;
int needduprules = 0;
int hasbestinstalljob = 0;
+ int hasfavorjob = 0;
+ int haslockjob = 0;
solve_start = solv_timems(0);
POOL_DEBUG(SOLV_DEBUG_STATS, "dupallowdowngrade=%d, dupallownamechange=%d, dupallowarchchange=%d, dupallowvendorchange=%d\n", solv->dup_allowdowngrade, solv->dup_allownamechange, solv->dup_allowarchchange, solv->dup_allowvendorchange);
POOL_DEBUG(SOLV_DEBUG_STATS, "promoteepoch=%d, forbidselfconflicts=%d\n", pool->promoteepoch, pool->forbidselfconflicts);
POOL_DEBUG(SOLV_DEBUG_STATS, "obsoleteusesprovides=%d, implicitobsoleteusesprovides=%d, obsoleteusescolors=%d, implicitobsoleteusescolors=%d\n", pool->obsoleteusesprovides, pool->implicitobsoleteusesprovides, pool->obsoleteusescolors, pool->implicitobsoleteusescolors);
- POOL_DEBUG(SOLV_DEBUG_STATS, "dontinstallrecommended=%d, addalreadyrecommended=%d\n", solv->dontinstallrecommended, solv->addalreadyrecommended);
+ POOL_DEBUG(SOLV_DEBUG_STATS, "dontinstallrecommended=%d, addalreadyrecommended=%d onlynamespacerecommended=%d\n", solv->dontinstallrecommended, solv->addalreadyrecommended, solv->only_namespace_recommended);
/* create whatprovides if not already there */
if (!pool->whatprovides)
queuep_free(&solv->update_targets);
queuep_free(&solv->cleandeps_updatepkgs);
queue_empty(&solv->ruleassertions);
- solv->bestrules_pkg = solv_free(solv->bestrules_pkg);
+ solv->bestrules_info = solv_free(solv->bestrules_info);
solv->yumobsrules_info = solv_free(solv->yumobsrules_info);
- solv->choicerules_ref = solv_free(solv->choicerules_ref);
+ solv->recommendsrules_info = solv_free(solv->recommendsrules_info);
+ solv->choicerules_info = solv_free(solv->choicerules_info);
if (solv->noupdate.size)
map_empty(&solv->noupdate);
map_zerosize(&solv->multiversion);
map_zerosize(&solv->allowuninstallmap);
map_zerosize(&solv->cleandepsmap);
map_zerosize(&solv->weakrulemap);
- map_zerosize(&solv->favormap);
- map_zerosize(&solv->isdisfavormap);
+ solv->favormap = solv_free(solv->favormap);
queue_empty(&solv->weakruleq);
solv->watches = solv_free(solv->watches);
queue_empty(&solv->ruletojob);
*/
initialnrules = solv->pkgrules_end ? solv->pkgrules_end : 1;
if (initialnrules > 1)
- deduceq2addedmap(solv, &addedmap);
+ deduceq2addedmap(solv, &addedmap); /* also enables all pkg rules */
if (solv->nrules != initialnrules)
- solver_shrinkrules(solv, initialnrules);
+ solver_shrinkrules(solv, initialnrules); /* shrink to just pkg rules */
solv->lastpkgrule = 0;
solv->pkgrules_end = 0;
solver_addjobrule(solv, solv->instbuddy[p - installed->start], 0, 0, i, weak);
#endif
}
+ if (solv->nrules != oldnrules)
+ haslockjob = 1;
break;
case SOLVER_DISTUPGRADE:
POOL_DEBUG(SOLV_DEBUG_JOB, "job: distupgrade %s\n", solver_select2str(pool, select, what));
case SOLVER_FAVOR:
case SOLVER_DISFAVOR:
POOL_DEBUG(SOLV_DEBUG_JOB, "job: %s %s\n", (how & SOLVER_JOBMASK) == SOLVER_FAVOR ? "favor" : "disfavor", solver_select2str(pool, select, what));
- FOR_JOB_SELECT(p, pp, select, what)
- {
- int j;
- if (!solv->favorq)
- {
- solv->favorq = solv_calloc(1, sizeof(Queue));
- queue_init(solv->favorq);
- }
- j = solv->favorq->count + 1;
- queue_push2(solv->favorq, p, (how & SOLVER_JOBMASK) == SOLVER_FAVOR ? j : -j);
- }
+ hasfavorjob = 1;
break;
default:
POOL_DEBUG(SOLV_DEBUG_JOB, "job: unknown job\n");
assert(solv->ruletojob.count == solv->nrules - solv->jobrules);
solv->jobrules_end = solv->nrules;
- /* transform favorq into two maps */
- if (solv->favorq)
- setup_favormaps(solv);
+ /* create favormap if we have favor jobs */
+ if (hasfavorjob)
+ setup_favormap(solv);
/* now create infarch and dup rules */
if (!solv->noinfarchcheck)
#endif
if (solv->bestupdatemap_all || solv->bestupdatemap.size || hasbestinstalljob)
- solver_addbestrules(solv, hasbestinstalljob);
+ solver_addbestrules(solv, hasbestinstalljob, haslockjob);
else
solv->bestrules = solv->bestrules_end = solv->bestrules_up = solv->nrules;
else
solv->yumobsrules = solv->yumobsrules_end = solv->nrules;
+ if (solv->havedisfavored && solv->strongrecommends && solv->recommendsruleq)
+ solver_addrecommendsrules(solv);
+ else
+ solv->recommendsrules = solv->recommendsrules_end = solv->nrules;
+
if (1)
solver_addchoicerules(solv);
else
solv->choicerules = solv->choicerules_end = solv->nrules;
- if (0)
- {
- for (i = solv->featurerules; i < solv->nrules; i++)
- solver_printruleclass(solv, SOLV_DEBUG_RESULT, solv->rules + i);
- }
/* all rules created
* --------------------------------------------------------------
* prepare for solving
char buf[64];
if (solver_ruleclass(solv, id) == SOLVER_RULE_CHOICE)
id = solver_rule2pkgrule(solv, id);
+ if (solver_ruleclass(solv, id) == SOLVER_RULE_RECOMMENDS)
+ id = solver_rule2pkgrule(solv, id);
rtype = solver_ruleinfo(solv, id, &depfrom, &depto, &dep);
if ((rtype & SOLVER_RULE_TYPEMASK) == SOLVER_RULE_JOB)
{