From: Michael Schroeder Date: Wed, 8 Apr 2015 11:22:58 +0000 (+0200) Subject: Postpone creation of alternatives until all other rules are resolved X-Git-Tag: 0.6.11~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfed87a149a6a1c2ace71bad7362bfbc434a6b32;p=thirdparty%2Flibsolv.git Postpone creation of alternatives until all other rules are resolved Also optimize the sort_by_common_deps code a bit. --- diff --git a/src/policy.c b/src/policy.c index 773b829a..fadfcdae 100644 --- a/src/policy.c +++ b/src/policy.c @@ -891,9 +891,11 @@ sort_by_name_evr_sortcmp(const void *ap, const void *bp, void *dp) Id r = aa[1] - bb[1]; if (r) return r < 0 ? -1 : 1; + if (aa[2] == bb[2]) + return 0; a = aa[2] < 0 ? -aa[2] : aa[2]; b = bb[2] < 0 ? -bb[2] : bb[2]; - if (pool->disttype != DISTTYPE_DEB) + if (pool->disttype != DISTTYPE_DEB && a != b) { /* treat release-less versions different */ const char *as = pool_id2str(pool, a); @@ -1127,10 +1129,10 @@ policy_filter_unwanted(Solver *solv, Queue *plist, int mode) prune_to_best_arch(pool, plist); if (plist->count > 1) prune_to_best_version(pool, plist); - if (plist->count > 1 && mode == POLICY_MODE_CHOOSE) + if (plist->count > 1 && (mode == POLICY_MODE_CHOOSE || mode == POLICY_MODE_CHOOSE_NOREORDER)) { prune_to_recommended(solv, plist); - if (plist->count > 1) + if (plist->count > 1 && mode != POLICY_MODE_CHOOSE_NOREORDER) { /* do some fancy reordering */ #if 0 diff --git a/src/policy.h b/src/policy.h index a4dd4c42..73410eed 100644 --- a/src/policy.h +++ b/src/policy.h @@ -19,6 +19,7 @@ extern "C" { #define POLICY_MODE_CHOOSE 0 #define POLICY_MODE_RECOMMEND 1 #define POLICY_MODE_SUGGEST 2 +#define POLICY_MODE_CHOOSE_NOREORDER 3 /* internal, do not use */ #define POLICY_ILLEGAL_DOWNGRADE 1 diff --git a/src/solver.c b/src/solver.c index 53b4bc81..69e89ef3 100644 --- a/src/solver.c +++ b/src/solver.c @@ -2071,7 +2071,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) int i, j, n; Solvable *s; Pool *pool = solv->pool; - Id p, pp, *dp; + Id p, pp, *dp, postponed; int minimizationsteps; int installedpos = solv->installed ? solv->installed->start : 0; @@ -2338,8 +2338,17 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) if (!solv->decisioncnt_resolve) solv->decisioncnt_resolve = solv->decisionq.count; POOL_DEBUG(SOLV_DEBUG_POLICY, "deciding unresolved rules\n"); - for (i = 1, n = 1; n < solv->nrules; i++, n++) + postponed = 0; + for (i = 1, n = 1; ; i++, n++) { + if (n >= solv->nrules) + { + if (postponed <= 0) + break; + i = postponed; + postponed = -1; + n = 1; + } if (i == solv->nrules) i = 1; r = solv->rules + i; @@ -2421,6 +2430,17 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) } } + if (dq.count > 1 && postponed >= 0) + { + policy_filter_unwanted(solv, &dq, POLICY_MODE_CHOOSE_NOREORDER); + if (dq.count > 1) + { + if (!postponed) + postponed = i; + continue; + } + } + olevel = level; level = selectandinstall(solv, level, &dq, disablerules, r - solv->rules); if (level == 0) @@ -2431,7 +2451,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) n = 0; } - if (n != solv->nrules) /* ran into trouble? */ + if (n < solv->nrules) /* ran into trouble? */ { if (level == 0) break; /* unsolvable */