- improve infarch/dup rule problem handling
[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 "solverdebug.h"
22 #include "bitmap.h"
23 #include "pool.h"
24 #include "util.h"
25 #include "evr.h"
26 #include "policy.h"
27
28
29 /*
30  * create obsoletesmap from solver decisions
31  *
32  * for solvables in installed repo:
33  *   0 - not obsoleted
34  *   p - one of the packages that obsolete us
35  * for all others:
36  *   n - number of packages this package obsoletes
37  *
38  */
39
40 Id *
41 solver_create_decisions_obsoletesmap(Solver *solv)
42 {
43   Pool *pool = solv->pool;
44   Repo *installed = solv->installed;
45   Id p, *obsoletesmap = NULL;
46   int i;
47   Solvable *s;
48
49   obsoletesmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
50   if (installed)
51     {
52       for (i = 0; i < solv->decisionq.count; i++)
53         {
54           Id pp, n;
55           int noobs;
56
57           n = solv->decisionq.elements[i];
58           if (n < 0)
59             continue;
60           if (n == SYSTEMSOLVABLE)
61             continue;
62           s = pool->solvables + n;
63           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
64             continue;
65           noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
66           FOR_PROVIDES(p, pp, s->name)
67             {
68               Solvable *ps = pool->solvables + p;
69               if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
70                 continue;
71               if (!solv->implicitobsoleteusesprovides && s->name != ps->name)
72                 continue;
73               if (pool->solvables[p].repo == installed && !obsoletesmap[p])
74                 {
75                   obsoletesmap[p] = n;
76                   obsoletesmap[n]++;
77                 }
78             }
79         }
80       for (i = 0; i < solv->decisionq.count; i++)
81         {
82           Id obs, *obsp;
83           Id pp, n;
84
85           n = solv->decisionq.elements[i];
86           if (n < 0)
87             continue;
88           if (n == SYSTEMSOLVABLE)
89             continue;
90           s = pool->solvables + n;
91           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
92             continue;
93           if (!s->obsoletes)
94             continue;
95           if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n))
96             continue;
97           obsp = s->repo->idarraydata + s->obsoletes;
98           while ((obs = *obsp++) != 0)
99             {
100               FOR_PROVIDES(p, pp, obs)
101                 {
102                   if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
103                     continue;
104                   if (pool->solvables[p].repo == installed && !obsoletesmap[p])
105                     {
106                       obsoletesmap[p] = n;
107                       obsoletesmap[n]++;
108                     }
109                 }
110             }
111         }
112     }
113   return obsoletesmap;
114 }
115
116 void
117 solver_printruleelement(Solver *solv, int type, Rule *r, Id v)
118 {
119   Pool *pool = solv->pool;
120   Solvable *s;
121   if (v < 0)
122     {
123       s = pool->solvables + -v;
124       POOL_DEBUG(type, "    !%s [%d]", solvable2str(pool, s), -v);
125     }
126   else
127     {
128       s = pool->solvables + v;
129       POOL_DEBUG(type, "    %s [%d]", solvable2str(pool, s), v);
130     }
131   if (r)
132     {
133       if (r->w1 == v)
134         POOL_DEBUG(type, " (w1)");
135       if (r->w2 == v)
136         POOL_DEBUG(type, " (w2)");
137     }
138   if (solv->decisionmap[s - pool->solvables] > 0)
139     POOL_DEBUG(type, " Install.level%d", solv->decisionmap[s - pool->solvables]);
140   if (solv->decisionmap[s - pool->solvables] < 0)
141     POOL_DEBUG(type, " Conflict.level%d", -solv->decisionmap[s - pool->solvables]);
142   POOL_DEBUG(type, "\n");
143 }
144
145
146 /*
147  * print rule
148  */
149
150 void
151 solver_printrule(Solver *solv, int type, Rule *r)
152 {
153   Pool *pool = solv->pool;
154   int i;
155   Id d, v;
156
157   if (r >= solv->rules && r < solv->rules + solv->nrules)   /* r is a solver rule */
158     POOL_DEBUG(type, "Rule #%d:", (int)(r - solv->rules));
159   else
160     POOL_DEBUG(type, "Rule:");                 /* r is any rule */
161   if (r && r->d < 0)
162     POOL_DEBUG(type, " (disabled)");
163   POOL_DEBUG(type, "\n");
164   d = r->d < 0 ? -r->d - 1 : r->d;
165   for (i = 0; ; i++)
166     {
167       if (i == 0)
168           /* print direct literal */
169         v = r->p;
170       else if (!d)
171         {
172           if (i == 2)
173             break;
174           /* binary rule --> print w2 as second literal */
175           v = r->w2;
176         }
177       else
178           /* every other which is in d */
179         v = solv->pool->whatprovidesdata[d + i - 1];
180       if (v == ID_NULL)
181         break;
182       solver_printruleelement(solv, type, r, v);
183     }
184   POOL_DEBUG(type, "    next rules: %d %d\n", r->n1, r->n2);
185 }
186
187 void
188 solver_printruleclass(Solver *solv, int type, Rule *r)
189 {
190   Pool *pool = solv->pool;
191   Id p = r - solv->rules;
192   assert(p >= 0);
193   if (p < solv->learntrules)
194     if (MAPTST(&solv->weakrulemap, p))
195       POOL_DEBUG(type, "WEAK ");
196   if (p >= solv->learntrules)
197     POOL_DEBUG(type, "LEARNT ");
198   else if (p >= solv->infarchrules && p < solv->infarchrules_end)
199     POOL_DEBUG(type, "INFARCH ");
200   else if (p >= solv->duprules && p < solv->duprules_end)
201     POOL_DEBUG(type, "DUP ");
202   else if (p >= solv->jobrules && p < solv->jobrules_end)
203     POOL_DEBUG(type, "JOB ");
204   else if (p >= solv->updaterules && p < solv->updaterules_end)
205     POOL_DEBUG(type, "UPDATE ");
206   else if (p >= solv->featurerules && p < solv->featurerules_end)
207     POOL_DEBUG(type, "FEATURE ");
208   solver_printrule(solv, type, r);
209 }
210
211 void
212 solver_printproblem(Solver *solv, Id v)
213 {
214   Pool *pool = solv->pool;
215   int i;
216   Rule *r;
217   Id *jp;
218
219   if (v > 0)
220     solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, solv->rules + v);
221   else
222     {
223       v = -(v + 1);
224       POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "JOB %d\n", v);
225       jp = solv->ruletojob.elements;
226       for (i = solv->jobrules, r = solv->rules + i; i < solv->learntrules; i++, r++, jp++)
227         if (*jp == v)
228           {
229             POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "- ");
230             solver_printrule(solv, SAT_DEBUG_SOLUTIONS, r);
231           }
232       POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "ENDJOB\n");
233     }
234 }
235
236 void
237 solver_printwatches(Solver *solv, int type)
238 {
239   Pool *pool = solv->pool;
240   int counter;
241
242   POOL_DEBUG(type, "Watches: \n");
243   for (counter = -(pool->nsolvables - 1); counter < pool->nsolvables; counter++)
244     POOL_DEBUG(type, "    solvable [%d] -- rule [%d]\n", counter, solv->watches[counter + pool->nsolvables]);
245 }
246
247 /*
248  * printdecisions
249  */
250
251 void
252 solver_printdecisions(Solver *solv)
253 {
254   Pool *pool = solv->pool;
255   Repo *installed = solv->installed;
256   Id p, *obsoletesmap = solver_create_decisions_obsoletesmap(solv);
257   int i;
258   Solvable *s;
259
260   IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
261     {
262       POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions -----\n");
263       for (i = 0; i < solv->decisionq.count; i++)
264         {
265           p = solv->decisionq.elements[i];
266           solver_printruleelement(solv, SAT_DEBUG_SCHUBI, 0, p);
267         }
268       POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n");
269     }
270
271   POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
272   POOL_DEBUG(SAT_DEBUG_RESULT, "transaction:\n");
273
274   /* print solvables to be erased */
275
276   if (installed)
277     {
278       FOR_REPO_SOLVABLES(installed, p, s)
279         {
280           if (solv->decisionmap[p] > 0)
281             continue;
282           if (obsoletesmap[p])
283             continue;
284           POOL_DEBUG(SAT_DEBUG_RESULT, "  erase     %s\n", solvable2str(pool, s));
285         }
286     }
287
288   /* print solvables to be installed */
289
290   for (i = 0; i < solv->decisionq.count; i++)
291     {
292       int j;
293       p = solv->decisionq.elements[i];
294       if (p < 0)
295         continue;
296       if (p == SYSTEMSOLVABLE)
297         continue;
298       s = pool->solvables + p;
299       if (installed && s->repo == installed)
300         continue;
301
302       if (!obsoletesmap[p])
303         {
304           POOL_DEBUG(SAT_DEBUG_RESULT, "  install   %s", solvable2str(pool, s));
305         }
306       else
307         {
308           Id xp, xpp;
309           FOR_PROVIDES(xp, xpp, s->name)
310             {
311               Solvable *s2 = pool->solvables + xp;
312               if (s2->name != s->name)
313                 continue;
314               if (evrcmp(pool, s->evr, s2->evr, EVRCMP_MATCH_RELEASE) < 0)
315                 break;
316             }
317           if (xp)
318             POOL_DEBUG(SAT_DEBUG_RESULT, "  downgrade %s", solvable2str(pool, s));
319           else
320             POOL_DEBUG(SAT_DEBUG_RESULT, "  upgrade   %s", solvable2str(pool, s));
321           POOL_DEBUG(SAT_DEBUG_RESULT, "  (obsoletes");
322           for (j = installed->start; j < installed->end; j++)
323             if (obsoletesmap[j] == p)
324               POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvable2str(pool, pool->solvables + j));
325           POOL_DEBUG(SAT_DEBUG_RESULT, ")");
326         }
327       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
328     }
329   POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
330
331   sat_free(obsoletesmap);
332
333   if (solv->recommendations.count)
334     {
335       POOL_DEBUG(SAT_DEBUG_RESULT, "recommended packages:\n");
336       for (i = 0; i < solv->recommendations.count; i++)
337         {
338           s = pool->solvables + solv->recommendations.elements[i];
339           if (solv->decisionmap[solv->recommendations.elements[i]] > 0)
340             {
341               if (installed && s->repo == installed)
342                 POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (installed)\n", solvable2str(pool, s));
343               else
344                 POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (selected)\n", solvable2str(pool, s));
345             }
346           else
347             POOL_DEBUG(SAT_DEBUG_RESULT, "  %s\n", solvable2str(pool, s));
348         }
349       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
350     }
351
352   if (solv->suggestions.count)
353     {
354       POOL_DEBUG(SAT_DEBUG_RESULT, "suggested packages:\n");
355       for (i = 0; i < solv->suggestions.count; i++)
356         {
357           s = pool->solvables + solv->suggestions.elements[i];
358           if (solv->decisionmap[solv->suggestions.elements[i]] > 0)
359             {
360               if (installed && s->repo == installed)
361                 POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (installed)\n", solvable2str(pool, s));
362               else
363                 POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (selected)\n", solvable2str(pool, s));
364             }
365           else
366             POOL_DEBUG(SAT_DEBUG_RESULT, "  %s\n", solvable2str(pool, s));
367         }
368       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
369     }
370   if (solv->orphaned.count)
371     {
372       POOL_DEBUG(SAT_DEBUG_RESULT, "orphaned packages:\n");
373       for (i = 0; i < solv->orphaned.count; i++)
374         {
375           s = pool->solvables + solv->orphaned.elements[i];
376           if (solv->decisionmap[solv->orphaned.elements[i]] > 0)
377             POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (kept)\n", solvable2str(pool, s));
378           else
379             POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (erased)\n", solvable2str(pool, s));
380         }
381       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
382     }
383 }
384
385 void
386 solver_printprobleminfo(Solver *solv, Queue *job, Id problem)
387 {
388   Pool *pool = solv->pool;
389   Id probr;
390   Id dep, source, target;
391   Solvable *s, *s2;
392
393   probr = solver_findproblemrule(solv, problem);
394   switch (solver_problemruleinfo(solv, job, probr, &dep, &source, &target))
395     {
396     case SOLVER_PROBLEM_DISTUPGRADE_RULE:
397       s = pool_id2solvable(pool, source);
398       POOL_DEBUG(SAT_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", solvable2str(pool, s));
399       return;
400     case SOLVER_PROBLEM_INFARCH_RULE:
401       s = pool_id2solvable(pool, source);
402       POOL_DEBUG(SAT_DEBUG_RESULT, "%s has inferior architecture\n", solvable2str(pool, s));
403       return;
404     case SOLVER_PROBLEM_UPDATE_RULE:
405       s = pool_id2solvable(pool, source);
406       POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvable2str(pool, s));
407       return;
408     case SOLVER_PROBLEM_JOB_RULE:
409       POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n");
410       return;
411     case SOLVER_PROBLEM_RPM_RULE:
412       POOL_DEBUG(SAT_DEBUG_RESULT, "some dependency problem\n");
413       return;
414     case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
415       POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides requested %s\n", dep2str(pool, dep));
416       return;
417     case SOLVER_PROBLEM_NOT_INSTALLABLE:
418       s = pool_id2solvable(pool, source);
419       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvable2str(pool, s));
420       return;
421     case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
422       s = pool_id2solvable(pool, source);
423       POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
424       return;
425     case SOLVER_PROBLEM_SAME_NAME:
426       s = pool_id2solvable(pool, source);
427       s2 = pool_id2solvable(pool, target);
428       POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
429       return;
430     case SOLVER_PROBLEM_PACKAGE_CONFLICT:
431       s = pool_id2solvable(pool, source);
432       s2 = pool_id2solvable(pool, target);
433       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
434       return;
435     case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
436       s = pool_id2solvable(pool, source);
437       s2 = pool_id2solvable(pool, target);
438       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
439       return;
440     case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
441       s = pool_id2solvable(pool, source);
442       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
443       return;
444     case SOLVER_PROBLEM_SELF_CONFLICT:
445       s = pool_id2solvable(pool, source);
446       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", solvable2str(pool, s), dep2str(pool, dep));
447       return;
448     }
449 }
450
451 void
452 solver_printsolutions(Solver *solv, Queue *job)
453 {
454   Pool *pool = solv->pool;
455   int pcnt;
456   Id p, rp, how, what, select;
457   Id problem, solution, element;
458   Solvable *s, *sd;
459
460   POOL_DEBUG(SAT_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
461   pcnt = 1;
462   problem = 0;
463   while ((problem = solver_next_problem(solv, problem)) != 0)
464     {
465       POOL_DEBUG(SAT_DEBUG_RESULT, "Problem %d:\n", pcnt++);
466       POOL_DEBUG(SAT_DEBUG_RESULT, "====================================\n");
467       solver_printprobleminfo(solv, job, problem);
468       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
469       solution = 0;
470       while ((solution = solver_next_solution(solv, problem, solution)) != 0)
471         {
472           element = 0;
473           while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
474             {
475               if (p == SOLVER_SOLUTION_JOB)
476                 {
477                   /* job, rp is index into job queue */
478                   how = job->elements[rp - 1];
479                   what = job->elements[rp];
480                   select = how & SOLVER_SELECTMASK;
481                   switch (how & SOLVER_JOBMASK)
482                     {
483                     case SOLVER_INSTALL:
484                       if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
485                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvable2str(pool, pool->solvables + what));
486                       else if (select == SOLVER_SOLVABLE_PROVIDES)
487                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable %s\n", solver_select2str(solv, select, what));
488                       else
489                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", solver_select2str(solv, select, what));
490                       break;
491                     case SOLVER_ERASE:
492                       if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
493                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvable2str(pool, pool->solvables + what));
494                       else if (select == SOLVER_SOLVABLE_PROVIDES)
495                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables %s\n", solver_select2str(solv, select, what));
496                       else
497                         POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", solver_select2str(solv, select, what));
498                       break;
499                     case SOLVER_UPDATE:
500                       POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install most recent version of %s\n", solver_select2str(solv, select, what));
501                       break;
502                     case SOLVER_LOCK:
503                       POOL_DEBUG(SAT_DEBUG_RESULT, "- do not lock %s\n", solver_select2str(solv, select, what));
504                       break;
505                     default:
506                       POOL_DEBUG(SAT_DEBUG_RESULT, "- do something different\n");
507                       break;
508                     }
509                 }
510               else if (p == SOLVER_SOLUTION_INFARCH)
511                 {
512                   s = pool->solvables + rp;
513                   if (solv->installed && s->repo == solv->installed)
514                     POOL_DEBUG(SAT_DEBUG_RESULT, "- keep %s despite the inferior architecture\n", solvable2str(pool, s));
515                   else
516                     POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s despite the inferior architecture\n", solvable2str(pool, s));
517                 }
518               else if (p == SOLVER_SOLUTION_DISTUPGRADE)
519                 {
520                   s = pool->solvables + rp;
521                   if (solv->installed && s->repo == solv->installed)
522                     POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
523                   else
524                     POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s from excluded repository\n", solvable2str(pool, s));
525                 }
526               else
527                 {
528                   /* policy, replace p with rp */
529                   s = pool->solvables + p;
530                   sd = rp ? pool->solvables + rp : 0;
531                   if (s == sd && solv->distupgrade)
532                     {
533                       POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
534                     }
535                   else if (sd)
536                     {
537                       int gotone = 0;
538                       if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
539                         {
540                           POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
541                           gotone = 1;
542                         }
543                       if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(solv, s, sd))
544                         {
545                           POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
546                           gotone = 1;
547                         }
548                       if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(solv, s, sd))
549                         {
550                           if (sd->vendor)
551                             POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to '%s' (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), id2str(pool, sd->vendor), solvable2str(pool, sd));
552                           else
553                             POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to no vendor (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), solvable2str(pool, sd));
554                           gotone = 1;
555                         }
556                       if (!gotone)
557                         POOL_DEBUG(SAT_DEBUG_RESULT, "- allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
558                     }
559                   else
560                     {
561                       POOL_DEBUG(SAT_DEBUG_RESULT, "- allow deinstallation of %s\n", solvable2str(pool, s));
562                     }
563
564                 }
565             }
566           POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
567         }
568     }
569 }
570
571 void
572 solver_printtrivial(Solver *solv)
573 {
574   Pool *pool = solv->pool;
575   Queue in, out;
576   Map installedmap;
577   Id p;
578   const char *n; 
579   Solvable *s; 
580   int i;
581
582   queue_init(&in);
583   for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
584     {   
585       n = id2str(pool, s->name);
586       if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
587         continue;
588       queue_push(&in, p); 
589     }   
590   if (!in.count)
591     {
592       queue_free(&in);
593       return;
594     }
595   solver_create_state_maps(solv, &installedmap, 0); 
596   queue_init(&out);
597   pool_trivial_installable(pool, &installedmap, &in, &out);
598   POOL_DEBUG(SAT_DEBUG_RESULT, "trivial installable status:\n");
599   for (i = 0; i < in.count; i++)
600     POOL_DEBUG(SAT_DEBUG_RESULT, "  %s: %d\n", solvable2str(pool, pool->solvables + in.elements[i]), out.elements[i]);
601   POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
602   map_free(&installedmap);
603   queue_free(&in);
604   queue_free(&out);
605 }
606
607 const char *
608 solver_select2str(Solver *solv, Id select, Id what)
609 {
610   Pool *pool = solv->pool;
611   const char *s;
612   char *b;
613   if (select == SOLVER_SOLVABLE)
614     return solvable2str(pool, pool->solvables + what);
615   if (select == SOLVER_SOLVABLE_NAME)
616     return dep2str(pool, what);
617   if (select == SOLVER_SOLVABLE_PROVIDES)
618     {
619       s = dep2str(pool, what);
620       b = pool_alloctmpspace(pool, 11 + strlen(s));
621       sprintf(b, "providing %s", s);
622       return b;
623     }
624   if (select == SOLVER_SOLVABLE_ONE_OF)
625     {
626       Id p;
627       char *b2;
628       b = "";
629       while ((p = pool->whatprovidesdata[what++]) != 0)
630         {
631           s = solvable2str(pool, pool->solvables + p);
632           b2 = pool_alloctmpspace(pool, strlen(b) + strlen(s) + 3);
633           sprintf(b2, "%s, %s", b, s);
634           b = b2;
635         }
636       return *b ? b + 2 : "nothing";
637     }
638   return "unknown job select";
639 }