2 * Copyright (c) 2008, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * debug functions for the SAT solver
21 #include "solver_private.h"
22 #include "solverdebug.h"
32 * create obsoletesmap from solver decisions
34 * for solvables in installed repo:
36 * p - one of the packages that obsolete us
38 * n - number of packages this package obsoletes
42 /* OBSOLETE: use transaction code instead! */
45 solver_create_decisions_obsoletesmap(Solver *solv)
47 Pool *pool = solv->pool;
48 Repo *installed = solv->installed;
49 Id p, *obsoletesmap = NULL;
53 obsoletesmap = (Id *)solv_calloc(pool->nsolvables, sizeof(Id));
56 for (i = 0; i < solv->decisionq.count; i++)
61 n = solv->decisionq.elements[i];
64 if (n == SYSTEMSOLVABLE)
66 s = pool->solvables + n;
67 if (s->repo == installed) /* obsoletes don't count for already installed packages */
69 noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
70 FOR_PROVIDES(p, pp, s->name)
72 Solvable *ps = pool->solvables + p;
73 if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
75 if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
77 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
79 if (ps->repo == installed && !obsoletesmap[p])
86 for (i = 0; i < solv->decisionq.count; i++)
91 n = solv->decisionq.elements[i];
94 if (n == SYSTEMSOLVABLE)
96 s = pool->solvables + n;
97 if (s->repo == installed) /* obsoletes don't count for already installed packages */
101 if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n))
103 obsp = s->repo->idarraydata + s->obsoletes;
104 while ((obs = *obsp++) != 0)
106 FOR_PROVIDES(p, pp, obs)
108 Solvable *ps = pool->solvables + p;
109 if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
111 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
113 if (pool->solvables[p].repo == installed && !obsoletesmap[p])
126 solver_printruleelement(Solver *solv, int type, Rule *r, Id v)
128 Pool *pool = solv->pool;
132 s = pool->solvables + -v;
133 POOL_DEBUG(type, " !%s [%d]", pool_solvable2str(pool, s), -v);
137 s = pool->solvables + v;
138 POOL_DEBUG(type, " %s [%d]", pool_solvable2str(pool, s), v);
140 if (pool->installed && s->repo == pool->installed)
141 POOL_DEBUG(type, "I");
145 POOL_DEBUG(type, " (w1)");
147 POOL_DEBUG(type, " (w2)");
149 if (solv->decisionmap[s - pool->solvables] > 0)
150 POOL_DEBUG(type, " Install.level%d", solv->decisionmap[s - pool->solvables]);
151 if (solv->decisionmap[s - pool->solvables] < 0)
152 POOL_DEBUG(type, " Conflict.level%d", -solv->decisionmap[s - pool->solvables]);
153 POOL_DEBUG(type, "\n");
162 solver_printrule(Solver *solv, int type, Rule *r)
164 Pool *pool = solv->pool;
168 if (r >= solv->rules && r < solv->rules + solv->nrules) /* r is a solver rule */
169 POOL_DEBUG(type, "Rule #%d:", (int)(r - solv->rules));
171 POOL_DEBUG(type, "Rule:"); /* r is any rule */
173 POOL_DEBUG(type, " (disabled)");
174 POOL_DEBUG(type, "\n");
175 d = r->d < 0 ? -r->d - 1 : r->d;
179 /* print direct literal */
185 /* binary rule --> print w2 as second literal */
189 /* every other which is in d */
190 v = solv->pool->whatprovidesdata[d + i - 1];
193 solver_printruleelement(solv, type, r, v);
195 POOL_DEBUG(type, " next rules: %d %d\n", r->n1, r->n2);
199 solver_printruleclass(Solver *solv, int type, Rule *r)
201 Pool *pool = solv->pool;
202 Id p = r - solv->rules;
204 if (p < solv->learntrules)
205 if (MAPTST(&solv->weakrulemap, p))
206 POOL_DEBUG(type, "WEAK ");
207 if (solv->learntrules && p >= solv->learntrules)
208 POOL_DEBUG(type, "LEARNT ");
209 else if (p >= solv->bestrules && p < solv->bestrules_end)
210 POOL_DEBUG(type, "BEST ");
211 else if (p >= solv->choicerules && p < solv->choicerules_end)
212 POOL_DEBUG(type, "CHOICE ");
213 else if (p >= solv->infarchrules && p < solv->infarchrules_end)
214 POOL_DEBUG(type, "INFARCH ");
215 else if (p >= solv->duprules && p < solv->duprules_end)
216 POOL_DEBUG(type, "DUP ");
217 else if (p >= solv->jobrules && p < solv->jobrules_end)
218 POOL_DEBUG(type, "JOB ");
219 else if (p >= solv->updaterules && p < solv->updaterules_end)
220 POOL_DEBUG(type, "UPDATE ");
221 else if (p >= solv->featurerules && p < solv->featurerules_end)
222 POOL_DEBUG(type, "FEATURE ");
223 solver_printrule(solv, type, r);
227 solver_printproblem(Solver *solv, Id v)
229 Pool *pool = solv->pool;
235 solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, solv->rules + v);
239 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "JOB %d\n", v);
240 jp = solv->ruletojob.elements;
241 for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
244 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "- ");
245 solver_printrule(solv, SOLV_DEBUG_SOLUTIONS, r);
247 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "ENDJOB\n");
252 solver_printwatches(Solver *solv, int type)
254 Pool *pool = solv->pool;
257 POOL_DEBUG(type, "Watches: \n");
258 for (counter = -(pool->nsolvables - 1); counter < pool->nsolvables; counter++)
259 POOL_DEBUG(type, " solvable [%d] -- rule [%d]\n", counter, solv->watches[counter + pool->nsolvables]);
263 solver_printdecisionq(Solver *solv, int type)
265 Pool *pool = solv->pool;
269 POOL_DEBUG(type, "Decisions:\n");
270 for (i = 0; i < solv->decisionq.count; i++)
272 p = solv->decisionq.elements[i];
274 POOL_DEBUG(type, "%d %d install %s, ", i, solv->decisionmap[p], pool_solvid2str(pool, p));
276 POOL_DEBUG(type, "%d %d conflict %s, ", i, -solv->decisionmap[-p], pool_solvid2str(pool, -p));
277 why = solv->decisionq_why.elements[i];
280 POOL_DEBUG(type, "forced by ");
281 solver_printruleclass(solv, type, solv->rules + why);
285 POOL_DEBUG(type, "chosen from ");
286 solver_printruleclass(solv, type, solv->rules - why);
289 POOL_DEBUG(type, "picked for some unknown reason.\n");
298 solver_printdecisions(Solver *solv)
300 Pool *pool = solv->pool;
301 Repo *installed = solv->installed;
302 Transaction *trans = solver_create_transaction(solv);
307 Queue recommendations;
311 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
312 POOL_DEBUG(SOLV_DEBUG_RESULT, "transaction:\n");
315 for (i = 0; i < trans->steps.count; i++)
317 p = trans->steps.elements[i];
318 s = pool->solvables + p;
319 type = transaction_type(trans, p, SOLVER_TRANSACTION_SHOW_ACTIVE|SOLVER_TRANSACTION_SHOW_ALL|SOLVER_TRANSACTION_SHOW_OBSOLETES|SOLVER_TRANSACTION_SHOW_MULTIINSTALL);
322 case SOLVER_TRANSACTION_MULTIINSTALL:
323 POOL_DEBUG(SOLV_DEBUG_RESULT, " multi install %s", pool_solvable2str(pool, s));
325 case SOLVER_TRANSACTION_MULTIREINSTALL:
326 POOL_DEBUG(SOLV_DEBUG_RESULT, " multi reinstall %s", pool_solvable2str(pool, s));
328 case SOLVER_TRANSACTION_INSTALL:
329 POOL_DEBUG(SOLV_DEBUG_RESULT, " install %s", pool_solvable2str(pool, s));
331 case SOLVER_TRANSACTION_REINSTALL:
332 POOL_DEBUG(SOLV_DEBUG_RESULT, " reinstall %s", pool_solvable2str(pool, s));
334 case SOLVER_TRANSACTION_DOWNGRADE:
335 POOL_DEBUG(SOLV_DEBUG_RESULT, " downgrade %s", pool_solvable2str(pool, s));
337 case SOLVER_TRANSACTION_CHANGE:
338 POOL_DEBUG(SOLV_DEBUG_RESULT, " change %s", pool_solvable2str(pool, s));
340 case SOLVER_TRANSACTION_UPGRADE:
341 case SOLVER_TRANSACTION_OBSOLETES:
342 POOL_DEBUG(SOLV_DEBUG_RESULT, " upgrade %s", pool_solvable2str(pool, s));
344 case SOLVER_TRANSACTION_ERASE:
345 POOL_DEBUG(SOLV_DEBUG_RESULT, " erase %s", pool_solvable2str(pool, s));
352 case SOLVER_TRANSACTION_INSTALL:
353 case SOLVER_TRANSACTION_ERASE:
354 case SOLVER_TRANSACTION_MULTIINSTALL:
355 case SOLVER_TRANSACTION_MULTIREINSTALL:
356 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
358 case SOLVER_TRANSACTION_REINSTALL:
359 case SOLVER_TRANSACTION_DOWNGRADE:
360 case SOLVER_TRANSACTION_CHANGE:
361 case SOLVER_TRANSACTION_UPGRADE:
362 case SOLVER_TRANSACTION_OBSOLETES:
363 transaction_all_obs_pkgs(trans, p, &iq);
366 POOL_DEBUG(SOLV_DEBUG_RESULT, " (obsoletes");
367 for (j = 0; j < iq.count; j++)
368 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s", pool_solvid2str(pool, iq.elements[j]));
369 POOL_DEBUG(SOLV_DEBUG_RESULT, ")");
371 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
379 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
381 queue_init(&recommendations);
382 queue_init(&suggestions);
383 queue_init(&orphaned);
384 solver_get_recommendations(solv, &recommendations, &suggestions, 0);
385 if (recommendations.count)
387 POOL_DEBUG(SOLV_DEBUG_RESULT, "recommended packages:\n");
388 for (i = 0; i < recommendations.count; i++)
390 s = pool->solvables + recommendations.elements[i];
391 if (solv->decisionmap[recommendations.elements[i]] > 0)
393 if (installed && s->repo == installed)
394 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (installed)\n", pool_solvable2str(pool, s));
396 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (selected)\n", pool_solvable2str(pool, s));
399 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", pool_solvable2str(pool, s));
401 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
404 if (suggestions.count)
406 POOL_DEBUG(SOLV_DEBUG_RESULT, "suggested packages:\n");
407 for (i = 0; i < suggestions.count; i++)
409 s = pool->solvables + suggestions.elements[i];
410 if (solv->decisionmap[suggestions.elements[i]] > 0)
412 if (installed && s->repo == installed)
413 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (installed)\n", pool_solvable2str(pool, s));
415 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (selected)\n", pool_solvable2str(pool, s));
418 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", pool_solvable2str(pool, s));
420 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
424 POOL_DEBUG(SOLV_DEBUG_RESULT, "orphaned packages:\n");
425 for (i = 0; i < orphaned.count; i++)
427 s = pool->solvables + orphaned.elements[i];
428 if (solv->decisionmap[solv->orphaned.elements[i]] > 0)
429 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (kept)\n", pool_solvable2str(pool, s));
431 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (erased)\n", pool_solvable2str(pool, s));
433 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
435 queue_free(&recommendations);
436 queue_free(&suggestions);
437 queue_free(&orphaned);
438 transaction_free(trans);
442 const char *id2strnone(Pool *pool, Id id)
444 return !id || id == 1 ? "(none)" : pool_id2str(pool, id);
448 transaction_print(Transaction *trans)
450 Pool *pool = trans->pool;
452 int i, j, mode, l, linel;
456 queue_init(&classes);
459 transaction_classify(trans, mode, &classes);
460 for (i = 0; i < classes.count; i += 4)
462 Id class = classes.elements[i];
463 Id cnt = classes.elements[i + 1];
466 case SOLVER_TRANSACTION_ERASE:
467 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d erased packages:\n", cnt);
469 case SOLVER_TRANSACTION_INSTALL:
470 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d installed packages:\n", cnt);
472 case SOLVER_TRANSACTION_REINSTALLED:
473 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d reinstalled packages:\n", cnt);
475 case SOLVER_TRANSACTION_DOWNGRADED:
476 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d downgraded packages:\n", cnt);
478 case SOLVER_TRANSACTION_CHANGED:
479 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d changed packages:\n", cnt);
481 case SOLVER_TRANSACTION_UPGRADED:
482 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d upgraded packages:\n", cnt);
484 case SOLVER_TRANSACTION_VENDORCHANGE:
485 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d vendor changes from '%s' to '%s':\n", cnt, id2strnone(pool, classes.elements[i + 2]), id2strnone(pool, classes.elements[i + 3]));
487 case SOLVER_TRANSACTION_ARCHCHANGE:
488 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d arch changes from %s to %s:\n", cnt, pool_id2str(pool, classes.elements[i + 2]), pool_id2str(pool, classes.elements[i + 3]));
491 class = SOLVER_TRANSACTION_IGNORE;
494 if (class == SOLVER_TRANSACTION_IGNORE)
496 transaction_classify_pkgs(trans, mode, class, classes.elements[i + 2], classes.elements[i + 3], &pkgs);
499 for (j = 0; j < pkgs.count; j++)
501 Id p = pkgs.elements[j];
502 Solvable *s = pool->solvables + p;
507 case SOLVER_TRANSACTION_DOWNGRADED:
508 case SOLVER_TRANSACTION_UPGRADED:
509 s2 = pool->solvables + transaction_obs_pkg(trans, p);
510 POOL_DEBUG(SOLV_DEBUG_RESULT, " - %s -> %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, s2));
512 case SOLVER_TRANSACTION_VENDORCHANGE:
513 case SOLVER_TRANSACTION_ARCHCHANGE:
514 n = pool_id2str(pool, s->name);
516 if (l + linel > sizeof(line) - 3)
519 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", line);
523 if (l + linel > sizeof(line) - 3)
524 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", n);
529 strcpy(line + linel, ", ");
532 strcpy(line + linel, n);
537 POOL_DEBUG(SOLV_DEBUG_RESULT, " - %s\n", pool_solvable2str(pool, s));
542 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", line);
543 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
545 queue_free(&classes);
550 solver_printproblemruleinfo(Solver *solv, Id probr)
552 Pool *pool = solv->pool;
553 Id dep, source, target;
555 switch (solver_ruleinfo(solv, probr, &source, &target, &dep))
557 case SOLVER_RULE_DISTUPGRADE:
558 POOL_DEBUG(SOLV_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", pool_solvid2str(pool, source));
560 case SOLVER_RULE_INFARCH:
561 POOL_DEBUG(SOLV_DEBUG_RESULT, "%s has inferior architecture\n", pool_solvid2str(pool, source));
563 case SOLVER_RULE_UPDATE:
564 POOL_DEBUG(SOLV_DEBUG_RESULT, "problem with installed package %s\n", pool_solvid2str(pool, source));
566 case SOLVER_RULE_JOB:
567 POOL_DEBUG(SOLV_DEBUG_RESULT, "conflicting requests\n");
569 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
570 POOL_DEBUG(SOLV_DEBUG_RESULT, "nothing provides requested %s\n", pool_dep2str(pool, dep));
572 case SOLVER_RULE_RPM:
573 POOL_DEBUG(SOLV_DEBUG_RESULT, "some dependency problem\n");
575 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
576 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s is not installable\n", pool_solvid2str(pool, source));
578 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
579 POOL_DEBUG(SOLV_DEBUG_RESULT, "nothing provides %s needed by %s\n", pool_dep2str(pool, dep), pool_solvid2str(pool, source));
581 case SOLVER_RULE_RPM_SAME_NAME:
582 POOL_DEBUG(SOLV_DEBUG_RESULT, "cannot install both %s and %s\n", pool_solvid2str(pool, source), pool_solvid2str(pool, target));
584 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
585 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep), pool_solvid2str(pool, target));
587 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
588 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep), pool_solvid2str(pool, target));
590 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
591 POOL_DEBUG(SOLV_DEBUG_RESULT, "installed package %s obsoletes %s provided by %s\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep), pool_solvid2str(pool, target));
593 case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
594 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s implicitly obsoletes %s provided by %s\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep), pool_solvid2str(pool, target));
596 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
597 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep));
599 case SOLVER_RULE_RPM_SELF_CONFLICT:
600 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep));
602 case SOLVER_RULE_UNKNOWN:
603 case SOLVER_RULE_FEATURE:
604 case SOLVER_RULE_LEARNT:
605 case SOLVER_RULE_CHOICE:
606 case SOLVER_RULE_BEST:
607 POOL_DEBUG(SOLV_DEBUG_RESULT, "bad rule type\n");
613 solver_printprobleminfo(Solver *solv, Id problem)
615 solver_printproblemruleinfo(solv, solver_findproblemrule(solv, problem));
619 solver_printcompleteprobleminfo(Solver *solv, Id problem)
626 solver_findallproblemrules(solv, problem, &q);
627 for (i = 0; i < q.count; i++)
629 probr = q.elements[i];
630 if (!(probr >= solv->updaterules && probr < solv->updaterules_end) && !(probr >= solv->jobrules && probr < solv->jobrules_end))
636 for (i = 0; i < q.count; i++)
638 probr = q.elements[i];
639 if (nobad && ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end)))
641 solver_printproblemruleinfo(solv, probr);
647 solver_printsolution(Solver *solv, Id problem, Id solution)
649 Pool *pool = solv->pool;
650 Id p, rp, element, how, what, select;
654 while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
656 if (p == SOLVER_SOLUTION_JOB)
658 /* job, rp is index into job queue */
659 how = solv->job.elements[rp - 1];
660 what = solv->job.elements[rp];
661 select = how & SOLVER_SELECTMASK;
662 switch (how & SOLVER_JOBMASK)
665 if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
666 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not keep %s installed\n", pool_solvid2str(pool, what));
667 else if (select == SOLVER_SOLVABLE_PROVIDES)
668 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install a solvable %s\n", solver_select2str(pool, select, what));
670 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install %s\n", solver_select2str(pool, select, what));
673 if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
674 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not forbid installation of %s\n", pool_solvid2str(pool, what));
675 else if (select == SOLVER_SOLVABLE_PROVIDES)
676 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not deinstall all solvables %s\n", solver_select2str(pool, select, what));
678 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not deinstall %s\n", solver_select2str(pool, select, what));
681 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install most recent version of %s\n", solver_select2str(pool, select, what));
684 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not lock %s\n", solver_select2str(pool, select, what));
687 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do something different\n");
691 else if (p == SOLVER_SOLUTION_INFARCH)
693 s = pool->solvables + rp;
694 if (solv->installed && s->repo == solv->installed)
695 POOL_DEBUG(SOLV_DEBUG_RESULT, " - keep %s despite the inferior architecture\n", pool_solvable2str(pool, s));
697 POOL_DEBUG(SOLV_DEBUG_RESULT, " - install %s despite the inferior architecture\n", pool_solvable2str(pool, s));
699 else if (p == SOLVER_SOLUTION_DISTUPGRADE)
701 s = pool->solvables + rp;
702 if (solv->installed && s->repo == solv->installed)
703 POOL_DEBUG(SOLV_DEBUG_RESULT, " - keep obsolete %s\n", pool_solvable2str(pool, s));
705 POOL_DEBUG(SOLV_DEBUG_RESULT, " - install %s from excluded repository\n", pool_solvable2str(pool, s));
707 else if (p == SOLVER_SOLUTION_BEST)
709 s = pool->solvables + rp;
710 if (solv->installed && s->repo == solv->installed)
711 POOL_DEBUG(SOLV_DEBUG_RESULT, " - keep old %s\n", pool_solvable2str(pool, s));
713 POOL_DEBUG(SOLV_DEBUG_RESULT, " - install %s despite the old version\n", pool_solvable2str(pool, s));
717 /* policy, replace p with rp */
718 s = pool->solvables + p;
719 sd = rp ? pool->solvables + rp : 0;
722 int illegal = policy_is_illegal(solv, s, sd, 0);
723 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
724 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow downgrade of %s to %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
725 if ((illegal & POLICY_ILLEGAL_NAMECHANGE) != 0)
726 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow name change of %s to %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
727 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
728 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow architecture change of %s to %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
729 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
732 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow vendor change from '%s' (%s) to '%s' (%s)\n", pool_id2str(pool, s->vendor), pool_solvable2str(pool, s), pool_id2str(pool, sd->vendor), pool_solvable2str(pool, sd));
734 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow vendor change from '%s' (%s) to no vendor (%s)\n", pool_id2str(pool, s->vendor), pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
737 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow replacement of %s with %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
741 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow deinstallation of %s\n", pool_solvable2str(pool, s));
748 solver_printallsolutions(Solver *solv)
750 Pool *pool = solv->pool;
752 Id problem, solution;
754 POOL_DEBUG(SOLV_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
757 while ((problem = solver_next_problem(solv, problem)) != 0)
760 POOL_DEBUG(SOLV_DEBUG_RESULT, "Problem %d:\n", pcnt);
761 POOL_DEBUG(SOLV_DEBUG_RESULT, "====================================\n");
763 solver_printprobleminfo(solv, problem);
765 solver_printcompleteprobleminfo(solv, problem);
767 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
769 while ((solution = solver_next_solution(solv, problem, solution)) != 0)
771 solver_printsolution(solv, problem, solution);
772 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
778 solver_printtrivial(Solver *solv)
780 Pool *pool = solv->pool;
788 for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
790 n = pool_id2str(pool, s->name);
791 if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
801 solver_trivial_installable(solv, &in, &out);
802 POOL_DEBUG(SOLV_DEBUG_RESULT, "trivial installable status:\n");
803 for (i = 0; i < in.count; i++)
804 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s: %d\n", pool_solvid2str(pool, in.elements[i]), out.elements[i]);
805 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
811 solver_select2str(Pool *pool, Id select, Id what)
815 select &= SOLVER_SELECTMASK;
816 if (select == SOLVER_SOLVABLE)
817 return pool_solvid2str(pool, what);
818 if (select == SOLVER_SOLVABLE_NAME)
819 return pool_dep2str(pool, what);
820 if (select == SOLVER_SOLVABLE_PROVIDES)
822 s = pool_dep2str(pool, what);
823 b = pool_alloctmpspace(pool, 11 + strlen(s));
824 sprintf(b, "providing %s", s);
827 if (select == SOLVER_SOLVABLE_ONE_OF)
831 while ((p = pool->whatprovidesdata[what++]) != 0)
833 s = pool_solvid2str(pool, p);
835 b = pool_tmpappend(pool, b, ", ", s);
837 b = pool_tmpjoin(pool, s, 0, 0);
838 pool_freetmpspace(pool, s);
840 return b ? b : "nothing";
842 if (select == SOLVER_SOLVABLE_REPO)
844 b = pool_alloctmpspace(pool, 20);
845 sprintf(b, "repo #%d", what);
848 if (select == SOLVER_SOLVABLE_ALL)
849 return "all packages";
850 return "unknown job select";
854 pool_job2str(Pool *pool, Id how, Id what, Id flagmask)
856 Id select = how & SOLVER_SELECTMASK;
857 const char *strstart = 0, *strend = 0;
861 switch (how & SOLVER_JOBMASK)
866 if (select == SOLVER_SOLVABLE && pool->installed && pool->solvables[what].repo == pool->installed)
867 strstart = "keep ", strend = "installed";
868 else if (select == SOLVER_SOLVABLE || select == SOLVER_SOLVABLE_NAME)
869 strstart = "install ";
870 else if (select == SOLVER_SOLVABLE_PROVIDES)
871 strstart = "install a package ";
873 strstart = "install one of ";
876 if (select == SOLVER_SOLVABLE && !(pool->installed && pool->solvables[what].repo == pool->installed))
877 strstart = "keep ", strend = "unstalled";
878 else if (select == SOLVER_SOLVABLE_PROVIDES)
879 strstart = "deinstall all packages ";
881 strstart = "deinstall ";
884 strstart = "update ";
886 case SOLVER_WEAKENDEPS:
887 strstart = "weaken deps of ";
889 case SOLVER_NOOBSOLETES:
890 strstart = "multi version ";
893 strstart = "update ";
895 case SOLVER_DISTUPGRADE:
896 strstart = "dist upgrade ";
899 strstart = "verify ";
901 case SOLVER_DROP_ORPHANED:
902 strstart = "deinstall ", strend = "if orphaned";
904 case SOLVER_USERINSTALLED:
905 strstart = "regard ", strend = "as userinstalled";
908 strstart = "unknown job ";
911 s = pool_tmpjoin(pool, strstart, solver_select2str(pool, select, what), strend);
913 if ((how & ~(SOLVER_SELECTMASK|SOLVER_JOBMASK)) == 0)
916 s = pool_tmpappend(pool, s, " ", 0);
917 if (how & SOLVER_WEAK)
918 s = pool_tmpappend(pool, s, ",weak", 0);
919 if (how & SOLVER_ESSENTIAL)
920 s = pool_tmpappend(pool, s, ",essential", 0);
921 if (how & SOLVER_CLEANDEPS)
922 s = pool_tmpappend(pool, s, ",cleandeps", 0);
923 if (how & SOLVER_SETEV)
924 s = pool_tmpappend(pool, s, ",setev", 0);
925 if (how & SOLVER_SETEVR)
926 s = pool_tmpappend(pool, s, ",setevr", 0);
927 if (how & SOLVER_SETARCH)
928 s = pool_tmpappend(pool, s, ",setarch", 0);
929 if (how & SOLVER_SETVENDOR)
930 s = pool_tmpappend(pool, s, ",setvendor", 0);
931 if (how & SOLVER_SETREPO)
932 s = pool_tmpappend(pool, s, ",setrepo", 0);
933 if (how & SOLVER_NOAUTOSET)
934 s = pool_tmpappend(pool, s, ",noautoset", 0);
936 s = pool_tmpappend(pool, s, ",?", 0);
938 return pool_tmpappend(pool, s, "]", 0);
942 pool_selection2str(Pool *pool, Queue *selection, Id flagmask)
947 s = pool_tmpjoin(pool, 0, 0, 0);
948 for (i = 0; i < selection->count; i += 2)
950 Id how = selection->elements[i];
952 s = pool_tmpappend(pool, s, " + ", 0);
953 s2 = solver_select2str(pool, how & SOLVER_SELECTMASK, selection->elements[i + 1]);
954 s = pool_tmpappend(pool, s, s2, 0);
955 pool_freetmpspace(pool, s2);
956 how &= flagmask & SOLVER_SETMASK;
960 s = pool_tmpappend(pool, s, " ", 0);
961 if (how & SOLVER_SETEV)
962 s = pool_tmpappend(pool, s, ",setev", 0);
963 if (how & SOLVER_SETEVR)
964 s = pool_tmpappend(pool, s, ",setevr", 0);
965 if (how & SOLVER_SETARCH)
966 s = pool_tmpappend(pool, s, ",setarch", 0);
967 if (how & SOLVER_SETVENDOR)
968 s = pool_tmpappend(pool, s, ",setvendor", 0);
969 if (how & SOLVER_SETREPO)
970 s = pool_tmpappend(pool, s, ",setrepo", 0);
971 if (how & SOLVER_NOAUTOSET)
972 s = pool_tmpappend(pool, s, ",noautoset", 0);
974 s = pool_tmpappend(pool, s, ",?", 0);
976 s = pool_tmpappend(pool, s, "]", 0);
983 solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id target, Id dep)
985 Pool *pool = solv->pool;
989 case SOLVER_RULE_DISTUPGRADE:
990 return pool_tmpjoin(pool, pool_solvid2str(pool, source), " does not belong to a distupgrade repository", 0);
991 case SOLVER_RULE_INFARCH:
992 return pool_tmpjoin(pool, pool_solvid2str(pool, source), " has inferior architecture", 0);
993 case SOLVER_RULE_UPDATE:
994 return pool_tmpjoin(pool, "problem with installed package ", pool_solvid2str(pool, source), 0);
995 case SOLVER_RULE_JOB:
996 return "conflicting requests";
997 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
998 return pool_tmpjoin(pool, "nothing provides requested ", pool_dep2str(pool, dep), 0);
999 case SOLVER_RULE_RPM:
1000 return "some dependency problem";
1001 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
1002 return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " is not installable");
1003 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
1004 s = pool_tmpjoin(pool, "nothing provides ", pool_dep2str(pool, dep), 0);
1005 return pool_tmpappend(pool, s, " needed by ", pool_solvid2str(pool, source));
1006 case SOLVER_RULE_RPM_SAME_NAME:
1007 s = pool_tmpjoin(pool, "cannot install both ", pool_solvid2str(pool, source), 0);
1008 return pool_tmpappend(pool, s, " and ", pool_solvid2str(pool, target));
1009 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
1010 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
1011 s = pool_tmpappend(pool, s, " conflicts with ", pool_dep2str(pool, dep));
1012 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
1013 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
1014 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
1015 s = pool_tmpappend(pool, s, " obsoletes ", pool_dep2str(pool, dep));
1016 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
1017 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
1018 s = pool_tmpjoin(pool, "installed package ", pool_solvid2str(pool, source), 0);
1019 s = pool_tmpappend(pool, s, " obsoletes ", pool_dep2str(pool, dep));
1020 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
1021 case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
1022 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
1023 s = pool_tmpappend(pool, s, " implicitly obsoletes ", pool_dep2str(pool, dep));
1024 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
1025 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
1026 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " requires ");
1027 return pool_tmpappend(pool, s, pool_dep2str(pool, dep), ", but none of the providers can be installed");
1028 case SOLVER_RULE_RPM_SELF_CONFLICT:
1029 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " conflicts with ");
1030 return pool_tmpappend(pool, s, pool_dep2str(pool, dep), " provided by itself");
1032 return "bad problem rule type";
1037 solver_solutionelement2str(Solver *solv, Id p, Id rp)
1039 Pool *pool = solv->pool;
1040 if (p == SOLVER_SOLUTION_JOB)
1042 Id how = solv->job.elements[rp - 1];
1043 Id what = solv->job.elements[rp];
1044 return pool_tmpjoin(pool, "do not ask to ", pool_job2str(pool, how, what, 0), 0);
1046 else if (p == SOLVER_SOLUTION_INFARCH)
1048 Solvable *s = pool->solvables + rp;
1049 if (solv->installed && s->repo == solv->installed)
1050 return pool_tmpjoin(pool, "keep ", pool_solvable2str(pool, s), " despite the inferior architecture");
1052 return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the inferior architecture");
1054 else if (p == SOLVER_SOLUTION_DISTUPGRADE)
1056 Solvable *s = pool->solvables + rp;
1057 if (solv->installed && s->repo == solv->installed)
1058 return pool_tmpjoin(pool, "keep obsolete ", pool_solvable2str(pool, s), 0);
1060 return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " from excluded repository");
1062 else if (p == SOLVER_SOLUTION_BEST)
1064 Solvable *s = pool->solvables + rp;
1065 if (solv->installed && s->repo == solv->installed)
1066 return pool_tmpjoin(pool, "keep old ", pool_solvable2str(pool, s), 0);
1068 return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the old version");
1070 else if (p > 0 && rp == 0)
1071 return pool_tmpjoin(pool, "allow deinstallation of ", pool_solvid2str(pool, p), 0);
1072 else if (p > 0 && rp > 0)
1074 const char *sp = pool_solvid2str(pool, p);
1075 const char *srp = pool_solvid2str(pool, rp);
1076 const char *str = pool_tmpjoin(pool, "allow replacement of ", sp, 0);
1077 return pool_tmpappend(pool, str, " with ", srp);
1080 return "bad solution element";
1084 policy_illegal2str(Solver *solv, int illegal, Solvable *s, Solvable *rs)
1086 Pool *pool = solv->pool;
1088 if (illegal == POLICY_ILLEGAL_DOWNGRADE)
1090 str = pool_tmpjoin(pool, "downgrade of ", pool_solvable2str(pool, s), 0);
1091 return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1093 if (illegal == POLICY_ILLEGAL_NAMECHANGE)
1095 str = pool_tmpjoin(pool, "name change of ", pool_solvable2str(pool, s), 0);
1096 return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1098 if (illegal == POLICY_ILLEGAL_ARCHCHANGE)
1100 str = pool_tmpjoin(pool, "architecture change of ", pool_solvable2str(pool, s), 0);
1101 return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1103 if (illegal == POLICY_ILLEGAL_VENDORCHANGE)
1105 str = pool_tmpjoin(pool, "vendor change from '", pool_id2str(pool, s->vendor), "' (");
1108 str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to '");
1109 str = pool_tmpappend(pool, str, pool_id2str(pool, rs->vendor), "' (");
1112 str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to no vendor (");
1113 return pool_tmpappend(pool, str, pool_solvable2str(pool, rs), ")");
1115 return "unknown illegal change";