diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-02-28 10:34:35 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-02-28 11:27:17 +0200 |
commit | 2655d27ea179f365166144677d0a1632dc70e10c (patch) | |
tree | 5af91220a2e76396121f976abfdbda61f18ed8f3 | |
parent | 179b453ab7cef53104f348c342599b0276233a95 (diff) | |
download | apk-tools-2655d27ea179f365166144677d0a1632dc70e10c.tar.gz apk-tools-2655d27ea179f365166144677d0a1632dc70e10c.tar.bz2 apk-tools-2655d27ea179f365166144677d0a1632dc70e10c.tar.xz apk-tools-2655d27ea179f365166144677d0a1632dc70e10c.zip |
solver: consider provided names also for preference
ref #574
-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 |