solver: fix backtracking with install_if dependencies

cute-signatures
Timo Teräs 2012-04-27 08:47:20 +03:00
parent 06323b3778
commit 29c7fb359e
1 changed files with 20 additions and 17 deletions

View File

@ -542,7 +542,7 @@ static void foreach_dependency(struct apk_solver_state *ss, struct apk_dependenc
func(ss, &deps->item[i]); func(ss, &deps->item[i]);
} }
static int install_if_missing(struct apk_solver_state *ss, struct apk_package *pkg) static int install_if_missing(struct apk_solver_state *ss, struct apk_package *pkg, struct apk_name *exclude)
{ {
int i, missing = 0; int i, missing = 0;
@ -550,7 +550,8 @@ static int install_if_missing(struct apk_solver_state *ss, struct apk_package *p
struct apk_dependency *dep = &pkg->install_if->item[i]; struct apk_dependency *dep = &pkg->install_if->item[i];
struct apk_name *name = dep->name; struct apk_name *name = dep->name;
if (!name->ss.locked || !apk_dep_is_provided(dep, &name->ss.chosen)) if (name == exclude ||
!name->ss.locked || !apk_dep_is_provided(dep, &name->ss.chosen))
missing++; missing++;
} }
@ -674,14 +675,15 @@ static void trigger_install_if(struct apk_solver_state *ss,
{ {
struct apk_name *name = pkg->name; struct apk_name *name = pkg->name;
if (install_if_missing(ss, pkg) == 0) { if (install_if_missing(ss, pkg, NULL) != 0)
return;
dbg_printf("trigger_install_if: " PKG_VER_FMT " triggered\n", dbg_printf("trigger_install_if: " PKG_VER_FMT " triggered\n",
PKG_VER_PRINTF(pkg)); PKG_VER_PRINTF(pkg));
name->ss.install_ifs++; name->ss.install_ifs++;
inherit_package_state(ss->db, pkg, parent_pkg); inherit_package_state(ss->db, pkg, parent_pkg);
promote_name(ss, name); promote_name(ss, name);
} }
}
static void untrigger_install_if(struct apk_solver_state *ss, static void untrigger_install_if(struct apk_solver_state *ss,
struct apk_package *pkg, struct apk_package *pkg,
@ -689,14 +691,15 @@ static void untrigger_install_if(struct apk_solver_state *ss,
{ {
struct apk_name *name = pkg->name; struct apk_name *name = pkg->name;
if (install_if_missing(ss, pkg) != 1) { if (install_if_missing(ss, pkg, parent_pkg->name) != 0)
return;
dbg_printf("untrigger_install_if: " PKG_VER_FMT " no longer triggered\n", dbg_printf("untrigger_install_if: " PKG_VER_FMT " no longer triggered\n",
PKG_VER_PRINTF(pkg)); PKG_VER_PRINTF(pkg));
name->ss.install_ifs--; name->ss.install_ifs--;
uninherit_package_state(ss->db, pkg, parent_pkg); uninherit_package_state(ss->db, pkg, parent_pkg);
demote_name(ss, name); demote_name(ss, name);
} }
}
static inline void assign_name( static inline void assign_name(
struct apk_solver_state *ss, struct apk_name *name, struct apk_provider p) struct apk_solver_state *ss, struct apk_name *name, struct apk_provider p)
@ -1254,7 +1257,7 @@ static int expand_branch(struct apk_solver_state *ss)
else else
branching_point = BRANCH_YES; branching_point = BRANCH_YES;
} else if (name->ss.requirers == 0 && name->ss.install_ifs != 0 && } else if (name->ss.requirers == 0 && name->ss.install_ifs != 0 &&
install_if_missing(ss, pkg0)) { install_if_missing(ss, pkg0, NULL)) {
/* not directly required, and package specific /* not directly required, and package specific
* install_if never triggered */ * install_if never triggered */
primary_decision = DECISION_EXCLUDE; primary_decision = DECISION_EXCLUDE;