From 099da786c859e4cc74a17402cfea953e3d0365b6 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 15 Oct 2009 12:41:00 +0200 Subject: [PATCH] - add SOLVER_DROP_ORPHANED for coolo --- src/solver.c | 44 +++++++++++++++++++++++++++++++++----------- src/solver.h | 2 ++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/solver.c b/src/solver.c index 6c1c34c..34f0b4c 100644 --- a/src/solver.c +++ b/src/solver.c @@ -1295,6 +1295,7 @@ solver_free(Solver *solv) map_free(&solv->fixmap); map_free(&solv->dupmap); map_free(&solv->dupinvolvedmap); + map_free(&solv->droporphanedmap); sat_free(solv->decisionmap); sat_free(solv->rules); @@ -1929,7 +1930,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) int installedone = 0; /* let's see if we can install some unsupported package */ - POOL_DEBUG(SAT_DEBUG_SOLVER, "deciding unsupported packages\n"); + POOL_DEBUG(SAT_DEBUG_SOLVER, "deciding orphaned packages\n"); for (i = 0; i < solv->orphaned.count; i++) { p = solv->orphaned.elements[i]; @@ -1937,21 +1938,30 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) continue; /* already decided */ olevel = level; if (solv->distupgrade_removeunsupported) - { - POOL_DEBUG(SAT_DEBUG_SOLVER, "removing unsupported %s\n", solvid2str(pool, p)); - level = setpropagatelearn(solv, level, -p, 0, 0); - } - else - { - POOL_DEBUG(SAT_DEBUG_SOLVER, "keeping unsupported %s\n", solvid2str(pool, p)); - level = setpropagatelearn(solv, level, p, 0, 0); - installedone = 1; - } + continue; + if (solv->droporphanedmap.size && MAPTST(&solv->droporphanedmap, p - solv->installed->start)) + continue; + POOL_DEBUG(SAT_DEBUG_SOLVER, "keeping orphaned %s\n", solvid2str(pool, p)); + level = setpropagatelearn(solv, level, p, 0, 0); + installedone = 1; if (level < olevel) break; } if (installedone || i < solv->orphaned.count) continue; /* back to main loop */ + for (i = 0; i < solv->orphaned.count; i++) + { + p = solv->orphaned.elements[i]; + if (solv->decisionmap[p]) + continue; /* already decided */ + POOL_DEBUG(SAT_DEBUG_SOLVER, "removing orphaned %s\n", solvid2str(pool, p)); + olevel = level; + level = setpropagatelearn(solv, level, -p, 0, 0); + if (level < olevel) + break; + } + if (i < solv->orphaned.count) + continue; /* back to main loop */ } if (solv->solution_callback) @@ -2798,6 +2808,18 @@ solver_solve(Solver *solv, Queue *job) case SOLVER_DISTUPGRADE: POOL_DEBUG(SAT_DEBUG_JOB, "job: distupgrade %s\n", solver_select2str(solv, select, what)); break; + case SOLVER_DROP_ORPHANED: + POOL_DEBUG(SAT_DEBUG_JOB, "job: drop orphaned %s\n", solver_select2str(solv, select, what)); + FOR_JOB_SELECT(p, pp, select, what) + { + s = pool->solvables + p; + if (!installed || s->repo != installed) + continue; + if (!solv->droporphanedmap.size) + map_grow(&solv->droporphanedmap, installed->end - installed->start); + MAPSET(&solv->droporphanedmap, p - installed->start); + } + break; default: POOL_DEBUG(SAT_DEBUG_JOB, "job: unknown job\n"); break; diff --git a/src/solver.h b/src/solver.h index b93f9e2..e8ce937 100644 --- a/src/solver.h +++ b/src/solver.h @@ -204,6 +204,7 @@ typedef struct _Solver { Map dupmap; /* packages from dup repos */ Map dupinvolvedmap; /* packages involved in dup process */ + Map droporphanedmap; /* packages to drop in dup mode */ Queue *ruleinfoq; /* tmp space for solver_ruleinfo() */ } Solver; @@ -229,6 +230,7 @@ typedef struct _Solver { #define SOLVER_LOCK 0x0600 #define SOLVER_DISTUPGRADE 0x0700 #define SOLVER_VERIFY 0x0800 +#define SOLVER_DROP_ORPHANED 0x0900 #define SOLVER_JOBMASK 0xff00 -- 2.7.4