diff options
author | Michael Schroeder <mls@suse.de> | 2012-11-30 14:28:10 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-11-30 14:28:10 +0100 |
commit | b3b6c1720880643b3dab626d5d96ffef18609141 (patch) | |
tree | b30dd70edd7e75cddd0aa76c6dc80ffe435a437b | |
parent | 936782d2daf5e9396fccdcb6c897ecd6268c9b84 (diff) | |
download | libsolv-b3b6c1720880643b3dab626d5d96ffef18609141.tar.gz libsolv-b3b6c1720880643b3dab626d5d96ffef18609141.tar.bz2 libsolv-b3b6c1720880643b3dab626d5d96ffef18609141.zip |
another targeted dup fix, add testcases
-rw-r--r-- | ext/testcase.c | 1 | ||||
-rw-r--r-- | src/rules.c | 228 | ||||
-rw-r--r-- | test/testcases/targeted/targeted_dup.t | 48 | ||||
-rw-r--r-- | test/testcases/targeted/targeted_up.t | 48 |
4 files changed, 198 insertions, 127 deletions
diff --git a/ext/testcase.c b/ext/testcase.c index 7464669..589aef3 100644 --- a/ext/testcase.c +++ b/ext/testcase.c @@ -55,6 +55,7 @@ static struct jobflags2str { { SOLVER_CLEANDEPS, "cleandeps" }, { SOLVER_ORUPDATE, "orupdate" }, { SOLVER_FORCEBEST, "forcebest" }, + { SOLVER_TARGETED, "targeted" }, { SOLVER_SETEV, "setev" }, { SOLVER_SETEVR, "setevr" }, { SOLVER_SETARCH, "setarch" }, diff --git a/src/rules.c b/src/rules.c index 7764bdf..2747422 100644 --- a/src/rules.c +++ b/src/rules.c @@ -1181,15 +1181,92 @@ reenableinfarchrule(Solver *solv, Id name) *** ***/ +static inline void +solver_addtodupmaps(Solver *solv, Id p, Id how, int targeted) +{ + Pool *pool = solv->pool; + Solvable *ps, *s = pool->solvables + p; + Repo *installed = solv->installed; + Id pi, pip, obs, *obsp; + + MAPSET(&solv->dupinvolvedmap, p); + if (targeted) + MAPSET(&solv->dupmap, p); + FOR_PROVIDES(pi, pip, s->name) + { + ps = pool->solvables + pi; + if (ps->name != s->name) + continue; + MAPSET(&solv->dupinvolvedmap, pi); + if (ps->repo == installed && solv->obsoletes && solv->obsoletes[pi - installed->start]) + { + Id *opp, pi2; + for (opp = solv->obsoletes_data + solv->obsoletes[pi - installed->start]; (pi2 = *opp++) != 0;) + if (pool->solvables[pi2].repo != installed) + MAPSET(&solv->dupinvolvedmap, pi2); + } + if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) + { + if (!solv->bestupdatemap.size) + map_grow(&solv->bestupdatemap, installed->end - installed->start); + MAPSET(&solv->bestupdatemap, pi - installed->start); + } + if (!targeted && ps->repo != installed) + MAPSET(&solv->dupmap, pi); + } + if (s->repo == installed && solv->obsoletes && solv->obsoletes[p - installed->start]) + { + Id *opp; + for (opp = solv->obsoletes_data + solv->obsoletes[p - installed->start]; (pi = *opp++) != 0;) + { + ps = pool->solvables + pi; + if (ps->repo == installed) + continue; + MAPSET(&solv->dupinvolvedmap, pi); + if (!targeted) + MAPSET(&solv->dupmap, pi); + } + } + if (targeted && s->repo != installed && s->obsoletes) + { + /* XXX: check obsoletes/provides combination */ + obsp = s->repo->idarraydata + s->obsoletes; + while ((obs = *obsp++) != 0) + { + FOR_PROVIDES(pi, pip, obs) + { + Solvable *ps = pool->solvables + pi; + if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs)) + continue; + if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps)) + continue; + MAPSET(&solv->dupinvolvedmap, pi); + if (ps->repo == installed && solv->obsoletes && solv->obsoletes[pi - installed->start]) + { + Id *opp, pi2; + for (opp = solv->obsoletes_data + solv->obsoletes[pi - installed->start]; (pi2 = *opp++) != 0;) + if (pool->solvables[pi2].repo != installed) + MAPSET(&solv->dupinvolvedmap, pi2); + } + if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) + { + if (!solv->bestupdatemap.size) + map_grow(&solv->bestupdatemap, installed->end - installed->start); + MAPSET(&solv->bestupdatemap, pi - installed->start); + } + } + } + } +} + void solver_createdupmaps(Solver *solv) { Queue *job = &solv->job; Pool *pool = solv->pool; - Repo *repo; Repo *installed = solv->installed; - Id select, how, what, p, pi, pp, pip, obs, *obsp; - Solvable *s, *ps; + Id select, how, what, p, pp; + Solvable *s; int i, targeted; map_init(&solv->dupmap, pool->nsolvables); @@ -1202,7 +1279,25 @@ solver_createdupmaps(Solver *solv) switch (how & SOLVER_JOBMASK) { case SOLVER_DISTUPGRADE: - if (select != SOLVER_SOLVABLE_REPO) + if (select == SOLVER_SOLVABLE_REPO) + { + Repo *repo; + if (what <= 0 || what > pool->nrepos) + break; + repo = pool_id2repo(pool, what); + if (!repo) + break; + if (repo != installed && !(how & SOLVER_TARGETED) && solv->noautotarget) + break; + targeted = repo != installed || (how & SOLVER_TARGETED) != 0; + FOR_REPO_SOLVABLES(repo, p, s) + { + if (repo != installed && !pool_installable(pool, s)) + continue; + solver_addtodupmaps(solv, p, how, targeted); + } + } + else { targeted = how & SOLVER_TARGETED ? 1 : 0; if (installed && !targeted && !solv->noautotarget) @@ -1219,132 +1314,11 @@ solver_createdupmaps(Solver *solv) Solvable *s = pool->solvables + p; if (!s->repo) continue; - if (!targeted && s->repo != installed) + if (s->repo != installed && !targeted) continue; if (s->repo != installed && !pool_installable(pool, s)) continue; - MAPSET(&solv->dupinvolvedmap, p); - if (targeted) - MAPSET(&solv->dupmap, p); - FOR_PROVIDES(pi, pip, s->name) - { - ps = pool->solvables + pi; - if (ps->name != s->name) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) - { - if (!solv->bestupdatemap.size) - map_grow(&solv->bestupdatemap, installed->end - installed->start); - MAPSET(&solv->bestupdatemap, pi - installed->start); - } - if (!targeted && ps->repo != installed) - MAPSET(&solv->dupmap, pi); - } - if (s->repo == installed && solv->obsoletes && solv->obsoletes[p - installed->start]) - { - Id *opp; - for (opp = solv->obsoletes_data + solv->obsoletes[p - installed->start]; (pi = *opp++) != 0;) - { - ps = pool->solvables + pi; - if (ps->repo == installed) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (!targeted) - MAPSET(&solv->dupmap, pi); - } - } - if (targeted && s->obsoletes) - { - /* XXX: check obsoletes/provides combination */ - obsp = s->repo->idarraydata + s->obsoletes; - while ((obs = *obsp++) != 0) - { - FOR_PROVIDES(pi, pp, obs) - { - Solvable *ps = pool->solvables + pi; - if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs)) - continue; - if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps)) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) - { - if (!solv->bestupdatemap.size) - map_grow(&solv->bestupdatemap, installed->end - installed->start); - MAPSET(&solv->bestupdatemap, pi - installed->start); - } - } - } - } - } - break; - } - if (what <= 0 || what > pool->nrepos) - break; - repo = pool_id2repo(pool, what); - if (!repo) - break; - if (repo != installed && !(how & SOLVER_TARGETED) && solv->noautotarget) - break; - targeted = repo != installed || (how & SOLVER_TARGETED) != 0; - FOR_REPO_SOLVABLES(repo, p, s) - { - if (repo != installed && !pool_installable(pool, s)) - continue; - MAPSET(&solv->dupinvolvedmap, p); - if (targeted) - MAPSET(&solv->dupmap, p); - FOR_PROVIDES(pi, pip, s->name) - { - ps = pool->solvables + pi; - if (ps->name != s->name) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) - { - if (!solv->bestupdatemap.size) - map_grow(&solv->bestupdatemap, installed->end - installed->start); - MAPSET(&solv->bestupdatemap, pi - installed->start); - } - if (!targeted && ps->repo != installed) - MAPSET(&solv->dupmap, pi); - } - if (s->repo == installed && solv->obsoletes && solv->obsoletes[p - installed->start]) - { - Id *opp; - for (opp = solv->obsoletes_data + solv->obsoletes[p - installed->start]; (pi = *opp++) != 0;) - { - ps = pool->solvables + pi; - if (ps->repo == installed) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (!targeted) - MAPSET(&solv->dupmap, pi); - } - } - if (targeted && s->obsoletes) - { - /* XXX: check obsoletes/provides combination */ - obsp = s->repo->idarraydata + s->obsoletes; - while ((obs = *obsp++) != 0) - { - FOR_PROVIDES(pi, pp, obs) - { - Solvable *ps = pool->solvables + pi; - if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs)) - continue; - if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps)) - continue; - MAPSET(&solv->dupinvolvedmap, pi); - if (ps->repo == installed && (how & SOLVER_FORCEBEST) != 0) - { - if (!solv->bestupdatemap.size) - map_grow(&solv->bestupdatemap, installed->end - installed->start); - MAPSET(&solv->bestupdatemap, pi - installed->start); - } - } - } + solver_addtodupmaps(solv, p, how, targeted); } } break; diff --git a/test/testcases/targeted/targeted_dup.t b/test/testcases/targeted/targeted_dup.t new file mode 100644 index 0000000..4815941 --- /dev/null +++ b/test/testcases/targeted/targeted_dup.t @@ -0,0 +1,48 @@ +repo system 0 testtags <inline> +#>=Pkg: A 1 1 noarch +#>+Prv: +#>A = 1-1 +#>-Prv: +repo available 0 testtags <inline> +#>=Pkg: A 2 1 noarch +#>+Prv: +#>A = 2-1 +#>-Prv: +#>=Pkg: B 1 0 noarch +#>+Prv: +#>B = 1-0 +#>-Prv: +#>+Obs: +#>A +#>-Obs: +system i686 rpm system + +# first check untargeted +job distupgrade name A = 1-1 +result transaction,problems <inline> +#>erase A-1-1.noarch@system B-1-0.noarch@available +#>install B-1-0.noarch@available + +# then targeted to A-2-1 +nextjob +job distupgrade name A = 2-1 +result transaction,problems <inline> +#>upgrade A-1-1.noarch@system A-2-1.noarch@available + +# then targeted to B +nextjob +job distupgrade name B +result transaction,problems <inline> +#>erase A-1-1.noarch@system B-1-0.noarch@available +#>install B-1-0.noarch@available + +# first check forced to targeted +nextjob +job distupgrade name A = 1-1 [targeted] +result transaction,problems <inline> + +# second check forced to untargeted +nextjob +solverflags noautotarget +job distupgrade name A = 2-1 +result transaction,problems <inline> diff --git a/test/testcases/targeted/targeted_up.t b/test/testcases/targeted/targeted_up.t new file mode 100644 index 0000000..4e5c4bc --- /dev/null +++ b/test/testcases/targeted/targeted_up.t @@ -0,0 +1,48 @@ +repo system 0 testtags <inline> +#>=Pkg: A 1 1 noarch +#>+Prv: +#>A = 1-1 +#>-Prv: +repo available 0 testtags <inline> +#>=Pkg: A 2 1 noarch +#>+Prv: +#>A = 2-1 +#>-Prv: +#>=Pkg: B 1 0 noarch +#>+Prv: +#>B = 1-0 +#>-Prv: +#>+Obs: +#>A +#>-Obs: +system i686 rpm system + +# first check untargeted +job update name A = 1-1 +result transaction,problems <inline> +#>erase A-1-1.noarch@system B-1-0.noarch@available +#>install B-1-0.noarch@available + +# then targeted to A-2-1 +nextjob +job update name A = 2-1 +result transaction,problems <inline> +#>upgrade A-1-1.noarch@system A-2-1.noarch@available + +# then targeted to B +nextjob +job update name B +result transaction,problems <inline> +#>erase A-1-1.noarch@system B-1-0.noarch@available +#>install B-1-0.noarch@available + +# first check forced to targeted +nextjob +job update name A = 1-1 [targeted] +result transaction,problems <inline> + +# second check forced to untargeted +nextjob +solverflags noautotarget +job distupgrade name A = 2-1 +result transaction,problems <inline> |