From: Michael Schroeder Date: Fri, 11 Apr 2008 08:50:10 +0000 (+0000) Subject: - change DU interface to use installedmap, like the trivial functions X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~419 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83d4f0dfe33a0d606fdef66e97eea8bdd8fd1f70;p=thirdparty%2Flibsolv.git - change DU interface to use installedmap, like the trivial functions --- diff --git a/src/pool.c b/src/pool.c index 05a283ac..b29aaaa9 100644 --- a/src/pool.c +++ b/src/pool.c @@ -965,6 +965,7 @@ struct ducbdata { DUChanges *mps; struct mptree *mptree; int addsub; + int hasdu; Id *dirmap; int nmap; @@ -1030,6 +1031,7 @@ solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyVa cbd->nmap = data->dirpool.ndirs; cbd->olddata = data; } + cbd->hasdu = 1; if (value->id < 0 || value->id >= cbd->nmap) return 0; mp = cbd->dirmap[value->id]; @@ -1063,7 +1065,7 @@ propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint) #define MPTREE_BLOCK 15 void -pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps) +pool_calc_duchanges(Pool *pool, Repo *oldinstalled, Map *installedmap, DUChanges *mps, int nmps) { char *p; const char *path, *compstr; @@ -1072,7 +1074,11 @@ pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps) int pos, compl; int mp; struct ducbdata cbd; + Solvable *s; + Id sp; + Map ignoredu; + memset(&ignoredu, 0, sizeof(ignoredu)); cbd.mps = mps; cbd.addsub = 0; cbd.dirmap = 0; @@ -1149,36 +1155,76 @@ pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps) cbd.mptree = mptree; cbd.addsub = 1; - for (i = 0; i < pkgs->count; i++) + for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++) { - Id sp = pkgs->elements[i]; - if (sp > 0) - repo_search(pool->solvables[sp].repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd); + if (!s->repo || (oldinstalled && s->repo == oldinstalled)) + continue; + if (!MAPTST(installedmap, sp)) + continue; + cbd.hasdu = 0; + repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd); + if (!cbd.hasdu && oldinstalled) + { + Id op, *opp; + /* no du data available, ignore data of all installed solvables we obsolete */ + if (!ignoredu.map) + map_init(&ignoredu, oldinstalled->end - oldinstalled->start); + if (s->obsoletes) + { + Id obs, *obsp = s->repo->idarraydata + s->obsoletes; + while ((obs = *obsp++) != 0) + FOR_PROVIDES(op, opp, obs) + if (op >= oldinstalled->start && op < oldinstalled->end) + MAPSET(&ignoredu, op - oldinstalled->start); + } + FOR_PROVIDES(op, opp, s->name) + if (pool->solvables[op].name == s->name) + if (op >= oldinstalled->start && op < oldinstalled->end) + MAPSET(&ignoredu, op - oldinstalled->start); + } } cbd.addsub = -1; - for (i = 0; i < pkgs->count; i++) + if (oldinstalled) { - Id sp = pkgs->elements[i]; - if (sp < 0) - repo_search(pool->solvables[-sp].repo, -sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd); + /* assumes we allways have du data for installed solvables */ + FOR_REPO_SOLVABLES(oldinstalled, sp, s) + { + if (MAPTST(installedmap, sp)) + continue; + if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start)) + continue; + repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd); + } } + if (ignoredu.map) + map_free(&ignoredu); sat_free(cbd.dirmap); sat_free(mptree); } int -pool_calc_installsizechange(Pool *pool, Queue *pkgs) +pool_calc_installsizechange(Pool *pool, Repo *oldinstalled, Map *installedmap) { - int i, change; + Id sp; + Solvable *s; + int change = 0; - change = 0; - for (i = 0; i < pkgs->count; i++) + for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++) + { + if (!s->repo || (oldinstalled && s->repo == oldinstalled)) + continue; + if (!MAPTST(installedmap, sp)) + continue; + change += repo_lookup_num(s, SOLVABLE_INSTALLSIZE); + } + if (oldinstalled) { - Id sp = pkgs->elements[i]; - if (sp > 0) - change += repo_lookup_num(pool->solvables + sp, SOLVABLE_INSTALLSIZE); - else if (sp < 0) - change -= repo_lookup_num(pool->solvables - sp, SOLVABLE_INSTALLSIZE); + FOR_REPO_SOLVABLES(oldinstalled, sp, s) + { + if (MAPTST(installedmap, sp)) + continue; + change -= repo_lookup_num(s, SOLVABLE_INSTALLSIZE); + } } return change; } diff --git a/src/pool.h b/src/pool.h index 0f7f8720..965ce582 100644 --- a/src/pool.h +++ b/src/pool.h @@ -253,8 +253,8 @@ typedef struct _duchanges { int files; } DUChanges; -void pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps); -int pool_calc_installsizechange(Pool *pool, Queue *pkgs); +void pool_calc_duchanges(Pool *pool, struct _Repo *oldinstalled, Map *installedmap, DUChanges *mps, int nmps); +int pool_calc_installsizechange(Pool *pool, struct _Repo *oldinstalled, Map *installedmap); /* loop over all providers of d */ #define FOR_PROVIDES(v, vp, d) \ diff --git a/src/solver.c b/src/solver.c index 0dbab057..c21af311 100644 --- a/src/solver.c +++ b/src/solver.c @@ -4150,63 +4150,35 @@ solver_solve(Solver *solv, Queue *job) /***********************************************************************/ void -solver_calc_changed_pkgs(Solver *solv, Queue *pkgs) +solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps) { Pool *pool = solv->pool; - Map installmap; - Solvable *s; - int i; + Map installedmap; Id p; + int i; - /* create list of solvables that have to be installed */ - /* (this is actually just a simple sort) */ - map_init(&installmap, pool->nsolvables); + map_init(&installedmap, pool->nsolvables); for (i = 1; i < solv->decisionq.count; i++) - { - Id p = solv->decisionq.elements[i]; - if (p < 0) - continue; - s = pool->solvables + p; - if (!s->repo) - continue; - if (solv->installed && s->repo == solv->installed) - continue; - MAPSET(&installmap, p); - } - for (p = 1; p < pool->nsolvables; p++) - if (MAPTST(&installmap, p)) - queue_push(pkgs, p); - map_free(&installmap); - /* run through erase solvable dudata */ - if (solv->installed) - { - FOR_REPO_SOLVABLES(solv->installed, p, s) - { - if (solv->decisionmap[p] < 0) - queue_push(pkgs, -p); - } - } -} - -void -solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps) -{ - Queue pkgs; - queue_init(&pkgs); - solver_calc_changed_pkgs(solv, &pkgs); - pool_calc_duchanges(solv->pool, &pkgs, mps, nmps); - queue_free(&pkgs); + if ((p = solv->decisionq.elements[i]) > 0) + MAPSET(&installedmap, p); + pool_calc_duchanges(pool, solv->installed, &installedmap, mps, nmps); + map_free(&installedmap); } int solver_calc_installsizechange(Solver *solv) { - int change; - Queue pkgs; - queue_init(&pkgs); - solver_calc_changed_pkgs(solv, &pkgs); - change = pool_calc_installsizechange(solv->pool, &pkgs); - queue_free(&pkgs); + Pool *pool = solv->pool; + Map installedmap; + Id p; + int i, change; + + map_init(&installedmap, pool->nsolvables); + for (i = 1; i < solv->decisionq.count; i++) + if ((p = solv->decisionq.elements[i]) > 0) + MAPSET(&installedmap, p); + change = pool_calc_installsizechange(solv->pool, solv->installed, &installedmap); + map_free(&installedmap); return change; } diff --git a/src/solver.h b/src/solver.h index 9966f66d..383abe2d 100644 --- a/src/solver.h +++ b/src/solver.h @@ -284,7 +284,6 @@ solver_is_enhancing(Solver *solv, Solvable *s) return 0; } -void solver_calc_changed_pkgs(Solver *solv, Queue *pkgs); void solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps); int solver_calc_installsizechange(Solver *solv);