Bug#232445: Patch for #232445
tags 232445 + patch
thanks
The following patch should fix the problem. Please apply. :-)
/* Steinar */
--
Homepage: http://www.sesse.net/
Index: lib/database.c
===================================================================
--- lib/database.c (revision 1840)
+++ lib/database.c (revision 1841)
@@ -130,6 +130,7 @@
pigp->installed.valid= 0;
pigp->available.valid= 0;
pigp->clientdata= NULL;
+ pigp->color= white;
blankpackageperfile(&pigp->installed);
blankpackageperfile(&pigp->available);
}
Index: include/dpkg-db.h
===================================================================
--- include/dpkg-db.h (revision 1840)
+++ include/dpkg-db.h (revision 1841)
@@ -139,6 +139,7 @@
struct pkginfoperfile installed;
struct pkginfoperfile available;
struct perpackagestate *clientdata;
+ enum { white, gray, black } color; /* used during cycle detection */
};
#endif /* DPKG_DB_H */
Index: main/depcon.c
===================================================================
--- main/depcon.c (revision 1840)
+++ main/depcon.c (revision 1841)
@@ -43,6 +43,8 @@
struct deppossi *possi;
};
+static int findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar);
+
static int foundcyclebroken(struct cyclesofarlink *thislink,
struct cyclesofarlink *sofar,
struct pkginfo *dependedon,
@@ -60,7 +62,7 @@
for (sol=sofar; sol && sol->pkg != dependedon; sol=sol->back);
/* If not, we do a recursive search on it to see what we find. */
- if (!sol) return findbreakcycle(possi->ed,thislink);
+ if (!sol) return findbreakcyclerecursive(possi->ed,thislink);
debug(dbg_depcon,"found cycle");
/* Right, we now break one of the links. We prefer to break
@@ -89,7 +91,7 @@
return 1;
}
-int findbreakcycle(struct pkginfo *pkg, struct cyclesofarlink *sofar) {
+static int findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar) {
/* Cycle breaking works recursively down the package dependency
* tree. `sofar' is the list of packages we've descended down
* already - if we encounter any of its packages again in a
@@ -100,8 +102,12 @@
struct deppossi *possi, *providelink;
struct pkginfo *provider;
+ if (pkg->color == black)
+ return 0;
+ pkg->color = gray;
+
if (f_debug & dbg_depcondetail) {
- fprintf(stderr,"D0%05o: findbreakcycle %s ",dbg_depcondetail,pkg->name);
+ fprintf(stderr,"D0%05o: findbreakcyclerecursive %s ",dbg_depcondetail,pkg->name);
for (sol=sofar; sol; sol=sol->back) fprintf(stderr," <- %s",sol->pkg->name);
fprintf(stderr,"\n");
}
@@ -131,9 +137,22 @@
}
}
/* Nope, we didn't find a cycle to break. */
+ pkg->color = black;
return 0;
}
+int findbreakcycle(struct pkginfo *pkg) {
+ struct pkgiterator *iter;
+ struct pkginfo *tpkg;
+
+ /* Clear the visited flag of all packages before we traverse them. */
+ for (iter = iterpkgstart(); (tpkg=iterpkgnext(iter)); ) {
+ tpkg->color = white;
+ }
+
+ return findbreakcyclerecursive(pkg, 0);
+}
+
void describedepcon(struct varbuf *addto, struct dependency *dep) {
varbufaddstr(addto,dep->up->name);
switch (dep->type) {
Index: main/configure.c
===================================================================
--- main/configure.c (revision 1840)
+++ main/configure.c (revision 1841)
@@ -99,7 +99,7 @@
pkg->name, statusinfos[pkg->status].name);
if (dependtry > 1)
- if (findbreakcycle(pkg,0))
+ if (findbreakcycle(pkg))
sincenothing= 0;
varbufinit(&aemsgs);
Index: main/main.h
===================================================================
--- main/main.h (revision 1840)
+++ main/main.h (revision 1841)
@@ -217,7 +217,7 @@
int depisok(struct dependency *dep, struct varbuf *whynot,
struct pkginfo **fixbyrm, int allowunconfigd);
struct cyclesofarlink;
-int findbreakcycle(struct pkginfo *pkg, struct cyclesofarlink *sofar);
+int findbreakcycle(struct pkginfo *pkg);
void describedepcon(struct varbuf *addto, struct dependency *dep);
#endif /* MAIN_H */
Index: main/remove.c
===================================================================
--- main/remove.c (revision 1840)
+++ main/remove.c (revision 1841)
@@ -69,7 +69,7 @@
}
if (dependtry>1) {
- if (findbreakcycle(pkgtoremove,0))
+ if (findbreakcycle(pkgtoremove))
sincenothing=0;
}
Reply to: