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->choicerules && p < solv->choicerules_end)
210 POOL_DEBUG(type, "CHOICE ");
211 else if (p >= solv->infarchrules && p < solv->infarchrules_end)
212 POOL_DEBUG(type, "INFARCH ");
213 else if (p >= solv->duprules && p < solv->duprules_end)
214 POOL_DEBUG(type, "DUP ");
215 else if (p >= solv->jobrules && p < solv->jobrules_end)
216 POOL_DEBUG(type, "JOB ");
217 else if (p >= solv->updaterules && p < solv->updaterules_end)
218 POOL_DEBUG(type, "UPDATE ");
219 else if (p >= solv->featurerules && p < solv->featurerules_end)
220 POOL_DEBUG(type, "FEATURE ");
221 solver_printrule(solv, type, r);
225 solver_printproblem(Solver *solv, Id v)
227 Pool *pool = solv->pool;
233 solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, solv->rules + v);
237 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "JOB %d\n", v);
238 jp = solv->ruletojob.elements;
239 for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
242 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "- ");
243 solver_printrule(solv, SOLV_DEBUG_SOLUTIONS, r);
245 POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "ENDJOB\n");
250 solver_printwatches(Solver *solv, int type)
252 Pool *pool = solv->pool;
255 POOL_DEBUG(type, "Watches: \n");
256 for (counter = -(pool->nsolvables - 1); counter < pool->nsolvables; counter++)
257 POOL_DEBUG(type, " solvable [%d] -- rule [%d]\n", counter, solv->watches[counter + pool->nsolvables]);
261 solver_printdecisionq(Solver *solv, int type)
263 Pool *pool = solv->pool;
267 POOL_DEBUG(type, "Decisions:\n");
268 for (i = 0; i < solv->decisionq.count; i++)
270 p = solv->decisionq.elements[i];
272 POOL_DEBUG(type, "%d %d install %s, ", i, solv->decisionmap[p], pool_solvid2str(pool, p));
274 POOL_DEBUG(type, "%d %d conflict %s, ", i, -solv->decisionmap[-p], pool_solvid2str(pool, -p));
275 why = solv->decisionq_why.elements[i];
278 POOL_DEBUG(type, "forced by ");
279 solver_printruleclass(solv, type, solv->rules + why);
283 POOL_DEBUG(type, "chosen from ");
284 solver_printruleclass(solv, type, solv->rules - why);
287 POOL_DEBUG(type, "picked for some unknown reason.\n");
296 solver_printdecisions(Solver *solv)
298 Pool *pool = solv->pool;
299 Repo *installed = solv->installed;
300 Transaction *trans = solver_create_transaction(solv);
306 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
307 POOL_DEBUG(SOLV_DEBUG_RESULT, "transaction:\n");
310 for (i = 0; i < trans->steps.count; i++)
312 p = trans->steps.elements[i];
313 s = pool->solvables + p;
314 type = transaction_type(trans, p, SOLVER_TRANSACTION_SHOW_ACTIVE|SOLVER_TRANSACTION_SHOW_ALL|SOLVER_TRANSACTION_SHOW_OBSOLETES|SOLVER_TRANSACTION_SHOW_MULTIINSTALL);
317 case SOLVER_TRANSACTION_MULTIINSTALL:
318 POOL_DEBUG(SOLV_DEBUG_RESULT, " multi install %s", pool_solvable2str(pool, s));
320 case SOLVER_TRANSACTION_MULTIREINSTALL:
321 POOL_DEBUG(SOLV_DEBUG_RESULT, " multi reinstall %s", pool_solvable2str(pool, s));
323 case SOLVER_TRANSACTION_INSTALL:
324 POOL_DEBUG(SOLV_DEBUG_RESULT, " install %s", pool_solvable2str(pool, s));
326 case SOLVER_TRANSACTION_REINSTALL:
327 POOL_DEBUG(SOLV_DEBUG_RESULT, " reinstall %s", pool_solvable2str(pool, s));
329 case SOLVER_TRANSACTION_DOWNGRADE:
330 POOL_DEBUG(SOLV_DEBUG_RESULT, " downgrade %s", pool_solvable2str(pool, s));
332 case SOLVER_TRANSACTION_CHANGE:
333 POOL_DEBUG(SOLV_DEBUG_RESULT, " change %s", pool_solvable2str(pool, s));
335 case SOLVER_TRANSACTION_UPGRADE:
336 case SOLVER_TRANSACTION_OBSOLETES:
337 POOL_DEBUG(SOLV_DEBUG_RESULT, " upgrade %s", pool_solvable2str(pool, s));
339 case SOLVER_TRANSACTION_ERASE:
340 POOL_DEBUG(SOLV_DEBUG_RESULT, " erase %s", pool_solvable2str(pool, s));
347 case SOLVER_TRANSACTION_INSTALL:
348 case SOLVER_TRANSACTION_ERASE:
349 case SOLVER_TRANSACTION_MULTIINSTALL:
350 case SOLVER_TRANSACTION_MULTIREINSTALL:
351 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
353 case SOLVER_TRANSACTION_REINSTALL:
354 case SOLVER_TRANSACTION_DOWNGRADE:
355 case SOLVER_TRANSACTION_CHANGE:
356 case SOLVER_TRANSACTION_UPGRADE:
357 case SOLVER_TRANSACTION_OBSOLETES:
358 transaction_all_obs_pkgs(trans, p, &iq);
361 POOL_DEBUG(SOLV_DEBUG_RESULT, " (obsoletes");
362 for (j = 0; j < iq.count; j++)
363 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s", pool_solvid2str(pool, iq.elements[j]));
364 POOL_DEBUG(SOLV_DEBUG_RESULT, ")");
366 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
374 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
376 if (solv->recommendations.count)
378 POOL_DEBUG(SOLV_DEBUG_RESULT, "recommended packages:\n");
379 for (i = 0; i < solv->recommendations.count; i++)
381 s = pool->solvables + solv->recommendations.elements[i];
382 if (solv->decisionmap[solv->recommendations.elements[i]] > 0)
384 if (installed && s->repo == installed)
385 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (installed)\n", pool_solvable2str(pool, s));
387 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (selected)\n", pool_solvable2str(pool, s));
390 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", pool_solvable2str(pool, s));
392 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
395 if (solv->suggestions.count)
397 POOL_DEBUG(SOLV_DEBUG_RESULT, "suggested packages:\n");
398 for (i = 0; i < solv->suggestions.count; i++)
400 s = pool->solvables + solv->suggestions.elements[i];
401 if (solv->decisionmap[solv->suggestions.elements[i]] > 0)
403 if (installed && s->repo == installed)
404 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (installed)\n", pool_solvable2str(pool, s));
406 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (selected)\n", pool_solvable2str(pool, s));
409 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", pool_solvable2str(pool, s));
411 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
413 if (solv->orphaned.count)
415 POOL_DEBUG(SOLV_DEBUG_RESULT, "orphaned packages:\n");
416 for (i = 0; i < solv->orphaned.count; i++)
418 s = pool->solvables + solv->orphaned.elements[i];
419 if (solv->decisionmap[solv->orphaned.elements[i]] > 0)
420 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (kept)\n", pool_solvable2str(pool, s));
422 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s (erased)\n", pool_solvable2str(pool, s));
424 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
426 transaction_free(trans);
430 const char *id2strnone(Pool *pool, Id id)
432 return !id || id == 1 ? "(none)" : pool_id2str(pool, id);
436 transaction_print(Transaction *trans)
438 Pool *pool = trans->pool;
440 int i, j, mode, l, linel;
444 queue_init(&classes);
447 transaction_classify(trans, mode, &classes);
448 for (i = 0; i < classes.count; i += 4)
450 Id class = classes.elements[i];
451 Id cnt = classes.elements[i + 1];
454 case SOLVER_TRANSACTION_ERASE:
455 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d erased packages:\n", cnt);
457 case SOLVER_TRANSACTION_INSTALL:
458 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d installed packages:\n", cnt);
460 case SOLVER_TRANSACTION_REINSTALLED:
461 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d reinstalled packages:\n", cnt);
463 case SOLVER_TRANSACTION_DOWNGRADED:
464 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d downgraded packages:\n", cnt);
466 case SOLVER_TRANSACTION_CHANGED:
467 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d changed packages:\n", cnt);
469 case SOLVER_TRANSACTION_UPGRADED:
470 POOL_DEBUG(SOLV_DEBUG_RESULT, "%d upgraded packages:\n", cnt);
472 case SOLVER_TRANSACTION_VENDORCHANGE:
473 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]));
475 case SOLVER_TRANSACTION_ARCHCHANGE:
476 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]));
479 class = SOLVER_TRANSACTION_IGNORE;
482 if (class == SOLVER_TRANSACTION_IGNORE)
484 transaction_classify_pkgs(trans, mode, class, classes.elements[i + 2], classes.elements[i + 3], &pkgs);
487 for (j = 0; j < pkgs.count; j++)
489 Id p = pkgs.elements[j];
490 Solvable *s = pool->solvables + p;
495 case SOLVER_TRANSACTION_DOWNGRADED:
496 case SOLVER_TRANSACTION_UPGRADED:
497 s2 = pool->solvables + transaction_obs_pkg(trans, p);
498 POOL_DEBUG(SOLV_DEBUG_RESULT, " - %s -> %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, s2));
500 case SOLVER_TRANSACTION_VENDORCHANGE:
501 case SOLVER_TRANSACTION_ARCHCHANGE:
502 n = pool_id2str(pool, s->name);
504 if (l + linel > sizeof(line) - 3)
507 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", line);
511 if (l + linel > sizeof(line) - 3)
512 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", n);
517 strcpy(line + linel, ", ");
520 strcpy(line + linel, n);
525 POOL_DEBUG(SOLV_DEBUG_RESULT, " - %s\n", pool_solvable2str(pool, s));
530 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s\n", line);
531 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
533 queue_free(&classes);
538 solver_printproblemruleinfo(Solver *solv, Id probr)
540 Pool *pool = solv->pool;
541 Id dep, source, target;
543 switch (solver_ruleinfo(solv, probr, &source, &target, &dep))
545 case SOLVER_RULE_DISTUPGRADE:
546 POOL_DEBUG(SOLV_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", pool_solvid2str(pool, source));
548 case SOLVER_RULE_INFARCH:
549 POOL_DEBUG(SOLV_DEBUG_RESULT, "%s has inferior architecture\n", pool_solvid2str(pool, source));
551 case SOLVER_RULE_UPDATE:
552 POOL_DEBUG(SOLV_DEBUG_RESULT, "problem with installed package %s\n", pool_solvid2str(pool, source));
554 case SOLVER_RULE_JOB:
555 POOL_DEBUG(SOLV_DEBUG_RESULT, "conflicting requests\n");
557 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
558 POOL_DEBUG(SOLV_DEBUG_RESULT, "nothing provides requested %s\n", pool_dep2str(pool, dep));
560 case SOLVER_RULE_RPM:
561 POOL_DEBUG(SOLV_DEBUG_RESULT, "some dependency problem\n");
563 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
564 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s is not installable\n", pool_solvid2str(pool, source));
566 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
567 POOL_DEBUG(SOLV_DEBUG_RESULT, "nothing provides %s needed by %s\n", pool_dep2str(pool, dep), pool_solvid2str(pool, source));
569 case SOLVER_RULE_RPM_SAME_NAME:
570 POOL_DEBUG(SOLV_DEBUG_RESULT, "cannot install both %s and %s\n", pool_solvid2str(pool, source), pool_solvid2str(pool, target));
572 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
573 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));
575 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
576 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));
578 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
579 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));
581 case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
582 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s implicitely obsoletes %s provided by %s\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep), pool_solvid2str(pool, target));
584 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
585 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));
587 case SOLVER_RULE_RPM_SELF_CONFLICT:
588 POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", pool_solvid2str(pool, source), pool_dep2str(pool, dep));
590 case SOLVER_RULE_UNKNOWN:
591 case SOLVER_RULE_FEATURE:
592 case SOLVER_RULE_LEARNT:
593 case SOLVER_RULE_CHOICE:
594 POOL_DEBUG(SOLV_DEBUG_RESULT, "bad rule type\n");
600 solver_printprobleminfo(Solver *solv, Id problem)
602 solver_printproblemruleinfo(solv, solver_findproblemrule(solv, problem));
606 solver_printcompleteprobleminfo(Solver *solv, Id problem)
613 solver_findallproblemrules(solv, problem, &q);
614 for (i = 0; i < q.count; i++)
616 probr = q.elements[i];
617 if (!(probr >= solv->updaterules && probr < solv->updaterules_end) && !(probr >= solv->jobrules && probr < solv->jobrules_end))
623 for (i = 0; i < q.count; i++)
625 probr = q.elements[i];
626 if (nobad && ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end)))
628 solver_printproblemruleinfo(solv, probr);
634 solver_printsolution(Solver *solv, Id problem, Id solution)
636 Pool *pool = solv->pool;
637 Id p, rp, element, how, what, select;
641 while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
643 if (p == SOLVER_SOLUTION_JOB)
645 /* job, rp is index into job queue */
646 how = solv->job.elements[rp - 1];
647 what = solv->job.elements[rp];
648 select = how & SOLVER_SELECTMASK;
649 switch (how & SOLVER_JOBMASK)
652 if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
653 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not keep %s installed\n", pool_solvid2str(pool, what));
654 else if (select == SOLVER_SOLVABLE_PROVIDES)
655 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install a solvable %s\n", solver_select2str(pool, select, what));
657 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install %s\n", solver_select2str(pool, select, what));
660 if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
661 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not forbid installation of %s\n", pool_solvid2str(pool, what));
662 else if (select == SOLVER_SOLVABLE_PROVIDES)
663 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not deinstall all solvables %s\n", solver_select2str(pool, select, what));
665 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not deinstall %s\n", solver_select2str(pool, select, what));
668 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not install most recent version of %s\n", solver_select2str(pool, select, what));
671 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do not lock %s\n", solver_select2str(pool, select, what));
674 POOL_DEBUG(SOLV_DEBUG_RESULT, " - do something different\n");
678 else if (p == SOLVER_SOLUTION_INFARCH)
680 s = pool->solvables + rp;
681 if (solv->installed && s->repo == solv->installed)
682 POOL_DEBUG(SOLV_DEBUG_RESULT, " - keep %s despite the inferior architecture\n", pool_solvable2str(pool, s));
684 POOL_DEBUG(SOLV_DEBUG_RESULT, " - install %s despite the inferior architecture\n", pool_solvable2str(pool, s));
686 else if (p == SOLVER_SOLUTION_DISTUPGRADE)
688 s = pool->solvables + rp;
689 if (solv->installed && s->repo == solv->installed)
690 POOL_DEBUG(SOLV_DEBUG_RESULT, " - keep obsolete %s\n", pool_solvable2str(pool, s));
692 POOL_DEBUG(SOLV_DEBUG_RESULT, " - install %s from excluded repository\n", pool_solvable2str(pool, s));
696 /* policy, replace p with rp */
697 s = pool->solvables + p;
698 sd = rp ? pool->solvables + rp : 0;
701 int illegal = policy_is_illegal(solv, s, sd, 0);
702 if ((illegal & POLICY_ILLEGAL_DOWNGRADE) != 0)
703 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow downgrade of %s to %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
704 if ((illegal & POLICY_ILLEGAL_ARCHCHANGE) != 0)
705 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow architecture change of %s to %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
706 if ((illegal & POLICY_ILLEGAL_VENDORCHANGE) != 0)
709 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));
711 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));
714 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow replacement of %s with %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
718 POOL_DEBUG(SOLV_DEBUG_RESULT, " - allow deinstallation of %s\n", pool_solvable2str(pool, s));
725 solver_printallsolutions(Solver *solv)
727 Pool *pool = solv->pool;
729 Id problem, solution;
731 POOL_DEBUG(SOLV_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
734 while ((problem = solver_next_problem(solv, problem)) != 0)
737 POOL_DEBUG(SOLV_DEBUG_RESULT, "Problem %d:\n", pcnt);
738 POOL_DEBUG(SOLV_DEBUG_RESULT, "====================================\n");
740 solver_printprobleminfo(solv, problem);
742 solver_printcompleteprobleminfo(solv, problem);
744 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
746 while ((solution = solver_next_solution(solv, problem, solution)) != 0)
748 solver_printsolution(solv, problem, solution);
749 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
755 solver_printtrivial(Solver *solv)
757 Pool *pool = solv->pool;
765 for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
767 n = pool_id2str(pool, s->name);
768 if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
778 solver_trivial_installable(solv, &in, &out);
779 POOL_DEBUG(SOLV_DEBUG_RESULT, "trivial installable status:\n");
780 for (i = 0; i < in.count; i++)
781 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s: %d\n", pool_solvid2str(pool, in.elements[i]), out.elements[i]);
782 POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
788 solver_select2str(Pool *pool, Id select, Id what)
792 if (select == SOLVER_SOLVABLE)
793 return pool_solvid2str(pool, what);
794 if (select == SOLVER_SOLVABLE_NAME)
795 return pool_dep2str(pool, what);
796 if (select == SOLVER_SOLVABLE_PROVIDES)
798 s = pool_dep2str(pool, what);
799 b = pool_alloctmpspace(pool, 11 + strlen(s));
800 sprintf(b, "providing %s", s);
803 if (select == SOLVER_SOLVABLE_ONE_OF)
807 while ((p = pool->whatprovidesdata[what++]) != 0)
809 s = pool_solvid2str(pool, p);
811 b = pool_tmpappend(pool, b, ", ", s);
813 b = pool_tmpjoin(pool, s, 0, 0);
814 pool_freetmpspace(pool, s);
816 return b ? b : "nothing";
818 if (select == SOLVER_SOLVABLE_REPO)
820 b = pool_alloctmpspace(pool, 20);
821 sprintf(b, "repo #%d", what);
824 if (select == SOLVER_SOLVABLE_ALL)
825 return "all packages";
826 return "unknown job select";
830 pool_job2str(Pool *pool, Id how, Id what, Id flagmask)
832 Id select = how & SOLVER_SELECTMASK;
833 const char *strstart = 0, *strend = 0;
837 switch (how & SOLVER_JOBMASK)
842 if (select == SOLVER_SOLVABLE && pool->installed && pool->solvables[what].repo == pool->installed)
843 strstart = "keep ", strend = "installed";
844 else if (select == SOLVER_SOLVABLE || select == SOLVER_SOLVABLE_NAME)
845 strstart = "install ";
846 else if (select == SOLVER_SOLVABLE_PROVIDES)
847 strstart = "install a package ";
849 strstart = "install one of ";
852 if (select == SOLVER_SOLVABLE && !(pool->installed && pool->solvables[what].repo == pool->installed))
853 strstart = "keep ", strend = "unstalled";
854 else if (select == SOLVER_SOLVABLE_PROVIDES)
855 strstart = "deinstall all packages ";
857 strstart = "deinstall ";
860 strstart = "update ";
862 case SOLVER_WEAKENDEPS:
863 strstart = "weaken deps of ";
865 case SOLVER_NOOBSOLETES:
866 strstart = "multi version ";
869 strstart = "update ";
871 case SOLVER_DISTUPGRADE:
872 strstart = "dist upgrade ";
875 strstart = "verify ";
877 case SOLVER_DROP_ORPHANED:
878 strstart = "deinstall ", strend = "if orphaned";
880 case SOLVER_USERINSTALLED:
881 strstart = "regard ", strend = "as userinstalled";
884 strstart = "unknown job ";
887 s = pool_tmpjoin(pool, strstart, solver_select2str(pool, select, what), strend);
888 if ((how & flagmask & ~(SOLVER_SELECTMASK|SOLVER_JOBMASK)) == 0)
891 s = pool_tmpappend(pool, s, " ", 0);
892 if (how & SOLVER_WEAK)
893 s = pool_tmpappend(pool, s, ",weak", 0);
894 if (how & SOLVER_ESSENTIAL)
895 s = pool_tmpappend(pool, s, ",essential", 0);
896 if (how & SOLVER_CLEANDEPS)
897 s = pool_tmpappend(pool, s, ",cleandeps", 0);
898 if (how & SOLVER_SETEV)
899 s = pool_tmpappend(pool, s, ",setev", 0);
900 if (how & SOLVER_SETEVR)
901 s = pool_tmpappend(pool, s, ",setevr", 0);
902 if (how & SOLVER_SETARCH)
903 s = pool_tmpappend(pool, s, ",setarch", 0);
904 if (how & SOLVER_SETVENDOR)
905 s = pool_tmpappend(pool, s, ",setvendor", 0);
906 if (how & SOLVER_SETREPO)
907 s = pool_tmpappend(pool, s, ",setrepo", 0);
908 if (how & SOLVER_NOAUTOSET)
909 s = pool_tmpappend(pool, s, ",noautoset", 0);
911 s = pool_tmpappend(pool, s, ",?", 0);
913 return pool_tmpappend(pool, s, "]", 0);
917 solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id target, Id dep)
919 Pool *pool = solv->pool;
923 case SOLVER_RULE_DISTUPGRADE:
924 return pool_tmpjoin(pool, pool_solvid2str(pool, source), " does not belong to a distupgrade repository", 0);
925 case SOLVER_RULE_INFARCH:
926 return pool_tmpjoin(pool, pool_solvid2str(pool, source), " has inferior architecture", 0);
927 case SOLVER_RULE_UPDATE:
928 return pool_tmpjoin(pool, "problem with installed package ", pool_solvid2str(pool, source), 0);
929 case SOLVER_RULE_JOB:
930 return "conflicting requests";
931 case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
932 return pool_tmpjoin(pool, "nothing provides requested ", pool_dep2str(pool, dep), 0);
933 case SOLVER_RULE_RPM:
934 return "some dependency problem";
935 case SOLVER_RULE_RPM_NOT_INSTALLABLE:
936 return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " is not installable");
937 case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
938 s = pool_tmpjoin(pool, "nothing provides ", pool_dep2str(pool, dep), 0);
939 return pool_tmpappend(pool, s, " needed by ", pool_solvid2str(pool, source));
940 case SOLVER_RULE_RPM_SAME_NAME:
941 s = pool_tmpjoin(pool, "cannot install both ", pool_solvid2str(pool, source), 0);
942 return pool_tmpappend(pool, s, " and ", pool_solvid2str(pool, target));
943 case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
944 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
945 s = pool_tmpappend(pool, s, " conflicts with ", pool_dep2str(pool, dep));
946 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
947 case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
948 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
949 s = pool_tmpappend(pool, s, " obsoletes ", pool_dep2str(pool, dep));
950 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
951 case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
952 s = pool_tmpjoin(pool, "installed package ", pool_solvid2str(pool, source), 0);
953 s = pool_tmpappend(pool, s, " obsoletes ", pool_dep2str(pool, dep));
954 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
955 case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
956 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
957 s = pool_tmpappend(pool, s, " implicitely obsoletes ", pool_dep2str(pool, dep));
958 return pool_tmpappend(pool, s, " provided by ", pool_solvid2str(pool, target));
959 case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
960 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " requires ");
961 return pool_tmpappend(pool, s, pool_dep2str(pool, dep), ", but none of the providers can be installed");
962 case SOLVER_RULE_RPM_SELF_CONFLICT:
963 s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " conflicts with ");
964 return pool_tmpappend(pool, s, pool_dep2str(pool, dep), " provided by itself");
966 return "bad problem rule type";
971 solver_solutionelement2str(Solver *solv, Id p, Id rp)
973 Pool *pool = solv->pool;
974 if (p == SOLVER_SOLUTION_JOB)
976 Id how = solv->job.elements[rp - 1];
977 Id what = solv->job.elements[rp];
978 return pool_tmpjoin(pool, "do not ask to ", pool_job2str(pool, how, what, 0), 0);
980 else if (p == SOLVER_SOLUTION_INFARCH)
982 Solvable *s = pool->solvables + rp;
983 if (solv->installed && s->repo == solv->installed)
984 return pool_tmpjoin(pool, "keep ", pool_solvable2str(pool, s), " despite the inferior architecture");
986 return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the inferior architecture");
988 else if (p == SOLVER_SOLUTION_DISTUPGRADE)
990 Solvable *s = pool->solvables + rp;
991 if (solv->installed && s->repo == solv->installed)
992 return pool_tmpjoin(pool, "keep obsolete ", pool_solvable2str(pool, s), 0);
994 return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " from excluded repository");
996 else if (p > 0 && rp == 0)
997 return pool_tmpjoin(pool, "allow deinstallation of ", pool_solvid2str(pool, p), 0);
998 else if (p > 0 && rp > 0)
1000 const char *sp = pool_solvid2str(pool, p);
1001 const char *srp = pool_solvid2str(pool, rp);
1002 const char *str = pool_tmpjoin(pool, "allow replacement of ", sp, 0);
1003 return pool_tmpappend(pool, str, " with ", srp);
1006 return "bad solution element";
1010 policy_illegal2str(Solver *solv, int illegal, Solvable *s, Solvable *rs)
1012 Pool *pool = solv->pool;
1014 if (illegal == POLICY_ILLEGAL_DOWNGRADE)
1016 str = pool_tmpjoin(pool, "downgrade of ", pool_solvable2str(pool, s), 0);
1017 return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1019 if (illegal == POLICY_ILLEGAL_ARCHCHANGE)
1021 str = pool_tmpjoin(pool, "architecture change of ", pool_solvable2str(pool, s), 0);
1022 return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1024 if (illegal == POLICY_ILLEGAL_VENDORCHANGE)
1026 str = pool_tmpjoin(pool, "vendor change from '", pool_id2str(pool, s->vendor), "' (");
1029 str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to '");
1030 str = pool_tmpappend(pool, str, pool_id2str(pool, rs->vendor), "' (");
1033 str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to no vendor (");
1034 return pool_tmpappend(pool, str, pool_solvable2str(pool, rs), ")");
1036 return "unknown illegal change";