diff options
-rw-r--r-- | src/solver.c | 15 | ||||
-rw-r--r-- | test/provides5.test | 6 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/solver.c b/src/solver.c index 0814e18..fc06e38 100644 --- a/src/solver.c +++ b/src/solver.c @@ -482,7 +482,7 @@ static void calculate_pkg_preference(struct apk_package *pkg) struct apk_name *name = pkg->name; struct apk_package_state *ps = pkg_to_ps(pkg); struct apk_provider p = APK_PROVIDER_FROM_PACKAGE(pkg); - int i; + int i, j; for (i = 0; i < name->providers->num; i++) { struct apk_provider *p0 = &name->providers->item[i]; @@ -491,7 +491,18 @@ static void calculate_pkg_preference(struct apk_package *pkg) if (compare_absolute_package_preference(&p, p0) < 0) ps->preference++; } - /* FIXME: consider all provided names too */ + for (i = 0; i < pkg->provides->num; i++) { + struct apk_dependency *d0 = &pkg->provides->item[i]; + if (d0->version == &apk_null_blob) + continue; + for (j = 0; j < d0->name->providers->num; j++) { + struct apk_provider *p0 = &d0->name->providers->item[j]; + if (pkg == p0->pkg) + continue; + if (compare_absolute_package_preference(&p, p0) < 0) + ps->preference++; + } + } } static void count_name(struct apk_solver_state *ss, struct apk_name *name) diff --git a/test/provides5.test b/test/provides5.test new file mode 100644 index 0000000..9876b02 --- /dev/null +++ b/test/provides5.test @@ -0,0 +1,6 @@ +@ARGS +--test-repo provides.repo +add server-a server-b +@EXPECT +ERROR: 1 unsatisfiable dependencies: + world: server-a |