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
This commit is contained in:
Дмитрий Левин 2011-03-14 02:27:17 +00:00
parent 37ca0532c0
commit 0358825884

View File

@ -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)