prefer selecting packages by their primary name
parent
a86c8ed082
commit
47570f80e9
|
@ -101,6 +101,7 @@ struct apk_name {
|
||||||
struct apk_name_array *rinstall_if;
|
struct apk_name_array *rinstall_if;
|
||||||
unsigned is_dependency : 1;
|
unsigned is_dependency : 1;
|
||||||
unsigned auto_select_virtual: 1;
|
unsigned auto_select_virtual: 1;
|
||||||
|
unsigned priority : 2;
|
||||||
unsigned int foreach_genid;
|
unsigned int foreach_genid;
|
||||||
union {
|
union {
|
||||||
struct apk_solver_name_state ss;
|
struct apk_solver_name_state ss;
|
||||||
|
|
|
@ -1439,9 +1439,11 @@ static int apk_db_name_rdepends(apk_hash_item item, void *pctx)
|
||||||
struct apk_provider *p;
|
struct apk_provider *p;
|
||||||
struct apk_dependency *dep;
|
struct apk_dependency *dep;
|
||||||
struct apk_name_array *touched;
|
struct apk_name_array *touched;
|
||||||
|
unsigned num_virtual = 0;
|
||||||
|
|
||||||
apk_name_array_init(&touched);
|
apk_name_array_init(&touched);
|
||||||
foreach_array_item(p, name->providers) {
|
foreach_array_item(p, name->providers) {
|
||||||
|
num_virtual += (p->pkg->name != name);
|
||||||
foreach_array_item(dep, p->pkg->depends) {
|
foreach_array_item(dep, p->pkg->depends) {
|
||||||
rname = dep->name;
|
rname = dep->name;
|
||||||
rname->is_dependency |= !dep->conflict;
|
rname->is_dependency |= !dep->conflict;
|
||||||
|
@ -1460,6 +1462,12 @@ static int apk_db_name_rdepends(apk_hash_item item, void *pctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (num_virtual == 0)
|
||||||
|
name->priority = 0;
|
||||||
|
else if (num_virtual != name->providers->num)
|
||||||
|
name->priority = 1;
|
||||||
|
else
|
||||||
|
name->priority = 2;
|
||||||
foreach_array_item(n0, touched)
|
foreach_array_item(n0, touched)
|
||||||
(*n0)->state_int = 0;
|
(*n0)->state_int = 0;
|
||||||
apk_name_array_free(&touched);
|
apk_name_array_free(&touched);
|
||||||
|
|
24
src/solver.c
24
src/solver.c
|
@ -972,6 +972,20 @@ static int cmp_pkgname(const void *p1, const void *p2)
|
||||||
return strcmp(d1->name->name, d2->name->name);
|
return strcmp(d1->name->name, d2->name->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int compare_name_dequeue(const struct apk_name *a, const struct apk_name *b)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = (!!a->ss.requirers) - (!!b->ss.requirers);
|
||||||
|
if (r) return -r;
|
||||||
|
|
||||||
|
r = (int)a->priority - (int)b->priority;
|
||||||
|
if (r) return r;
|
||||||
|
|
||||||
|
r = a->ss.max_dep_chain - b->ss.max_dep_chain;
|
||||||
|
return -r;
|
||||||
|
}
|
||||||
|
|
||||||
int apk_solver_solve(struct apk_database *db,
|
int apk_solver_solve(struct apk_database *db,
|
||||||
unsigned short solver_flags,
|
unsigned short solver_flags,
|
||||||
struct apk_dependency_array *world,
|
struct apk_dependency_array *world,
|
||||||
|
@ -1022,14 +1036,8 @@ restart:
|
||||||
name = name0;
|
name = name0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (name == NULL)
|
if (!name || compare_name_dequeue(name0, name) < 0)
|
||||||
goto prefer;
|
name = name0;
|
||||||
if ((!!name0->ss.requirers) - (!!name->ss.requirers) < 0)
|
|
||||||
continue;
|
|
||||||
if (name0->ss.max_dep_chain - name->ss.max_dep_chain < 0)
|
|
||||||
continue;
|
|
||||||
prefer:
|
|
||||||
name = name0;
|
|
||||||
}
|
}
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue