From: Michael Schroeder Date: Fri, 15 Jan 2016 15:15:41 +0000 (+0100) Subject: linked packages: fix rule generation X-Git-Tag: 0.6.18~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2a85109094596dd5c5c95226b373952aa428b3e;p=thirdparty%2Flibsolv.git linked packages: fix rule generation Add multiple rules for different package names instead of ORing them all together. I hope this works out better for our applications. --- diff --git a/src/rules.c b/src/rules.c index 6f357203..4cd53d33 100644 --- a/src/rules.c +++ b/src/rules.c @@ -417,6 +417,19 @@ addpkgrule(Solver *solv, Id p, Id p2, Id d, int type, Id dep) #ifdef ENABLE_LINKED_PKGS +static int +addlinks_cmp(const void *ap, const void *bp, void *dp) +{ + Pool *pool = dp; + Id a = *(Id *)ap; + Id b = *(Id *)bp; + Solvable *sa = pool->solvables + a; + Solvable *sb = pool->solvables + b; + if (sa->name != sb->name) + return sa->name - sb->name; + return sa - sb; +} + static void addlinks(Solver *solv, Solvable *s, Id req, Queue *qr, Id prv, Queue *qp, Map *m, Queue *workq) { @@ -424,6 +437,8 @@ addlinks(Solver *solv, Solvable *s, Id req, Queue *qr, Id prv, Queue *qp, Map *m int i; if (!qr->count) return; + if (qp->count > 1) + solv_sort(qp->elements, qp->count, sizeof(Id), addlinks_cmp, pool); #if 0 printf("ADDLINKS %s\n -> %s\n", pool_solvable2str(pool, s), pool_dep2str(pool, req)); for (i = 0; i < qr->count; i++) @@ -439,9 +454,17 @@ addlinks(Solver *solv, Solvable *s, Id req, Queue *qr, Id prv, Queue *qp, Map *m addpkgrule(solv, -(s - pool->solvables), 0, pool_queuetowhatprovides(pool, qr), SOLVER_RULE_PKG_REQUIRES, req); if (qp->count > 1) { - Id d = pool_queuetowhatprovides(pool, qp); - for (i = 0; i < qr->count; i++) - addpkgrule(solv, -qr->elements[i], 0, d, SOLVER_RULE_PKG_REQUIRES, prv); + int j; + for (i = j = 0; i < qp->count; i = j) + { + Id d = pool->solvables[qp->elements[i]].name; + for (j = i + 1; j < qp->count; j++) + if (d != pool->solvables[qp->elements[j]].name) + break; + d = pool_ids2whatprovides(pool, qp->elements + i, j - i); + for (i = 0; i < qr->count; i++) + addpkgrule(solv, -qr->elements[i], 0, d, SOLVER_RULE_PKG_REQUIRES, prv); + } } else if (qp->count) {