diff options
author | William Pitcock <nenolod@dereferenced.org> | 2017-11-02 16:24:09 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2017-11-02 16:24:09 +0000 |
commit | 9165aa3894bcf19f36be16d733f75eb997becd4f (patch) | |
tree | c102429fe1dc4cb7c5b3e9ef53b37d1e24364825 /src/solver.c | |
parent | f18c708183ac735d1787ff5b450d36f6596a10b9 (diff) | |
download | apk-tools-9165aa3894bcf19f36be16d733f75eb997becd4f.tar.gz apk-tools-9165aa3894bcf19f36be16d733f75eb997becd4f.tar.bz2 apk-tools-9165aa3894bcf19f36be16d733f75eb997becd4f.tar.xz apk-tools-9165aa3894bcf19f36be16d733f75eb997becd4f.zip |
solver: instead of tracking selected packages, score by requirer count for tiebreaking
Diffstat (limited to 'src/solver.c')
-rw-r--r-- | src/solver.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/solver.c b/src/solver.c index 11ccfc9..17dbdd2 100644 --- a/src/solver.c +++ b/src/solver.c @@ -299,10 +299,6 @@ static void apply_constraint(struct apk_solver_state *ss, struct apk_package *pp if (is_provided) inherit_pinning_and_flags(ss, pkg0, ppkg); - - /* if a world-dependency is non-virtual, then the provider is going to be selected */ - if (ppkg == NULL && dep->name == pkg0->name && pkg0->ss.pkg_selectable) - pkg0->ss.pkg_selected = 1; } } @@ -485,6 +481,17 @@ static void reconsider_name(struct apk_solver_state *ss, struct apk_name *name) name->name, name->ss.has_options, name->ss.reverse_deps_done); } +static int count_requirers(const struct apk_package *pkg) +{ + int cnt = pkg->name->ss.requirers; + struct apk_dependency *p; + + foreach_array_item(p, pkg->provides) + cnt += p->name->ss.requirers; + + return cnt; +} + static int compare_providers(struct apk_solver_state *ss, struct apk_provider *pA, struct apk_provider *pB) { @@ -591,8 +598,8 @@ static int compare_providers(struct apk_solver_state *ss, if (r) return r; - /* Prefer already selected package. */ - r = pkgA->ss.pkg_selected - pkgB->ss.pkg_selected; + /* Prefer highest requirer count. */ + r = count_requirers(pkgA) - count_requirers(pkgB); if (r) return r; |