From: Michael Schroeder Date: Fri, 26 Oct 2012 13:17:51 +0000 (+0200) Subject: support SOLVER_SOLVABLE_REPO and SOLVER_SOLVABLE_ALL in more job types, even if many... X-Git-Tag: BASE-SuSE-Code-12_3-Branch~212 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb28413d8e7463e364a4a994331e87a452d1cd74;p=thirdparty%2Flibsolv.git support SOLVER_SOLVABLE_REPO and SOLVER_SOLVABLE_ALL in more job types, even if many are not meaningful --- diff --git a/src/pool.h b/src/pool.h index bf525221..77ee7ecd 100644 --- a/src/pool.h +++ b/src/pool.h @@ -344,9 +344,16 @@ void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts); /* loop over all repositories */ #define FOR_REPOS(repoid, r) \ - for (repoid = 1; repoid < pool->nrepos; repoid++) \ - if ((r = pool->repos[repoid]) != 0) - + for (repoid = 1; repoid < pool->nrepos; repoid++) \ + if ((r = pool->repos[repoid]) == 0) \ + continue; \ + else + +#define FOR_POOL_SOLVABLES(p) \ + for (p = 2; p < pool->nsolvables; p++) \ + if (pool->solvables[p].repo == 0) \ + continue; \ + else #ifdef ENABLE_COMPS #define ISCONDDEP(id) (ISRELDEP(id) && (GETRELDEP(pool, id))->flags == REL_COND) diff --git a/src/rules.c b/src/rules.c index b565282b..990a2ab1 100644 --- a/src/rules.c +++ b/src/rules.c @@ -1495,6 +1495,8 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q) else { int qcnt = q->count; + /* does not work for SOLVER_SOLVABLE_ALL and SOLVER_SOLVABLE_REPO, but + they are not useful for SOLVER_INSTALL jobs anyway */ FOR_JOB_SELECT(p, pp, select, what) { s = pool->solvables + p; @@ -1618,6 +1620,9 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q) case SOLVER_ERASE: if (!installed) break; + if (select == SOLVER_SOLVABLE_ALL || (select == SOLVER_SOLVABLE_REPO && what == installed->repoid)) + FOR_REPO_SOLVABLES(installed, p, s) + queue_push2(q, DISABLE_UPDATE, p); FOR_JOB_SELECT(p, pp, select, what) if (pool->solvables[p].repo == installed) queue_push2(q, DISABLE_UPDATE, p); @@ -2403,6 +2408,9 @@ solver_createcleandepsmap(Solver *solv, Map *cleandepsmap, int unneeded) { what = job->elements[i + 1]; select = how & SOLVER_SELECTMASK; + if (select == SOLVER_SOLVABLE_ALL || (select == SOLVER_SOLVABLE_REPO && what == installed->repoid)) + FOR_REPO_SOLVABLES(installed, p, s) + MAPSET(&userinstalled, p - installed->start); FOR_JOB_SELECT(p, pp, select, what) if (pool->solvables[p].repo == installed) MAPSET(&userinstalled, p - installed->start); diff --git a/src/selection.c b/src/selection.c index 4ad9cc77..2f5ca917 100644 --- a/src/selection.c +++ b/src/selection.c @@ -87,9 +87,8 @@ selection_solvables(Pool *pool, Queue *selection, Queue *pkgs) Id select = selection->elements[i] & SOLVER_SELECTMASK; if (select == SOLVER_SOLVABLE_ALL) { - for (p = 2; p < pool->nsolvables; p++) - if (pool->solvables[p].repo) - queue_push(pkgs, p); + FOR_POOL_SOLVABLES(p) + queue_push(pkgs, p); } if (select == SOLVER_SOLVABLE_REPO) { @@ -534,11 +533,13 @@ selection_limit(Pool *pool, Queue *sel1, Queue *sel2) miss = 0; if (select == SOLVER_SOLVABLE_ALL) { - for (p = 2; p < pool->nsolvables; p++) - if (map_tst(&m2, p)) - queue_push(&q1, p); - else - miss = 1; + FOR_POOL_SOLVABLES(p) + { + if (map_tst(&m2, p)) + queue_push(&q1, p); + else + miss = 1; + } } else if (select == SOLVER_SOLVABLE_REPO) { diff --git a/src/selection.h b/src/selection.h index 2966b991..0bd6a4d8 100644 --- a/src/selection.h +++ b/src/selection.h @@ -24,7 +24,7 @@ #define SELECTION_FLAT (1 << 10) #define SELECTION_NOCASE (1 << 11) -extern int selection_make(Pool *pool, Queue *selection, const char *name, int flags); +extern int selection_make(Pool *pool, Queue *selection, const char *name, int flags); extern void selection_limit(Pool *pool, Queue *sel1, Queue *sel2); extern void selection_add(Pool *pool, Queue *sel1, Queue *sel2); extern void selection_solvables(Pool *pool, Queue *selection, Queue *pkgs); diff --git a/src/solver.c b/src/solver.c index a284017d..323d2be0 100644 --- a/src/solver.c +++ b/src/solver.c @@ -2529,6 +2529,19 @@ solver_calculate_noobsmap(Pool *pool, Queue *job, Map *noobsmap) select = how & SOLVER_SELECTMASK; if (!noobsmap->size) map_grow(noobsmap, pool->nsolvables); + if (select == SOLVER_SOLVABLE_ALL) + { + FOR_POOL_SOLVABLES(p) + MAPSET(noobsmap, p); + } + else if (select == SOLVER_SOLVABLE_REPO) + { + Solvable *s; + Repo *repo = pool_id2repo(pool, what); + if (repo) + FOR_REPO_SOLVABLES(repo, p, s) + MAPSET(noobsmap, p); + } FOR_JOB_SELECT(p, pp, select, what) MAPSET(noobsmap, p); } @@ -2620,7 +2633,7 @@ solver_solve(Solver *solv, Queue *job) switch (how & SOLVER_JOBMASK) { case SOLVER_VERIFY: - if (select == SOLVER_SOLVABLE_ALL) + if (select == SOLVER_SOLVABLE_ALL || (select == SOLVER_SOLVABLE_REPO && solv->installed && what == solv->installed->repoid)) solv->fixmap_all = 1; FOR_JOB_SELECT(p, pp, select, what) { @@ -2633,7 +2646,7 @@ solver_solve(Solver *solv, Queue *job) } break; case SOLVER_UPDATE: - if (select == SOLVER_SOLVABLE_ALL) + if (select == SOLVER_SOLVABLE_ALL || (select == SOLVER_SOLVABLE_REPO && solv->installed && what == solv->installed->repoid)) solv->updatemap_all = 1; FOR_JOB_SELECT(p, pp, select, what) { @@ -2861,7 +2874,20 @@ solver_solve(Solver *solv, Queue *job) POOL_DEBUG(SOLV_DEBUG_JOB, "job: %s%serase %s\n", weak ? "weak " : "", how & SOLVER_CLEANDEPS ? "clean deps " : "", solver_select2str(pool, select, what)); if ((how & SOLVER_CLEANDEPS) != 0 && !solv->cleandepsmap.size && installed) map_grow(&solv->cleandepsmap, installed->end - installed->start); + /* specific solvable: by id or by nevra */ name = (select == SOLVER_SOLVABLE || (select == SOLVER_SOLVABLE_NAME && ISRELDEP(what))) ? 0 : -1; + if (select == SOLVER_SOLVABLE_ALL) /* hmmm ;) */ + { + FOR_POOL_SOLVABLES(p) + solver_addjobrule(solv, -p, 0, i, weak); + } + else if (select == SOLVER_SOLVABLE_REPO) + { + Repo *repo = pool_id2repo(pool, what); + if (repo) + FOR_REPO_SOLVABLES(repo, p, s) + solver_addjobrule(solv, -p, 0, i, weak); + } FOR_JOB_SELECT(p, pp, select, what) { s = pool->solvables + p; @@ -2903,6 +2929,20 @@ solver_solve(Solver *solv, Queue *job) case SOLVER_UPDATE: if ((how & SOLVER_CLEANDEPS) != 0 && installed) { + if (how == SOLVER_SOLVABLE_ALL || (how == SOLVER_SOLVABLE_REPO && what == installed->repoid)) + { + FOR_REPO_SOLVABLES(installed, p, s) + { + if (!solv->cleandeps_updatepkgs) + { + solv->cleandeps_updatepkgs = solv_calloc(1, sizeof(Queue)); + queue_init(solv->cleandeps_updatepkgs); + } + queue_pushunique(solv->cleandeps_updatepkgs, p); + if (!solv->cleandepsmap.size) + map_grow(&solv->cleandepsmap, installed->end - installed->start); + } + } FOR_JOB_SELECT(p, pp, select, what) { s = pool->solvables + p; @@ -2935,18 +2975,27 @@ solver_solve(Solver *solv, Queue *job) break; case SOLVER_LOCK: POOL_DEBUG(SOLV_DEBUG_JOB, "job: %slock %s\n", weak ? "weak " : "", solver_select2str(pool, select, what)); - FOR_JOB_SELECT(p, pp, select, what) + if (select == SOLVER_SOLVABLE_ALL) { - s = pool->solvables + p; - solver_addjobrule(solv, installed && s->repo == installed ? p : -p, 0, i, weak); + FOR_POOL_SOLVABLES(p) + solver_addjobrule(solv, installed && pool->solvables[p].repo == installed ? p : -p, 0, i, weak); } + else if (select == SOLVER_SOLVABLE_REPO) + { + Repo *repo = pool_id2repo(pool, what); + if (repo) + FOR_REPO_SOLVABLES(repo, p, s) + solver_addjobrule(solv, installed && pool->solvables[p].repo == installed ? p : -p, 0, i, weak); + } + FOR_JOB_SELECT(p, pp, select, what) + solver_addjobrule(solv, installed && pool->solvables[p].repo == installed ? p : -p, 0, i, weak); break; case SOLVER_DISTUPGRADE: POOL_DEBUG(SOLV_DEBUG_JOB, "job: distupgrade %s\n", solver_select2str(pool, select, what)); break; case SOLVER_DROP_ORPHANED: POOL_DEBUG(SOLV_DEBUG_JOB, "job: drop orphaned %s\n", solver_select2str(pool, select, what)); - if (select == SOLVER_SOLVABLE_ALL) + if (select == SOLVER_SOLVABLE_ALL || (select == SOLVER_SOLVABLE_REPO && installed && what == installed->repoid)) solv->droporphanedmap_all = 1; FOR_JOB_SELECT(p, pp, select, what) { @@ -3600,9 +3649,8 @@ pool_job2solvables(Pool *pool, Queue *pkgs, Id how, Id what) queue_empty(pkgs); if (how == SOLVER_SOLVABLE_ALL) { - for (p = 2; p < pool->nsolvables; p++) - if (pool->solvables[p].repo) - queue_push(pkgs, p); + FOR_POOL_SOLVABLES(p) + queue_push(pkgs, p); } else if (how == SOLVER_SOLVABLE_REPO) {