From b89bcdfd93a60417649340a18ca3bb573b1d9691 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 22 Nov 2010 06:52:53 -0300 Subject: [PATCH] qpkg: also consider conflicts introduced by package about to be added - prereq.c (conflicts, resolve, prereq): renamed "conflicts" to "old_conflicts" - prereq.c (new_conflicts, resolve, prereq): also test whether any of the conflicts of the package we're about to add matches an installed or considered package - test/conflict, test/instconf: test for conflicts introduced by package about to be added --- qpkg/prereq.c | 25 ++++++++++++++--- qpkg/test/conflict | 67 ++++++++++++++++++++++++++++++++++++++++++++++ qpkg/test/instconf | 41 ++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 4 deletions(-) diff --git a/qpkg/prereq.c b/qpkg/prereq.c index f00e9f6..a99518b 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -111,7 +111,7 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref) } -static int conflicts(const struct pkg *pkg, const struct list *conf) +static int old_conflicts(const struct pkg *pkg, const struct list *conf) { const struct ref *ref; @@ -125,6 +125,21 @@ static int conflicts(const struct pkg *pkg, const struct list *conf) } +static int new_conflicts(const struct ref *refs) +{ + const struct ref *ref; + const struct pkg *pkg; + + for (ref = refs; ref; ref = ref->next) + for (pkg = ref->pkg->jrb->val; pkg; pkg = pkg->more) + if ((pkg->flags & (QPKG_INSTALLED | QPKG_ADDING)) || + pkg->mark) + if (satisfies(pkg, ref)) + return 1; + return 0; +} + + /* ----- Recurse through lists and layers of dependencies ------------------ */ @@ -186,11 +201,13 @@ static void resolve(struct list *next_dep, const struct ref *dep, exit(1); } if ((pkg->flags & QPKG_INSTALLED) || pkg->mark) { - assert(!conflicts(pkg, conf)); + assert(!old_conflicts(pkg, conf)); resolve(next_dep, dep->next, top, conf); continue; } - if (conflicts(pkg, conf)) + if (old_conflicts(pkg, conf)) + continue; + if (new_conflicts(pkg->conflicts)) continue; level++; append_install(pkg); @@ -268,7 +285,7 @@ struct pkg **prereq(struct pkg *pkg) .next = installed_conflicts() }; - if (conflicts(pkg, &conf)) { + if (old_conflicts(pkg, &conf) || new_conflicts(pkg->conflicts)) { fprintf(stderr, "%.*s conflicts with installed packages\n", ID2PF(pkg->id)); exit(1); diff --git a/qpkg/test/conflict b/qpkg/test/conflict index aa72f81..314fbc7 100755 --- a/qpkg/test/conflict +++ b/qpkg/test/conflict @@ -155,3 +155,70 @@ EOF expect <