From 03588258844d0365b2e4584422b9993191d2a1de Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 14 Mar 2011 02:27:17 +0000 Subject: [PATCH] pruneRDeps1: fix check for cycles The check for cycles introduced in 4.0.4-alt100.17-6-ga71e004 appeared to be incomplete. For example, it fails to recognize a cycle in the following example: %package -n test Requires: libtest = %version-%release %package -n libtest Requires: libtest-common = %version-%release %package -n libtest-common Requires: libtest = %version-%release --- build/interdep.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/interdep.c b/build/interdep.c index d21d374..3bd0f6f 100644 --- a/build/interdep.c +++ b/build/interdep.c @@ -564,7 +564,7 @@ void pruneExtraDeps(struct Req *r, Spec spec) // assuming pkg1 has strict dependency on pkg2, prune deps required by pkg2 static -void pruneRDeps1(struct Req *r, Package pkg1, Package pkg2) +void pruneRDeps1(struct Req *r, Spec spec, Package pkg1, Package pkg2) { TFI_t fi = pkg1->cpioList; if (fi == NULL) @@ -601,11 +601,11 @@ void pruneRDeps1(struct Req *r, Package pkg1, Package pkg2) int npruned = 0; char pruned[reqc]; bzero(pruned, reqc); - // check if pkg2 is non-last part of a cycle + // check if pkg2 is part of a cycle int cycle = 0; Package pkg3; - for (pkg3 = pkg2->next; pkg3; pkg3 = pkg3->next) { - if (pkg3 == pkg1) + for (pkg3 = spec->packages; pkg3; pkg3 = pkg3->next) { + if (pkg3 == pkg1 || pkg3 == pkg2) continue; if (Requires(r, pkg2, pkg3) && Requires(r, pkg3, pkg2)) { cycle = 1; @@ -661,10 +661,10 @@ void pruneExtraRDeps(struct Req *r, Spec spec) for (pkg1 = spec->packages; pkg1; pkg1 = pkg1->next) for (pkg2 = pkg1->next; pkg2; pkg2 = pkg2->next) if (Requires(r, pkg1, pkg2)) - pruneRDeps1(r, pkg1, pkg2); + pruneRDeps1(r, spec, pkg1, pkg2); // "else" guards against mutual deletions else if (Requires(r, pkg2, pkg1)) - pruneRDeps1(r, pkg2, pkg1); + pruneRDeps1(r, spec, pkg2, pkg1); } int processInterdep(Spec spec)