diff --git a/qpkg/prereq.c b/qpkg/prereq.c index 22e7f40..5751e16 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -166,7 +166,7 @@ static void print_debug(const struct pkg *pkg, const struct stack *top, } -static void resolve(struct list *next_dep, const struct ref *dep, +static void resolve(struct list *next_deps, const struct ref *dep, struct stack *top, struct list *conf) { static int level = 0; @@ -178,19 +178,21 @@ static void resolve(struct list *next_dep, const struct ref *dep, struct pkg *pkg; while (!dep) { - if (!next_dep) { + if (!next_deps) { done(); return; } assert(top->pkg->flags & QPKG_ADDING); top->pkg->flags &= ~QPKG_ADDING; top = top->next; - dep = next_dep->refs; - next_dep = next_dep->next; + dep = next_deps->refs; + next_deps = next_deps->next; } for (pkg = dep->pkg->jrb->val; pkg; pkg = pkg->more) { if (best && n_install == n_best) - return; + break; + if (pkg->flags & QPKG_PROVIDED) + continue; if (debug) print_debug(pkg, top, level); if (!satisfies(pkg, dep)) @@ -203,7 +205,7 @@ static void resolve(struct list *next_dep, const struct ref *dep, } if ((pkg->flags & QPKG_INSTALLED) || pkg->mark) { assert(!old_conflicts(pkg, conf)); - resolve(next_dep, dep->next, top, conf); + resolve(next_deps, dep->next, top, conf); continue; } if (old_conflicts(pkg, conf)) @@ -213,7 +215,7 @@ static void resolve(struct list *next_dep, const struct ref *dep, level++; append_install(pkg); more_deps.refs = dep->next; - more_deps.next = next_dep; + more_deps.next = next_deps; more_conf.refs = pkg->conflicts; more_conf.next = conf; stack.pkg = pkg; @@ -225,11 +227,12 @@ static void resolve(struct list *next_dep, const struct ref *dep, } /* - * @@@ this shouldn't be all of the story yet. if we fail a dependency + * @@@ this shouldn't be all of the story yet. If we fail a dependency * due to a conflict, the current algorithm may leave packages marked * as QPKG_ADDING, possibly triggering a false cyclic dependency error. + * See test/bug-adding for an example. * - * In the case if cycle detection, we could avoid all the hassle of + * In the case of cycle detection, we could avoid all the hassle of * maintaining this flag and just walk down the stack to see if we're * already trying to add the package (the stack should be correct with * the current algorithm), but we'll need this kind of accurate