From: Michael Schroeder Date: Wed, 6 Mar 2013 17:35:44 +0000 (+0100) Subject: cleanup code now that the vendorcheck callback is in the pool X-Git-Tag: BASE-SuSE-Code-12_3-Branch~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebfee3e7d80a22278d3405d7abb9e47fcba31d9e;p=thirdparty%2Flibsolv.git cleanup code now that the vendorcheck callback is in the pool --- diff --git a/src/pool.h b/src/pool.h index 482aefb4..8e1a951d 100644 --- a/src/pool.h +++ b/src/pool.h @@ -266,8 +266,7 @@ Id pool_id2langid(Pool *pool, Id id, const char *lang, int create); int solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap, Map *noobsoletesmap); int solvable_trivial_installable_repo(Solvable *s, struct _Repo *installed, Map *noobsoletesmap); int solvable_trivial_installable_queue(Solvable *s, Queue *installed, Map *noobsoletesmap); -struct _Solver; /* argh, needed for vendorchange callback FIXME */ -int solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, struct _Solver *solv); +int solvable_is_irrelevant_patch(Solvable *s, Map *installedmap); void pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap); diff --git a/src/solvable.c b/src/solvable.c index 45945443..7ac79eee 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -462,7 +462,7 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm { if (providedbyinstalled(pool, installedmap, con, ispatch, noobsoletesmap)) { - if (ispatch && solvable_is_irrelevant_patch(s, installedmap, 0)) + if (ispatch && solvable_is_irrelevant_patch(s, installedmap)) return -1; return 0; } @@ -473,7 +473,7 @@ solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsm interesting = 1; } } - if (ispatch && interesting && solvable_is_irrelevant_patch(s, installedmap, 0)) + if (ispatch && interesting && solvable_is_irrelevant_patch(s, installedmap)) interesting = 0; } #if 0 @@ -575,11 +575,33 @@ solvable_trivial_installable_repo(Solvable *s, Repo *installed, Map *noobsoletes return r; } +/* FIXME: this mirrors policy_illegal_vendorchange */ +static int +pool_illegal_vendorchange(Pool *pool, Solvable *s1, Solvable *s2) +{ + Id v1, v2; + Id vendormask1, vendormask2; + + if (pool->custom_vendorcheck) + return pool->custom_vendorcheck(pool, s1, s2); + /* treat a missing vendor as empty string */ + v1 = s1->vendor ? s1->vendor : ID_EMPTY; + v2 = s2->vendor ? s2->vendor : ID_EMPTY; + if (v1 == v2) + return 0; + vendormask1 = pool_vendor2mask(pool, v1); + if (!vendormask1) + return 1; /* can't match */ + vendormask2 = pool_vendor2mask(pool, v2); + if ((vendormask1 & vendormask2) != 0) + return 0; + return 1; /* no class matches */ +} /* check if this patch is relevant according to the vendor. To bad that patches * don't have a vendor, so we need to do some careful repo testing. */ int -solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, Solver *solv) +solvable_is_irrelevant_patch(Solvable *s, Map *installedmap) { Pool *pool = s->repo->pool; Id con, *conp; @@ -618,23 +640,8 @@ solvable_is_irrelevant_patch(Solvable *s, Map *installedmap, Solver *solv) /* ok, we have a package from the patch repo that solves the conflict. check vendor */ if (si->vendor == s2->vendor) return 0; - /* FIXME: solv is only needed for the vendorchange callback */ - if (solv) - { - if (!policy_illegal_vendorchange(solv, si, s2)) - return 0; - } - else - { - Id v1 = si->vendor ? si->vendor : ID_EMPTY; - Id v2 = s2->vendor ? s2->vendor : ID_EMPTY; - if (v1 == v2) - return 0; - v1 = pool_vendor2mask(pool, v1); - v2 = pool_vendor2mask(pool, v2); - if ((v1 & v2) != 0) - return 0; - } + if (!pool_illegal_vendorchange(pool, si, s2)) + return 0; /* vendor change was illegal, ignore conflict */ } } diff --git a/src/solver.c b/src/solver.c index 38b53c22..c1518db6 100644 --- a/src/solver.c +++ b/src/solver.c @@ -3911,7 +3911,7 @@ solver_trivial_installable(Solver *solv, Queue *pkgs, Queue *res) if (res->elements[i] != -1) { Solvable *s = pool->solvables + pkgs->elements[i]; - if (!strncmp("patch:", pool_id2str(pool, s->name), 6) && solvable_is_irrelevant_patch(s, &installedmap, solv)) + if (!strncmp("patch:", pool_id2str(pool, s->name), 6) && solvable_is_irrelevant_patch(s, &installedmap)) res->elements[i] = -1; } map_free(&installedmap);