summaryrefslogtreecommitdiff
path: root/src/solverdebug.c
blob: 5baafc672535bc89c08929fceff436e37d81fb62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
/*
 * Copyright (c) 2008, Novell Inc.
 *
 * This program is licensed under the BSD license, read LICENSE.BSD
 * for further information
 */

/*
 * solverdebug.c
 *
 * debug functions for the SAT solver
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>

#include "solver.h"
#include "solverdebug.h"
#include "bitmap.h"
#include "pool.h"
#include "util.h"
#include "evr.h"
#include "policy.h"


/*
 * create obsoletesmap from solver decisions
 *
 * for solvables in installed repo:
 *   0 - not obsoleted
 *   p - one of the packages that obsolete us
 * for all others:
 *   n - number of packages this package obsoletes
 *
 */

Id *
solver_create_decisions_obsoletesmap(Solver *solv)
{
  Pool *pool = solv->pool;
  Repo *installed = solv->installed;
  Id p, *obsoletesmap = NULL;
  int i;
  Solvable *s;

  obsoletesmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
  if (installed)
    {
      for (i = 0; i < solv->decisionq.count; i++)
	{
	  Id pp, n;
	  int noobs;

	  n = solv->decisionq.elements[i];
	  if (n < 0)
	    continue;
	  if (n == SYSTEMSOLVABLE)
	    continue;
	  s = pool->solvables + n;
	  if (s->repo == installed)		/* obsoletes don't count for already installed packages */
	    continue;
	  noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
	  FOR_PROVIDES(p, pp, s->name)
	    {
	      Solvable *ps = pool->solvables + p;
	      if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
		continue;
	      if (!solv->implicitobsoleteusesprovides && s->name != ps->name)
		continue;
	      if (pool->solvables[p].repo == installed && !obsoletesmap[p])
		{
		  obsoletesmap[p] = n;
		  obsoletesmap[n]++;
		}
	    }
	}
      for (i = 0; i < solv->decisionq.count; i++)
	{
	  Id obs, *obsp;
	  Id pp, n;

	  n = solv->decisionq.elements[i];
	  if (n < 0)
	    continue;
	  if (n == SYSTEMSOLVABLE)
	    continue;
	  s = pool->solvables + n;
	  if (s->repo == installed)		/* obsoletes don't count for already installed packages */
	    continue;
	  if (!s->obsoletes)
	    continue;
	  if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n))
	    continue;
	  obsp = s->repo->idarraydata + s->obsoletes;
	  while ((obs = *obsp++) != 0)
	    {
	      FOR_PROVIDES(p, pp, obs)
		{
		  if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p, obs))
		    continue;
		  if (pool->solvables[p].repo == installed && !obsoletesmap[p])
		    {
		      obsoletesmap[p] = n;
		      obsoletesmap[n]++;
		    }
		}
	    }
	}
    }
  return obsoletesmap;
}

void
solver_printruleelement(Solver *solv, int type, Rule *r, Id v)
{
  Pool *pool = solv->pool;
  Solvable *s;
  if (v < 0)
    {
      s = pool->solvables + -v;
      POOL_DEBUG(type, "    !%s [%d]", solvable2str(pool, s), -v);
    }
  else
    {
      s = pool->solvables + v;
      POOL_DEBUG(type, "    %s [%d]", solvable2str(pool, s), v);
    }
  if (r)
    {
      if (r->w1 == v)
	POOL_DEBUG(type, " (w1)");
      if (r->w2 == v)
	POOL_DEBUG(type, " (w2)");
    }
  if (solv->decisionmap[s - pool->solvables] > 0)
    POOL_DEBUG(type, " Install.level%d", solv->decisionmap[s - pool->solvables]);
  if (solv->decisionmap[s - pool->solvables] < 0)
    POOL_DEBUG(type, " Conflict.level%d", -solv->decisionmap[s - pool->solvables]);
  POOL_DEBUG(type, "\n");
}


/*
 * print rule
 */

void
solver_printrule(Solver *solv, int type, Rule *r)
{
  Pool *pool = solv->pool;
  int i;
  Id d, v;

  if (r >= solv->rules && r < solv->rules + solv->nrules)   /* r is a solver rule */
    POOL_DEBUG(type, "Rule #%d:", (int)(r - solv->rules));
  else
    POOL_DEBUG(type, "Rule:");		       /* r is any rule */
  if (r && r->d < 0)
    POOL_DEBUG(type, " (disabled)");
  POOL_DEBUG(type, "\n");
  d = r->d < 0 ? -r->d - 1 : r->d;
  for (i = 0; ; i++)
    {
      if (i == 0)
	  /* print direct literal */
	v = r->p;
      else if (!d)
	{
	  if (i == 2)
	    break;
	  /* binary rule --> print w2 as second literal */
	  v = r->w2;
	}
      else
	  /* every other which is in d */
	v = solv->pool->whatprovidesdata[d + i - 1];
      if (v == ID_NULL)
	break;
      solver_printruleelement(solv, type, r, v);
    }
  POOL_DEBUG(type, "    next rules: %d %d\n", r->n1, r->n2);
}

void
solver_printruleclass(Solver *solv, int type, Rule *r)
{
  Pool *pool = solv->pool;
  Id p = r - solv->rules;
  assert(p >= 0);
  if (p < solv->learntrules)
    if (MAPTST(&solv->weakrulemap, p))
      POOL_DEBUG(type, "WEAK ");
  if (p >= solv->learntrules)
    POOL_DEBUG(type, "LEARNT ");
  else if (p >= solv->infarchrules && p < solv->infarchrules_end)
    POOL_DEBUG(type, "INFARCH ");
  else if (p >= solv->duprules && p < solv->duprules_end)
    POOL_DEBUG(type, "DUP ");
  else if (p >= solv->jobrules && p < solv->jobrules_end)
    POOL_DEBUG(type, "JOB ");
  else if (p >= solv->updaterules && p < solv->updaterules_end)
    POOL_DEBUG(type, "UPDATE ");
  else if (p >= solv->featurerules && p < solv->featurerules_end)
    POOL_DEBUG(type, "FEATURE ");
  solver_printrule(solv, type, r);
}

void
solver_printproblem(Solver *solv, Id v)
{
  Pool *pool = solv->pool;
  int i;
  Rule *r;
  Id *jp;

  if (v > 0)
    solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, solv->rules + v);
  else
    {
      v = -(v + 1);
      POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "JOB %d\n", v);
      jp = solv->ruletojob.elements;
      for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
	if (*jp == v)
	  {
	    POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "- ");
	    solver_printrule(solv, SAT_DEBUG_SOLUTIONS, r);
	  }
      POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "ENDJOB\n");
    }
}

void
solver_printwatches(Solver *solv, int type)
{
  Pool *pool = solv->pool;
  int counter;

  POOL_DEBUG(type, "Watches: \n");
  for (counter = -(pool->nsolvables - 1); counter < pool->nsolvables; counter++)
    POOL_DEBUG(type, "    solvable [%d] -- rule [%d]\n", counter, solv->watches[counter + pool->nsolvables]);
}

/*
 * printdecisions
 */

void
solver_printdecisions(Solver *solv)
{
  Pool *pool = solv->pool;
  Repo *installed = solv->installed;
  Id p, *obsoletesmap = solver_create_decisions_obsoletesmap(solv);
  int i;
  Solvable *s;

  IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
    {
      POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions -----\n");
      for (i = 0; i < solv->decisionq.count; i++)
	{
	  p = solv->decisionq.elements[i];
	  solver_printruleelement(solv, SAT_DEBUG_SCHUBI, 0, p);
	}
      POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n");
    }

  POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
  POOL_DEBUG(SAT_DEBUG_RESULT, "transaction:\n");

  /* print solvables to be erased */

  if (installed)
    {
      FOR_REPO_SOLVABLES(installed, p, s)
	{
	  if (solv->decisionmap[p] > 0)
	    continue;
	  if (obsoletesmap[p])
	    continue;
	  POOL_DEBUG(SAT_DEBUG_RESULT, "  erase     %s\n", solvable2str(pool, s));
	}
    }

  /* print solvables to be installed */

  for (i = 0; i < solv->decisionq.count; i++)
    {
      int j;
      p = solv->decisionq.elements[i];
      if (p < 0)
	continue;
      if (p == SYSTEMSOLVABLE)
	continue;
      s = pool->solvables + p;
      if (installed && s->repo == installed)
	continue;

      if (!obsoletesmap[p])
        {
          POOL_DEBUG(SAT_DEBUG_RESULT, "  install   %s", solvable2str(pool, s));
        }
      else
	{
	  Id xp, xpp;
	  FOR_PROVIDES(xp, xpp, s->name)
	    {
	      Solvable *s2 = pool->solvables + xp;
	      if (s2->name != s->name)
		continue;
	      if (evrcmp(pool, s->evr, s2->evr, EVRCMP_MATCH_RELEASE) < 0)
		break;
	    }
	  if (xp)
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  downgrade %s", solvable2str(pool, s));
	  else
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  upgrade   %s", solvable2str(pool, s));
          POOL_DEBUG(SAT_DEBUG_RESULT, "  (obsoletes");
	  for (j = installed->start; j < installed->end; j++)
	    if (obsoletesmap[j] == p)
	      POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvable2str(pool, pool->solvables + j));
	  POOL_DEBUG(SAT_DEBUG_RESULT, ")");
	}
      POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
    }
  POOL_DEBUG(SAT_DEBUG_RESULT, "\n");

  sat_free(obsoletesmap);

  if (solv->recommendations.count)
    {
      POOL_DEBUG(SAT_DEBUG_RESULT, "recommended packages:\n");
      for (i = 0; i < solv->recommendations.count; i++)
	{
	  s = pool->solvables + solv->recommendations.elements[i];
          if (solv->decisionmap[solv->recommendations.elements[i]] > 0)
	    {
	      if (installed && s->repo == installed)
	        POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (installed)\n", solvable2str(pool, s));
	      else
	        POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (selected)\n", solvable2str(pool, s));
	    }
          else
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  %s\n", solvable2str(pool, s));
	}
      POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
    }

  if (solv->suggestions.count)
    {
      POOL_DEBUG(SAT_DEBUG_RESULT, "suggested packages:\n");
      for (i = 0; i < solv->suggestions.count; i++)
	{
	  s = pool->solvables + solv->suggestions.elements[i];
          if (solv->decisionmap[solv->suggestions.elements[i]] > 0)
	    {
	      if (installed && s->repo == installed)
	        POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (installed)\n", solvable2str(pool, s));
	      else
	        POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (selected)\n", solvable2str(pool, s));
	    }
	  else
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  %s\n", solvable2str(pool, s));
	}
      POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
    }
  if (solv->orphaned.count)
    {
      POOL_DEBUG(SAT_DEBUG_RESULT, "orphaned packages:\n");
      for (i = 0; i < solv->orphaned.count; i++)
	{
	  s = pool->solvables + solv->orphaned.elements[i];
          if (solv->decisionmap[solv->orphaned.elements[i]] > 0)
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (kept)\n", solvable2str(pool, s));
	  else
	    POOL_DEBUG(SAT_DEBUG_RESULT, "  %s (erased)\n", solvable2str(pool, s));
	}
      POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
    }
}

void
solver_printprobleminfo(Solver *solv, Queue *job, Id problem)
{
  Pool *pool = solv->pool;
  Id probr;
  Id dep, source, target;
  Solvable *s, *s2;

  probr = solver_findproblemrule(solv, problem);
  switch (solver_problemruleinfo(solv, job, probr, &dep, &source, &target))
    {
    case SOLVER_PROBLEM_DISTUPGRADE_RULE:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", solvable2str(pool, s));
      return;
    case SOLVER_PROBLEM_INFARCH_RULE:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "%s has inferior architecture\n", solvable2str(pool, s));
      return;
    case SOLVER_PROBLEM_UPDATE_RULE:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvable2str(pool, s));
      return;
    case SOLVER_PROBLEM_JOB_RULE:
      POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n");
      return;
    case SOLVER_PROBLEM_RPM_RULE:
      POOL_DEBUG(SAT_DEBUG_RESULT, "some dependency problem\n");
      return;
    case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
      POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides requested %s\n", dep2str(pool, dep));
      return;
    case SOLVER_PROBLEM_NOT_INSTALLABLE:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvable2str(pool, s));
      return;
    case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
      return;
    case SOLVER_PROBLEM_SAME_NAME:
      s = pool_id2solvable(pool, source);
      s2 = pool_id2solvable(pool, target);
      POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
      return;
    case SOLVER_PROBLEM_PACKAGE_CONFLICT:
      s = pool_id2solvable(pool, source);
      s2 = pool_id2solvable(pool, target);
      POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
      return;
    case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
      s = pool_id2solvable(pool, source);
      s2 = pool_id2solvable(pool, target);
      POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
      return;
    case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
      return;
    case SOLVER_PROBLEM_SELF_CONFLICT:
      s = pool_id2solvable(pool, source);
      POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", solvable2str(pool, s), dep2str(pool, dep));
      return;
    }
}

void
solver_printsolutions(Solver *solv, Queue *job)
{
  Pool *pool = solv->pool;
  int pcnt;
  Id p, rp, how, what, select;
  Id problem, solution, element;
  Solvable *s, *sd;

  POOL_DEBUG(SAT_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
  pcnt = 1;
  problem = 0;
  while ((problem = solver_next_problem(solv, problem)) != 0)
    {
      POOL_DEBUG(SAT_DEBUG_RESULT, "Problem %d:\n", pcnt++);
      POOL_DEBUG(SAT_DEBUG_RESULT, "====================================\n");
      solver_printprobleminfo(solv, job, problem);
      POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
      solution = 0;
      while ((solution = solver_next_solution(solv, problem, solution)) != 0)
        {
	  element = 0;
	  while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
	    {
	      if (p == SOLVER_SOLUTION_JOB)
		{
		  /* job, rp is index into job queue */
		  how = job->elements[rp - 1];
		  what = job->elements[rp];
		  select = how & SOLVER_SELECTMASK;
		  switch (how & SOLVER_JOBMASK)
		    {
		    case SOLVER_INSTALL:
		      if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvable2str(pool, pool->solvables + what));
		      else if (select == SOLVER_SOLVABLE_PROVIDES)
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable %s\n", solver_select2str(solv, select, what));
		      else
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", solver_select2str(solv, select, what));
		      break;
		    case SOLVER_ERASE:
		      if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvable2str(pool, pool->solvables + what));
		      else if (select == SOLVER_SOLVABLE_PROVIDES)
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables %s\n", solver_select2str(solv, select, what));
		      else
			POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", solver_select2str(solv, select, what));
		      break;
		    case SOLVER_UPDATE:
		      POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install most recent version of %s\n", solver_select2str(solv, select, what));
		      break;
		    case SOLVER_LOCK:
		      POOL_DEBUG(SAT_DEBUG_RESULT, "- do not lock %s\n", solver_select2str(solv, select, what));
		      break;
		    default:
		      POOL_DEBUG(SAT_DEBUG_RESULT, "- do something different\n");
		      break;
		    }
		}
	      else if (p == SOLVER_SOLUTION_INFARCH)
		{
		  s = pool->solvables + rp;
		  if (solv->installed && s->repo == solv->installed)
		    POOL_DEBUG(SAT_DEBUG_RESULT, "- keep %s despite the inferior architecture\n", solvable2str(pool, s));
		  else
		    POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s despite the inferior architecture\n", solvable2str(pool, s));
		}
	      else if (p == SOLVER_SOLUTION_DISTUPGRADE)
		{
		  s = pool->solvables + rp;
		  if (solv->installed && s->repo == solv->installed)
		    POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
		  else
		    POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s from excluded repository\n", solvable2str(pool, s));
		}
	      else
		{
		  /* policy, replace p with rp */
		  s = pool->solvables + p;
		  sd = rp ? pool->solvables + rp : 0;
		  if (s == sd && solv->distupgrade)
		    {
		      POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
		    }
		  else if (sd)
		    {
		      int gotone = 0;
		      if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
			{
			  POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
			  gotone = 1;
			}
		      if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(solv, s, sd))
			{
			  POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
			  gotone = 1;
			}
		      if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(solv, s, sd))
			{
			  if (sd->vendor)
			    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));
			  else
			    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));
			  gotone = 1;
			}
		      if (!gotone)
			POOL_DEBUG(SAT_DEBUG_RESULT, "- allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
		    }
		  else
		    {
		      POOL_DEBUG(SAT_DEBUG_RESULT, "- allow deinstallation of %s\n", solvable2str(pool, s));
		    }

		}
	    }
	  POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
        }
    }
}

void
solver_printtrivial(Solver *solv)
{
  Pool *pool = solv->pool;
  Queue in, out;
  Id p;
  const char *n; 
  Solvable *s; 
  int i;

  queue_init(&in);
  for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
    {   
      n = id2str(pool, s->name);
      if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
        continue;
      queue_push(&in, p); 
    }   
  if (!in.count)
    {
      queue_free(&in);
      return;
    }
  queue_init(&out);
  solver_trivial_installable(solv, &in, &out);
  POOL_DEBUG(SAT_DEBUG_RESULT, "trivial installable status:\n");
  for (i = 0; i < in.count; i++)
    POOL_DEBUG(SAT_DEBUG_RESULT, "  %s: %d\n", solvable2str(pool, pool->solvables + in.elements[i]), out.elements[i]);
  POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
  queue_free(&in);
  queue_free(&out);
}

const char *
solver_select2str(Solver *solv, Id select, Id what)
{
  Pool *pool = solv->pool;
  const char *s;
  char *b;
  if (select == SOLVER_SOLVABLE)
    return solvable2str(pool, pool->solvables + what);
  if (select == SOLVER_SOLVABLE_NAME)
    return dep2str(pool, what);
  if (select == SOLVER_SOLVABLE_PROVIDES)
    {
      s = dep2str(pool, what);
      b = pool_alloctmpspace(pool, 11 + strlen(s));
      sprintf(b, "providing %s", s);
      return b;
    }
  if (select == SOLVER_SOLVABLE_ONE_OF)
    {
      Id p;
      char *b2;
      b = "";
      while ((p = pool->whatprovidesdata[what++]) != 0)
	{
	  s = solvable2str(pool, pool->solvables + p);
	  b2 = pool_alloctmpspace(pool, strlen(b) + strlen(s) + 3);
	  sprintf(b2, "%s, %s", b, s);
	  b = b2;
	}
      return *b ? b + 2 : "nothing";
    }
  return "unknown job select";
}