Already use LOCALPOOL when converting filelist/language extensions
[platform/upstream/libsolv.git] / src / solverdebug.c
1 /*
2  * Copyright (c) 2008, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * solverdebug.c
10  *
11  * debug functions for the SAT solver
12  */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <assert.h>
19
20 #include "solver.h"
21 #include "solver_private.h"
22 #include "solverdebug.h"
23 #include "bitmap.h"
24 #include "pool.h"
25 #include "poolarch.h"
26 #include "util.h"
27 #include "evr.h"
28 #include "policy.h"
29
30
31 /*
32  * create obsoletesmap from solver decisions
33  *
34  * for solvables in installed repo:
35  *   0 - not obsoleted
36  *   p - one of the packages that obsolete us
37  * for all others:
38  *   n - number of packages this package obsoletes
39  *
40  */
41
42 /* OBSOLETE: use transaction code instead! */
43
44 Id *
45 solver_create_decisions_obsoletesmap(Solver *solv)
46 {
47   Pool *pool = solv->pool;
48   Repo *installed = solv->installed;
49   Id p, *obsoletesmap = NULL;
50   int i;
51   Solvable *s;
52
53   obsoletesmap = (Id *)solv_calloc(pool->nsolvables, sizeof(Id));
54   if (installed)
55     {
56       for (i = 0; i < solv->decisionq.count; i++)
57         {
58           Id pp, n;
59           int noobs;
60
61           n = solv->decisionq.elements[i];
62           if (n < 0)
63             continue;
64           if (n == SYSTEMSOLVABLE)
65             continue;
66           s = pool->solvables + n;
67           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
68             continue;
69           noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
70           FOR_PROVIDES(p, pp, s->name)
71             {
72               Solvable *ps = pool->solvables + p;
73               if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
74                 continue;
75               if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
76                 continue;
77               if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
78                 continue;
79               if (ps->repo == installed && !obsoletesmap[p])
80                 {
81                   obsoletesmap[p] = n;
82                   obsoletesmap[n]++;
83                 }
84             }
85         }
86       for (i = 0; i < solv->decisionq.count; i++)
87         {
88           Id obs, *obsp;
89           Id pp, n;
90
91           n = solv->decisionq.elements[i];
92           if (n < 0)
93             continue;
94           if (n == SYSTEMSOLVABLE)
95             continue;
96           s = pool->solvables + n;
97           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
98             continue;
99           if (!s->obsoletes)
100             continue;
101           if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n))
102             continue;
103           obsp = s->repo->idarraydata + s->obsoletes;
104           while ((obs = *obsp++) != 0)
105             {
106               FOR_PROVIDES(p, pp, obs)
107                 {
108                   Solvable *ps = pool->solvables + p;
109                   if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
110                     continue;
111                   if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
112                     continue;
113                   if (pool->solvables[p].repo == installed && !obsoletesmap[p])
114                     {
115                       obsoletesmap[p] = n;
116                       obsoletesmap[n]++;
117                     }
118                 }
119             }
120         }
121     }
122   return obsoletesmap;
123 }
124
125 void
126 solver_printruleelement(Solver *solv, int type, Rule *r, Id v)
127 {
128   Pool *pool = solv->pool;
129   Solvable *s;
130   if (v < 0)
131     {
132       s = pool->solvables + -v;
133       POOL_DEBUG(type, "    !%s [%d]", pool_solvable2str(pool, s), -v);
134     }
135   else
136     {
137       s = pool->solvables + v;
138       POOL_DEBUG(type, "    %s [%d]", pool_solvable2str(pool, s), v);
139     }
140   if (pool->installed && s->repo == pool->installed)
141     POOL_DEBUG(type, "I");
142   if (r)
143     {
144       if (r->w1 == v)
145         POOL_DEBUG(type, " (w1)");
146       if (r->w2 == v)
147         POOL_DEBUG(type, " (w2)");
148     }
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");
154 }
155
156
157 /*
158  * print rule
159  */
160
161 void
162 solver_printrule(Solver *solv, int type, Rule *r)
163 {
164   Pool *pool = solv->pool;
165   int i;
166   Id d, v;
167
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));
170   else
171     POOL_DEBUG(type, "Rule:");                 /* r is any rule */
172   if (r && r->d < 0)
173     POOL_DEBUG(type, " (disabled)");
174   POOL_DEBUG(type, "\n");
175   d = r->d < 0 ? -r->d - 1 : r->d;
176   for (i = 0; ; i++)
177     {
178       if (i == 0)
179           /* print direct literal */
180         v = r->p;
181       else if (!d)
182         {
183           if (i == 2)
184             break;
185           /* binary rule --> print w2 as second literal */
186           v = r->w2;
187         }
188       else
189           /* every other which is in d */
190         v = solv->pool->whatprovidesdata[d + i - 1];
191       if (v == ID_NULL)
192         break;
193       solver_printruleelement(solv, type, r, v);
194     }
195   POOL_DEBUG(type, "    next rules: %d %d\n", r->n1, r->n2);
196 }
197
198 void
199 solver_printruleclass(Solver *solv, int type, Rule *r)
200 {
201   Pool *pool = solv->pool;
202   Id p = r - solv->rules;
203   assert(p >= 0);
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);
224 }
225
226 void
227 solver_printproblem(Solver *solv, Id v)
228 {
229   Pool *pool = solv->pool;
230   int i;
231   Rule *r;
232   Id *jp;
233
234   if (v > 0)
235     solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, solv->rules + v);
236   else
237     {
238       v = -(v + 1);
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++)
242         if (*jp == v)
243           {
244             POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "- ");
245             solver_printrule(solv, SOLV_DEBUG_SOLUTIONS, r);
246           }
247       POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "ENDJOB\n");
248     }
249 }
250
251 void
252 solver_printwatches(Solver *solv, int type)
253 {
254   Pool *pool = solv->pool;
255   int counter;
256
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]);
260 }
261
262 void
263 solver_printdecisionq(Solver *solv, int type)
264 {
265   Pool *pool = solv->pool;
266   int i;
267   Id p, why;
268
269   POOL_DEBUG(type, "Decisions:\n");
270   for (i = 0; i < solv->decisionq.count; i++)
271     {
272       p = solv->decisionq.elements[i];
273       if (p > 0)
274         POOL_DEBUG(type, "%d %d install  %s, ", i, solv->decisionmap[p], pool_solvid2str(pool, p));
275       else
276         POOL_DEBUG(type, "%d %d conflict %s, ", i, -solv->decisionmap[-p], pool_solvid2str(pool, -p));
277       why = solv->decisionq_why.elements[i];
278       if (why > 0)
279         {
280           POOL_DEBUG(type, "forced by ");
281           solver_printruleclass(solv, type, solv->rules + why);
282         }
283       else if (why < 0)
284         {
285           POOL_DEBUG(type, "chosen from ");
286           solver_printruleclass(solv, type, solv->rules - why);
287         }
288       else
289         POOL_DEBUG(type, "picked for some unknown reason.\n");
290     }
291 }
292
293 /*
294  * printdecisions
295  */
296
297 void
298 solver_printdecisions(Solver *solv)
299 {
300   Pool *pool = solv->pool;
301   Repo *installed = solv->installed;
302   Transaction *trans = solver_create_transaction(solv);
303   Id p, type;
304   int i, j;
305   Solvable *s;
306   Queue iq;
307   Queue recommendations;
308   Queue suggestions;
309   Queue orphaned;
310
311   POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
312   POOL_DEBUG(SOLV_DEBUG_RESULT, "transaction:\n");
313
314   queue_init(&iq);
315   for (i = 0; i < trans->steps.count; i++)
316     {
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);
320       switch(type)
321         {
322         case SOLVER_TRANSACTION_MULTIINSTALL:
323           POOL_DEBUG(SOLV_DEBUG_RESULT, "  multi install %s", pool_solvable2str(pool, s));
324           break;
325         case SOLVER_TRANSACTION_MULTIREINSTALL:
326           POOL_DEBUG(SOLV_DEBUG_RESULT, "  multi reinstall %s", pool_solvable2str(pool, s));
327           break;
328         case SOLVER_TRANSACTION_INSTALL:
329           POOL_DEBUG(SOLV_DEBUG_RESULT, "  install   %s", pool_solvable2str(pool, s));
330           break;
331         case SOLVER_TRANSACTION_REINSTALL:
332           POOL_DEBUG(SOLV_DEBUG_RESULT, "  reinstall %s", pool_solvable2str(pool, s));
333           break;
334         case SOLVER_TRANSACTION_DOWNGRADE:
335           POOL_DEBUG(SOLV_DEBUG_RESULT, "  downgrade %s", pool_solvable2str(pool, s));
336           break;
337         case SOLVER_TRANSACTION_CHANGE:
338           POOL_DEBUG(SOLV_DEBUG_RESULT, "  change    %s", pool_solvable2str(pool, s));
339           break;
340         case SOLVER_TRANSACTION_UPGRADE:
341         case SOLVER_TRANSACTION_OBSOLETES:
342           POOL_DEBUG(SOLV_DEBUG_RESULT, "  upgrade   %s", pool_solvable2str(pool, s));
343           break;
344         case SOLVER_TRANSACTION_ERASE:
345           POOL_DEBUG(SOLV_DEBUG_RESULT, "  erase     %s", pool_solvable2str(pool, s));
346           break;
347         default:
348           break;
349         }
350       switch(type)
351         {
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");
357           break;
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);
364           if (iq.count)
365             {
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, ")");
370             }
371           POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
372           break;
373         default:
374           break;
375         }
376     }
377   queue_free(&iq);
378
379   POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
380
381   queue_init(&recommendations);
382   queue_init(&suggestions);
383   queue_init(&orphaned);
384   solver_get_recommendations(solv, &recommendations, &suggestions, 0);
385   if (recommendations.count)
386     {
387       POOL_DEBUG(SOLV_DEBUG_RESULT, "recommended packages:\n");
388       for (i = 0; i < recommendations.count; i++)
389         {
390           s = pool->solvables + recommendations.elements[i];
391           if (solv->decisionmap[recommendations.elements[i]] > 0)
392             {
393               if (installed && s->repo == installed)
394                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (installed)\n", pool_solvable2str(pool, s));
395               else
396                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (selected)\n", pool_solvable2str(pool, s));
397             }
398           else
399             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s\n", pool_solvable2str(pool, s));
400         }
401       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
402     }
403
404   if (suggestions.count)
405     {
406       POOL_DEBUG(SOLV_DEBUG_RESULT, "suggested packages:\n");
407       for (i = 0; i < suggestions.count; i++)
408         {
409           s = pool->solvables + suggestions.elements[i];
410           if (solv->decisionmap[suggestions.elements[i]] > 0)
411             {
412               if (installed && s->repo == installed)
413                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (installed)\n", pool_solvable2str(pool, s));
414               else
415                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (selected)\n", pool_solvable2str(pool, s));
416             }
417           else
418             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s\n", pool_solvable2str(pool, s));
419         }
420       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
421     }
422   if (orphaned.count)
423     {
424       POOL_DEBUG(SOLV_DEBUG_RESULT, "orphaned packages:\n");
425       for (i = 0; i < orphaned.count; i++)
426         {
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));
430           else
431             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (erased)\n", pool_solvable2str(pool, s));
432         }
433       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
434     }
435   queue_free(&recommendations);
436   queue_free(&suggestions);
437   queue_free(&orphaned);
438   transaction_free(trans);
439 }
440
441 static inline
442 const char *id2strnone(Pool *pool, Id id)
443 {
444   return !id || id == 1 ? "(none)" : pool_id2str(pool, id);
445 }
446
447 void
448 transaction_print(Transaction *trans)
449 {
450   Pool *pool = trans->pool;
451   Queue classes, pkgs;
452   int i, j, mode, l, linel;
453   char line[76];
454   const char *n;
455
456   queue_init(&classes);
457   queue_init(&pkgs);
458   mode = 0;
459   transaction_classify(trans, mode, &classes);
460   for (i = 0; i < classes.count; i += 4)
461     {
462       Id class = classes.elements[i];
463       Id cnt = classes.elements[i + 1];
464       switch(class)
465         {
466         case SOLVER_TRANSACTION_ERASE:
467           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d erased packages:\n", cnt);
468           break;
469         case SOLVER_TRANSACTION_INSTALL:
470           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d installed packages:\n", cnt);
471           break;
472         case SOLVER_TRANSACTION_REINSTALLED:
473           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d reinstalled packages:\n", cnt);
474           break;
475         case SOLVER_TRANSACTION_DOWNGRADED:
476           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d downgraded packages:\n", cnt);
477           break;
478         case SOLVER_TRANSACTION_CHANGED:
479           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d changed packages:\n", cnt);
480           break;
481         case SOLVER_TRANSACTION_UPGRADED:
482           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d upgraded packages:\n", cnt);
483           break;
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]));
486           break;
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]));
489           break;
490         default:
491           class = SOLVER_TRANSACTION_IGNORE;
492           break;
493         }
494       if (class == SOLVER_TRANSACTION_IGNORE)
495         continue;
496       transaction_classify_pkgs(trans, mode, class, classes.elements[i + 2], classes.elements[i + 3], &pkgs);
497       *line = 0;
498       linel = 0;
499       for (j = 0; j < pkgs.count; j++)
500         {
501           Id p = pkgs.elements[j];
502           Solvable *s = pool->solvables + p;
503           Solvable *s2;
504
505           switch(class)
506             {
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));
511               break;
512             case SOLVER_TRANSACTION_VENDORCHANGE:
513             case SOLVER_TRANSACTION_ARCHCHANGE:
514               n = pool_id2str(pool, s->name);
515               l = strlen(n);
516               if (l + linel > sizeof(line) - 3)
517                 {
518                   if (*line)
519                     POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", line);
520                   *line = 0;
521                   linel = 0;
522                 }
523               if (l + linel > sizeof(line) - 3)
524                 POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", n);
525               else
526                 {
527                   if (*line)
528                     {
529                       strcpy(line + linel, ", ");
530                       linel += 2;
531                     }
532                   strcpy(line + linel, n);
533                   linel += l;
534                 }
535               break;
536             default:
537               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - %s\n", pool_solvable2str(pool, s));
538               break;
539             }
540         }
541       if (*line)
542         POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", line);
543       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
544     }
545   queue_free(&classes);
546   queue_free(&pkgs);
547 }
548
549 void
550 solver_printproblemruleinfo(Solver *solv, Id probr)
551 {
552   Pool *pool = solv->pool;
553   Id dep, source, target;
554
555   switch (solver_ruleinfo(solv, probr, &source, &target, &dep))
556     {
557     case SOLVER_RULE_DISTUPGRADE:
558       POOL_DEBUG(SOLV_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", pool_solvid2str(pool, source));
559       return;
560     case SOLVER_RULE_INFARCH:
561       POOL_DEBUG(SOLV_DEBUG_RESULT, "%s has inferior architecture\n", pool_solvid2str(pool, source));
562       return;
563     case SOLVER_RULE_UPDATE:
564       POOL_DEBUG(SOLV_DEBUG_RESULT, "problem with installed package %s\n", pool_solvid2str(pool, source));
565       return;
566     case SOLVER_RULE_JOB:
567       POOL_DEBUG(SOLV_DEBUG_RESULT, "conflicting requests\n");
568       return;
569     case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
570       POOL_DEBUG(SOLV_DEBUG_RESULT, "nothing provides requested %s\n", pool_dep2str(pool, dep));
571       return;
572     case SOLVER_RULE_RPM:
573       POOL_DEBUG(SOLV_DEBUG_RESULT, "some dependency problem\n");
574       return;
575     case SOLVER_RULE_RPM_NOT_INSTALLABLE:
576       POOL_DEBUG(SOLV_DEBUG_RESULT, "package %s is not installable\n", pool_solvid2str(pool, source));
577       return;
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));
580       return;
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));
583       return;
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));
586       return;
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));
589       return;
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));
592       return;
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));
595       return;
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));
598       return;
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));
601       return;
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");
608       return;
609     }
610 }
611
612 void
613 solver_printprobleminfo(Solver *solv, Id problem)
614 {
615   solver_printproblemruleinfo(solv, solver_findproblemrule(solv, problem));
616 }
617
618 void
619 solver_printcompleteprobleminfo(Solver *solv, Id problem)
620 {
621   Queue q;
622   Id probr;
623   int i, nobad = 0;
624
625   queue_init(&q);
626   solver_findallproblemrules(solv, problem, &q);
627   for (i = 0; i < q.count; i++)
628     {
629       probr = q.elements[i];
630       if (!(probr >= solv->updaterules && probr < solv->updaterules_end) && !(probr >= solv->jobrules && probr < solv->jobrules_end))
631         {
632           nobad = 1;
633           break;
634         }
635     }
636   for (i = 0; i < q.count; i++)
637     {
638       probr = q.elements[i];
639       if (nobad && ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end)))
640         continue;
641       solver_printproblemruleinfo(solv, probr);
642     }
643   queue_free(&q);
644 }
645
646 void
647 solver_printsolution(Solver *solv, Id problem, Id solution)
648 {
649   Pool *pool = solv->pool;
650   Id p, rp, element, how, what, select;
651   Solvable *s, *sd;
652
653   element = 0;
654   while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
655     {
656       if (p == SOLVER_SOLUTION_JOB)
657         {
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)
663             {
664             case SOLVER_INSTALL:
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));
669               else
670                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  - do not install %s\n", solver_select2str(pool, select, what));
671               break;
672             case SOLVER_ERASE:
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));
677               else
678                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  - do not deinstall %s\n", solver_select2str(pool, select, what));
679               break;
680             case SOLVER_UPDATE:
681               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - do not install most recent version of %s\n", solver_select2str(pool, select, what));
682               break;
683             case SOLVER_LOCK:
684               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - do not lock %s\n", solver_select2str(pool, select, what));
685               break;
686             default:
687               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - do something different\n");
688               break;
689             }
690         }
691       else if (p == SOLVER_SOLUTION_INFARCH)
692         {
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));
696           else
697             POOL_DEBUG(SOLV_DEBUG_RESULT, "  - install %s despite the inferior architecture\n", pool_solvable2str(pool, s));
698         }
699       else if (p == SOLVER_SOLUTION_DISTUPGRADE)
700         {
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));
704           else
705             POOL_DEBUG(SOLV_DEBUG_RESULT, "  - install %s from excluded repository\n", pool_solvable2str(pool, s));
706         }
707       else if (p == SOLVER_SOLUTION_BEST)
708         {
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));
712           else
713             POOL_DEBUG(SOLV_DEBUG_RESULT, "  - install %s despite the old version\n", pool_solvable2str(pool, s));
714         }
715       else
716         {
717           /* policy, replace p with rp */
718           s = pool->solvables + p;
719           sd = rp ? pool->solvables + rp : 0;
720           if (sd)
721             {
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)
730                 {
731                   if (sd->vendor)
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));
733                   else
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));
735                 }
736               if (!illegal)
737                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  - allow replacement of %s with %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, sd));
738             }
739           else
740             {
741               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - allow deinstallation of %s\n", pool_solvable2str(pool, s));
742             }
743         }
744     }
745 }
746
747 void
748 solver_printallsolutions(Solver *solv)
749 {
750   Pool *pool = solv->pool;
751   int pcnt;
752   Id problem, solution;
753
754   POOL_DEBUG(SOLV_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
755   pcnt = 0;
756   problem = 0;
757   while ((problem = solver_next_problem(solv, problem)) != 0)
758     {
759       pcnt++;
760       POOL_DEBUG(SOLV_DEBUG_RESULT, "Problem %d:\n", pcnt);
761       POOL_DEBUG(SOLV_DEBUG_RESULT, "====================================\n");
762 #if 1
763       solver_printprobleminfo(solv, problem);
764 #else
765       solver_printcompleteprobleminfo(solv, problem);
766 #endif
767       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
768       solution = 0;
769       while ((solution = solver_next_solution(solv, problem, solution)) != 0)
770         {
771           solver_printsolution(solv, problem, solution);
772           POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
773         }
774     }
775 }
776
777 void
778 solver_printtrivial(Solver *solv)
779 {
780   Pool *pool = solv->pool;
781   Queue in, out;
782   Id p;
783   const char *n; 
784   Solvable *s; 
785   int i;
786
787   queue_init(&in);
788   for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
789     {   
790       n = pool_id2str(pool, s->name);
791       if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
792         continue;
793       queue_push(&in, p); 
794     }   
795   if (!in.count)
796     {
797       queue_free(&in);
798       return;
799     }
800   queue_init(&out);
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");
806   queue_free(&in);
807   queue_free(&out);
808 }
809
810 const char *
811 solver_select2str(Pool *pool, Id select, Id what)
812 {
813   const char *s;
814   char *b;
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)
821     {
822       s = pool_dep2str(pool, what);
823       b = pool_alloctmpspace(pool, 11 + strlen(s));
824       sprintf(b, "providing %s", s);
825       return b;
826     }
827   if (select == SOLVER_SOLVABLE_ONE_OF)
828     {
829       Id p;
830       b = 0;
831       while ((p = pool->whatprovidesdata[what++]) != 0)
832         {
833           s = pool_solvid2str(pool, p);
834           if (b)
835             b = pool_tmpappend(pool, b, ", ", s);
836           else
837             b = pool_tmpjoin(pool, s, 0, 0);
838           pool_freetmpspace(pool, s);
839         }
840       return b ? b : "nothing";
841     }
842   if (select == SOLVER_SOLVABLE_REPO)
843     {
844       b = pool_alloctmpspace(pool, 20);
845       sprintf(b, "repo #%d", what);
846       return b;
847     }
848   if (select == SOLVER_SOLVABLE_ALL)
849     return "all packages";
850   return "unknown job select";
851 }
852
853 const char *
854 pool_job2str(Pool *pool, Id how, Id what, Id flagmask)
855 {
856   Id select = how & SOLVER_SELECTMASK;
857   const char *strstart = 0, *strend = 0;
858   char *s;
859   int o;
860
861   switch (how & SOLVER_JOBMASK)
862     {
863     case SOLVER_NOOP:
864       return "do nothing";
865     case SOLVER_INSTALL:
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 ";
872       else
873         strstart = "install one of ";
874       break;
875     case SOLVER_ERASE:
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 ";
880       else
881         strstart = "deinstall ";
882       break;
883     case SOLVER_UPDATE:
884       strstart = "update ";
885       break;
886     case SOLVER_WEAKENDEPS:
887       strstart = "weaken deps of ";
888       break;
889     case SOLVER_NOOBSOLETES:
890       strstart = "multi version ";
891       break;
892     case SOLVER_LOCK:
893       strstart = "update ";
894       break;
895     case SOLVER_DISTUPGRADE:
896       strstart = "dist upgrade ";
897       break;
898     case SOLVER_VERIFY:
899       strstart = "verify ";
900       break;
901     case SOLVER_DROP_ORPHANED:
902       strstart = "deinstall ", strend = "if orphaned";
903       break;
904     case SOLVER_USERINSTALLED:
905       strstart = "regard ", strend = "as userinstalled";
906       break;
907     default:
908       strstart = "unknown job ";
909       break;
910     }
911   s = pool_tmpjoin(pool, strstart, solver_select2str(pool, select, what), strend);
912   how &= flagmask;
913   if ((how & ~(SOLVER_SELECTMASK|SOLVER_JOBMASK)) == 0)
914     return s;
915   o = strlen(s);
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);
935   if (s[o + 1] != ',')
936     s = pool_tmpappend(pool, s, ",?", 0);
937   s[o + 1] = '[';
938   return pool_tmpappend(pool, s, "]", 0);
939 }
940
941 const char *
942 pool_selection2str(Pool *pool, Queue *selection, Id flagmask)
943 {
944   char *s;
945   const char *s2;
946   int i;
947   s = pool_tmpjoin(pool, 0, 0, 0);
948   for (i = 0; i < selection->count; i += 2)
949     {
950       Id how = selection->elements[i];
951       if (*s)
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;
957       if (how)
958         {
959           int o = strlen(s);
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);
973           if (s[o + 1] != ',')
974             s = pool_tmpappend(pool, s, ",?", 0);
975           s[o + 1] = '[';
976           s = pool_tmpappend(pool, s, "]", 0);
977         }
978     }
979   return s;
980 }
981
982 const char *
983 solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id target, Id dep)
984 {
985   Pool *pool = solv->pool;
986   char *s;
987   switch (type)
988     {
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");
1031     default:
1032       return "bad problem rule type";
1033     }
1034 }
1035
1036 const char *
1037 solver_solutionelement2str(Solver *solv, Id p, Id rp)
1038 {
1039   Pool *pool = solv->pool;
1040   if (p == SOLVER_SOLUTION_JOB)
1041     {
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);
1045     }
1046   else if (p == SOLVER_SOLUTION_INFARCH)
1047     {
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");
1051       else
1052         return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the inferior architecture");
1053     }
1054   else if (p == SOLVER_SOLUTION_DISTUPGRADE)
1055     {
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);
1059       else
1060         return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " from excluded repository");
1061     }
1062   else if (p == SOLVER_SOLUTION_BEST)
1063     {
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);
1067       else
1068         return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the old version");
1069     }
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)
1073     {
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);
1078     }
1079   else
1080     return "bad solution element";
1081 }
1082
1083 const char *
1084 policy_illegal2str(Solver *solv, int illegal, Solvable *s, Solvable *rs)
1085 {
1086   Pool *pool = solv->pool;
1087   const char *str;
1088   if (illegal == POLICY_ILLEGAL_DOWNGRADE)
1089     {
1090       str = pool_tmpjoin(pool, "downgrade of ", pool_solvable2str(pool, s), 0);
1091       return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1092     }
1093   if (illegal == POLICY_ILLEGAL_NAMECHANGE)
1094     {
1095       str = pool_tmpjoin(pool, "name change of ", pool_solvable2str(pool, s), 0);
1096       return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1097     }
1098   if (illegal == POLICY_ILLEGAL_ARCHCHANGE)
1099     {
1100       str = pool_tmpjoin(pool, "architecture change of ", pool_solvable2str(pool, s), 0);
1101       return pool_tmpappend(pool, str, " to ", pool_solvable2str(pool, rs));
1102     }
1103   if (illegal == POLICY_ILLEGAL_VENDORCHANGE)
1104     {
1105       str = pool_tmpjoin(pool, "vendor change from '", pool_id2str(pool, s->vendor), "' (");
1106       if (rs->vendor)
1107         {
1108           str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to '");
1109           str = pool_tmpappend(pool, str, pool_id2str(pool, rs->vendor), "' (");
1110         }
1111       else
1112         str = pool_tmpappend(pool, str, pool_solvable2str(pool, s), ") to no vendor (");
1113       return pool_tmpappend(pool, str, pool_solvable2str(pool, rs), ")");
1114     }
1115   return "unknown illegal change";
1116 }