solver: instead of tracking selected packages, score by requirer count for tiebreaking
parent
f18c708183
commit
9165aa3894
|
@ -54,7 +54,6 @@ struct apk_solver_package_state {
|
||||||
unsigned seen : 1;
|
unsigned seen : 1;
|
||||||
unsigned pkg_available : 1;
|
unsigned pkg_available : 1;
|
||||||
unsigned pkg_selectable : 1;
|
unsigned pkg_selectable : 1;
|
||||||
unsigned pkg_selected : 1;
|
|
||||||
unsigned tag_ok : 1;
|
unsigned tag_ok : 1;
|
||||||
unsigned tag_preferred : 1;
|
unsigned tag_preferred : 1;
|
||||||
unsigned dependencies_used : 1;
|
unsigned dependencies_used : 1;
|
||||||
|
|
19
src/solver.c
19
src/solver.c
|
@ -299,10 +299,6 @@ static void apply_constraint(struct apk_solver_state *ss, struct apk_package *pp
|
||||||
|
|
||||||
if (is_provided)
|
if (is_provided)
|
||||||
inherit_pinning_and_flags(ss, pkg0, ppkg);
|
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);
|
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,
|
static int compare_providers(struct apk_solver_state *ss,
|
||||||
struct apk_provider *pA, struct apk_provider *pB)
|
struct apk_provider *pA, struct apk_provider *pB)
|
||||||
{
|
{
|
||||||
|
@ -591,8 +598,8 @@ static int compare_providers(struct apk_solver_state *ss,
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* Prefer already selected package. */
|
/* Prefer highest requirer count. */
|
||||||
r = pkgA->ss.pkg_selected - pkgB->ss.pkg_selected;
|
r = count_requirers(pkgA) - count_requirers(pkgB);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue