diff options
author | Timo Teräs <timo.teras@iki.fi> | 2018-11-12 14:16:36 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2018-11-12 14:16:36 +0200 |
commit | 47570f80e9f6bf1f3a41bc6e13ec4bf17849c809 (patch) | |
tree | a4f9269d9782328eb793a74e44f5e0b910d44510 /src/solver.c | |
parent | a86c8ed0828f670b875b418ef10d83bddeca97f6 (diff) | |
download | apk-tools-47570f80e9f6bf1f3a41bc6e13ec4bf17849c809.tar.gz apk-tools-47570f80e9f6bf1f3a41bc6e13ec4bf17849c809.tar.bz2 apk-tools-47570f80e9f6bf1f3a41bc6e13ec4bf17849c809.tar.xz apk-tools-47570f80e9f6bf1f3a41bc6e13ec4bf17849c809.zip |
prefer selecting packages by their primary name
Diffstat (limited to 'src/solver.c')
-rw-r--r-- | src/solver.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/solver.c b/src/solver.c index 5522707..e1d8e2b 100644 --- a/src/solver.c +++ b/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); } +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, unsigned short solver_flags, struct apk_dependency_array *world, @@ -1022,14 +1036,8 @@ restart: name = name0; break; } - if (name == NULL) - goto prefer; - 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 || compare_name_dequeue(name0, name) < 0) + name = name0; } if (name == NULL) break; |