Author: kkaempf Date: Thu Feb 7 16:35:33 2008 New Revision: 8535 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8535&view=rev Log: honor Solver.limittokind Modified: trunk/sat-solver/src/policy.c Modified: trunk/sat-solver/src/policy.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/policy.c?rev=8535&r1=8534&r2=8535&view=diff ============================================================================== --- trunk/sat-solver/src/policy.c (original) +++ trunk/sat-solver/src/policy.c Thu Feb 7 16:35:33 2008 @@ -73,6 +73,34 @@ return a - b; } + +/* + * prune queue, only keep solvables of kind + * + */ + +static void +prune_to_kind(Pool *pool, Queue *plist, solvable_kind kind) +{ + int i, j; + Solvable *s; + + /* prune to highest priority */ + for (i = j = 0; i < plist->count; i++) + { + s = pool->solvables + plist->elements[i]; + if (s->kind == kind) + plist->elements[j++] = plist->elements[i]; + } + plist->count = j; +} + + +/* + * prune to repository with highest priority + * + */ + static void prune_to_highest_prio(Pool *pool, Queue *plist) { @@ -81,13 +109,13 @@ int bestprio = 0; /* prune to highest priority */ - for (i = 0; i < plist->count; i++) + for (i = 0; i < plist->count; i++) /* find highest prio in queue */ { s = pool->solvables + plist->elements[i]; if (i == 0 || s->repo->priority > bestprio) bestprio = s->repo->priority; } - for (i = j = 0; i < plist->count; i++) + for (i = j = 0; i < plist->count; i++) /* remove all with lower prio */ { s = pool->solvables + plist->elements[i]; if (s->repo->priority == bestprio) @@ -96,12 +124,14 @@ plist->count = j; } + /* * prune_to_recommended * * XXX: should we prune to requires/suggests that are already * fulfilled by other packages? */ + static void prune_to_recommended(Solver *solv, Queue *plist) { @@ -296,6 +326,11 @@ plist->count = j; } + +/* legacy, do not use anymore! + * (rates arch higher than version, but thats a policy) + */ + void prune_best_arch_name_version(Solver *solv, Pool *pool, Queue *plist) { @@ -315,6 +350,8 @@ policy_filter_unwanted(Solver *solv, Queue *plist, Id inst, int mode) { Pool *pool = solv->pool; + if (plist->count > 1 && solv->limittokind) + prune_to_kind(pool, plist, solv->limittokind-1); if (plist->count > 1 && mode != POLICY_MODE_SUGGEST) prune_to_highest_prio(pool, plist); if (plist->count > 1 && mode == POLICY_MODE_CHOOSE) -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org