summaryrefslogtreecommitdiff
path: root/src/solver.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-01-18 11:38:31 +0200
committerTimo Teräs <timo.teras@iki.fi>2013-01-18 11:38:31 +0200
commit86a7338575b2e499e2758b1b848e1a173ee27c78 (patch)
treeb54560458159752c10d9b1b822f4c2e3072b39fe /src/solver.c
parente50da7e4a523c121dbd5bae52fe239ad64621e06 (diff)
downloadapk-tools-86a7338575b2e499e2758b1b848e1a173ee27c78.tar.gz
apk-tools-86a7338575b2e499e2758b1b848e1a173ee27c78.tar.bz2
apk-tools-86a7338575b2e499e2758b1b848e1a173ee27c78.tar.xz
apk-tools-86a7338575b2e499e2758b1b848e1a173ee27c78.zip
solver: fix name assignment logic to not mess up internal state
Should get rid of error messages like: ERROR: Saved_score {4/0/0,74} != score {6/0/0,74}
Diffstat (limited to 'src/solver.c')
-rw-r--r--src/solver.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/solver.c b/src/solver.c
index b12fc70..bb8d177 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -699,17 +699,16 @@ static void untrigger_install_if(struct apk_solver_state *ss,
static inline void assign_name(
struct apk_solver_state *ss, struct apk_name *name, struct apk_provider p)
{
- if (p.version == &apk_null_blob) {
+ if (name->ss.locked &&
+ (p.version != &apk_null_blob || name->ss.chosen.version != &apk_null_blob)) {
/* Assigning locked name with version is a problem;
* generally package providing same name twice */
- if (name->ss.locked && name->ss.chosen.version != &apk_null_blob)
- ss->impossible_state = 1;
- } else {
- /* Similar to above */
- if (name->ss.locked)
- ss->impossible_state = 1;
+ name->ss.locked++;
+ ss->impossible_state = 1;
+ return;
}
- name->ss.chosen = p;
+ if (!name->ss.locked)
+ name->ss.chosen = p;
name->ss.locked++;
if (list_hashed(&name->ss.unsolved_list)) {
list_del(&name->ss.unsolved_list);
@@ -850,15 +849,15 @@ static void undo_decision(struct apk_solver_state *ss,
foreach_rinstall_if_pkg(ss, pkg, untrigger_install_if);
foreach_dependency(ss, pkg->depends, undo_constraint);
- get_topology_score(ss, pkg, &score);
- subscore(&ss->score, &score);
-
unassign_name(ss, pkg->name);
for (i = 0; i < pkg->provides->num; i++) {
struct apk_dependency *p = &pkg->provides->item[i];
unassign_name(ss, p->name);
}
ss->assigned_names--;
+
+ get_topology_score(ss, pkg, &score);
+ subscore(&ss->score, &score);
}
ps->locked = 0;
} else {