diff --git a/qpkg/TODO b/qpkg/TODO index e88fadc..f95cc41 100644 --- a/qpkg/TODO +++ b/qpkg/TODO @@ -3,6 +3,9 @@ Still left to do - check whether introducing a new package would cause a conflict + Update: conflicts among the packages considered for installation are now + checked. + - compile the list of conflicts of installed packages - handle Provides: diff --git a/qpkg/prereq.c b/qpkg/prereq.c index 56b8ac9..d7e330a 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -93,6 +93,7 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref) return 0; if (!ref->version) return 1; + /* @@@ error in the database, not qpkg's fault */ assert(pkg->version); cmp = comp_versions(pkg->version, ref->version); //fprintf(stderr, "%.*s <%d> %.*s\n", @@ -112,7 +113,14 @@ static int satisfies(const struct pkg *pkg, const struct ref *ref) static int conflicts(const struct pkg *pkg, const struct list *conf) { - /* @@@ */ + const struct ref *ref; + + while (conf) { + for (ref = conf->refs; ref; ref = ref->next) + if (satisfies(pkg, ref)) + return 1; + conf = conf->next; + } return 0; } @@ -219,9 +227,14 @@ struct pkg **prereq(struct pkg *pkg) .pkg = pkg, .next = NULL }; + struct list conf = { + .refs = pkg->conflicts, + .next = NULL + }; + /* @@@ make list of pre-existing conflicts */ pkg->flags |= QPKG_ADDING; - resolve(NULL, pkg->depends, &stack, NULL); + resolve(NULL, pkg->depends, &stack, &conf); pkg->flags &= ~QPKG_ADDING; free(installs); return best; diff --git a/qpkg/test/conflict b/qpkg/test/conflict new file mode 100755 index 0000000..aa72f81 --- /dev/null +++ b/qpkg/test/conflict @@ -0,0 +1,157 @@ +#!/bin/sh +. ./Common + +############################################################################### + +qpkg_fail "direct conflict precludes resolution" prereq A <= 1) +Filename: foo +EOF +expect <= 1) +Filename: foo +EOF +expect <