diff options
author | Michael Schroeder <mls@suse.de> | 2007-10-15 11:06:02 +0000 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2007-10-15 11:06:02 +0000 |
commit | ef55e590661e3efbe9470193c6f2baf0fd8d753f (patch) | |
tree | 2dc0e31576ef0b17517441cd48e95da882b1eac0 /src | |
parent | fd66530c72c759caf10d25878a97f976fd048121 (diff) | |
download | libsolv-ef55e590661e3efbe9470193c6f2baf0fd8d753f.tar.gz libsolv-ef55e590661e3efbe9470193c6f2baf0fd8d753f.tar.bz2 libsolv-ef55e590661e3efbe9470193c6f2baf0fd8d753f.zip |
make prune_to_recommended look at recommends, too.
Diffstat (limited to 'src')
-rw-r--r-- | src/bitmap.c | 8 | ||||
-rw-r--r-- | src/solver.c | 35 | ||||
-rw-r--r-- | src/solver.h | 44 |
3 files changed, 59 insertions, 28 deletions
diff --git a/src/bitmap.c b/src/bitmap.c index e8ce806..0ebd2d9 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -7,20 +7,20 @@ #include <string.h> #include "bitmap.h" +#include "util.h" void mapinit(Map *m, int n) { m->size = (n + 7) >> 3; - m->map = calloc(m->size, 1); + m->map = xcalloc(m->size, 1); } // free space allocated void mapfree(Map *m) { - free(m->map); - m->map = 0; + m->map = xfree(m->map); m->size = 0; } @@ -29,7 +29,7 @@ void clonemap(Map *t, Map *s) { t->size = s->size; - t->map = malloc(s->size); + t->map = xmalloc(s->size); memcpy(t->map, s->map, t->size); } diff --git a/src/solver.c b/src/solver.c index dc11b2c..6213b58 100644 --- a/src/solver.c +++ b/src/solver.c @@ -117,11 +117,34 @@ prune_to_recommended(Solver *solv, Queue *plist) Pool *pool = solv->pool; int i, j; Solvable *s; - Id sup, *supp; + Id p, *pp, sup, *supp, rec, *recp; + if (solv->recommends_index < 0) + { + MAPZERO(&solv->recommends); + solv->recommends_index = 0; + } + while (solv->recommends_index < solv->decisionq.count) + { + p = solv->decisionq.elements[solv->recommends_index++]; + if (p < 0) + continue; + s = pool->solvables + p; + if (!(recp = s->recommends)) + continue; + while ((rec = *recp++) != 0) + FOR_PROVIDES(p, pp, rec) + MAPSET(&solv->recommends, p); + } for (i = j = 0; i < plist->count; i++) { - s = pool->solvables + plist->elements[i]; + p = plist->elements[i]; + if (MAPTST(&solv->recommends, p)) + { + plist->elements[j++] = p; + continue; + } + s = pool->solvables + p; if (!s->supplements && !s->freshens) continue; if ((supp = s->supplements) != 0) @@ -621,10 +644,8 @@ addrule(Solver *solv, Id p, Id d) return r; /* direct conflict! */ for (i = 0; i < solv->decisionq.count; i++) - { if (solv->decisionq.elements[i] == -p) break; - } if (i == solv->decisionq.count) abort(); if (solv->decisionq_why.elements[i] == 0) @@ -1362,6 +1383,7 @@ reset_solver(Solver *solv) solv->decisionq_why.count = i; solv->decisionq.count = i; + solv->recommends_index = -1; if (i < solv->propagate_index) solv->propagate_index = i; /* make direct decisions from enabled unary rules */ @@ -1542,6 +1564,7 @@ revert(Solver *solv, int level) solv->decisionq_why.count--; solv->propagate_index = solv->decisionq.count; } + solv->recommends_index = -1; } @@ -1669,6 +1692,9 @@ solver_create(Pool *pool, Source *system) queueinit(&solv->learnt_why); queueinit(&solv->learnt_pool); + mapinit(&solv->recommends, pool->nsolvables); + solv->recommends_index = 0; + solv->decisionmap = (Id *)xcalloc(pool->nsolvables, sizeof(Id)); solv->rules = (Rule *)xmalloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule)); memset(solv->rules, 0, sizeof(Rule)); @@ -1689,6 +1715,7 @@ solver_free(Solver *solv) queuefree(&solv->decisionq_why); queuefree(&solv->learnt_why); queuefree(&solv->learnt_pool); + mapfree(&solv->recommends); xfree(solv->decisionmap); xfree(solv->rules); xfree(solv->watches); diff --git a/src/solver.h b/src/solver.h index 776978c..470b087 100644 --- a/src/solver.h +++ b/src/solver.h @@ -10,6 +10,7 @@ #include "pool.h" #include "source.h" #include "queue.h" +#include "bitmap.h" /* ---------------------------------------------- * Rule @@ -40,32 +41,32 @@ typedef struct solver { Pool *pool; Source *system; - int fixsystem; /* repair errors in rpm dependency graph */ - int allowdowngrade; /* allow to downgrade installed solvable */ - int allowarchchange; /* allow to change architecture of installed solvables */ - int allowuninstall; /* allow removal of system solvables, else keep all installed solvables */ - int updatesystem; /* distupgrade */ - int allowvirtualconflicts; /* false: conflicts on package name, true: conflicts on package provides */ + int fixsystem; /* repair errors in rpm dependency graph */ + int allowdowngrade; /* allow to downgrade installed solvable */ + int allowarchchange; /* allow to change architecture of installed solvables */ + int allowuninstall; /* allow removal of system solvables, else keep all installed solvables */ + int updatesystem; /* distupgrade */ + int allowvirtualconflicts; /* false: conflicts on package name, true: conflicts on package provides */ - Rule *rules; /* all rules */ - Id nrules; /* rpm rules */ + Rule *rules; /* all rules */ + Id nrules; /* rpm rules */ - Id jobrules; /* user rules */ - Id systemrules; /* policy rules, e.g. keep packages installed or update. All literals > 0 */ - Id learntrules; /* learnt rules */ + Id jobrules; /* user rules */ + Id systemrules; /* policy rules, e.g. keep packages installed or update. All literals > 0 */ + Id learntrules; /* learnt rules */ - Id *weaksystemrules; /* please try to install (r->d) */ + Id *weaksystemrules; /* please try to install (r->d) */ - Id *watches; /* Array of rule offsets - * watches has nsolvables*2 entries and is addressed from the middle - * middle-solvable : decision to conflict, offset point to linked-list of rules - * middle+solvable : decision to install: offset point to linked-list of rules - */ + Id *watches; /* Array of rule offsets + * watches has nsolvables*2 entries and is addressed from the middle + * middle-solvable : decision to conflict, offset point to linked-list of rules + * middle+solvable : decision to install: offset point to linked-list of rules + */ /* our decisions: */ Queue decisionq; - Queue decisionq_why; /* index of rule, Offset into rules */ - Id *decisionmap; /* map for all available solvables, > 0: level of decision when installed, < 0 level of decision when conflict */ + Queue decisionq_why; /* index of rule, Offset into rules */ + Id *decisionmap; /* map for all available solvables, > 0: level of decision when installed, < 0 level of decision when conflict */ /* learnt rule history */ Queue learnt_why; @@ -75,7 +76,10 @@ typedef struct solver { Queue problems; - int rc_output; /* output result compatible to redcarpet/zypp testsuite, set == 2 for pure rc (will suppress architecture) */ + Map recommends; /* recommended packages from decisionmap */ + int recommends_index; /* recommended level */ + + int rc_output; /* output result compatible to redcarpet/zypp testsuite, set == 2 for pure rc (will suppress architecture) */ } Solver; /* |