solver: misc fixes
caused upgrading package X with "apk add path/to/x...apk" where the package file was not in any repository to not work properly.cute-signatures
parent
cb5054e686
commit
918807c45b
31
src/solver.c
31
src/solver.c
|
@ -286,11 +286,11 @@ static int compare_package_preference(unsigned short solver_flags,
|
||||||
struct apk_package *pkgB)
|
struct apk_package *pkgB)
|
||||||
{
|
{
|
||||||
/* preferred repository pinning */
|
/* preferred repository pinning */
|
||||||
if ((pkgA->ipkg || (pkgA->repos & preferred_repos)) &&
|
if ((pkgA->ipkg || pkgA->filename || (pkgA->repos & preferred_repos)) &&
|
||||||
!(pkgB->ipkg || (pkgB->repos & preferred_repos)))
|
!(pkgB->ipkg || pkgB->filename || (pkgB->repos & preferred_repos)))
|
||||||
return 1;
|
return 1;
|
||||||
if ((pkgB->ipkg || (pkgB->repos & preferred_repos)) &&
|
if ((pkgB->ipkg || pkgA->filename || (pkgB->repos & preferred_repos)) &&
|
||||||
!(pkgA->ipkg || (pkgA->repos & preferred_repos)))
|
!(pkgA->ipkg || pkgB->filename || (pkgA->repos & preferred_repos)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
||||||
|
@ -386,10 +386,15 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
|
||||||
|
|
||||||
if (ps0 == NULL ||
|
if (ps0 == NULL ||
|
||||||
pkg0->topology_hard >= ss->topology_position ||
|
pkg0->topology_hard >= ss->topology_position ||
|
||||||
((pkg0->repos != 0) && (pkg0->ipkg == NULL) && !(pkg0->repos & allowed_repos)) ||
|
|
||||||
(ps0->flags & APK_PKGSTF_DECIDED))
|
(ps0->flags & APK_PKGSTF_DECIDED))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if ((pkg0->repos != 0) && (pkg0->ipkg == NULL) && (pkg0->filename == NULL) &&
|
||||||
|
!(pkg0->repos & allowed_repos)) {
|
||||||
|
skipped_options++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ns->requirers == 0 && ns->install_ifs != 0 &&
|
if (ns->requirers == 0 && ns->install_ifs != 0 &&
|
||||||
install_if_missing(ss, pkg0)) {
|
install_if_missing(ss, pkg0)) {
|
||||||
skipped_options++;
|
skipped_options++;
|
||||||
|
@ -429,7 +434,8 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
|
||||||
best_topology);
|
best_topology);
|
||||||
if (!list_hashed(&ns->unsolved_list))
|
if (!list_hashed(&ns->unsolved_list))
|
||||||
list_add(&ns->unsolved_list, &ss->unsolved_list_head);
|
list_add(&ns->unsolved_list, &ss->unsolved_list_head);
|
||||||
ns->chosen = best_pkg;
|
if (!ns->locked)
|
||||||
|
ns->chosen = best_pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
return options + skipped_options;
|
return options + skipped_options;
|
||||||
|
@ -554,18 +560,21 @@ static int next_branch(struct apk_solver_state *ss)
|
||||||
while (ss->latest_decision != NULL) {
|
while (ss->latest_decision != NULL) {
|
||||||
pkg = ss->latest_decision;
|
pkg = ss->latest_decision;
|
||||||
ps = pkg_to_ps(pkg);
|
ps = pkg_to_ps(pkg);
|
||||||
undo_decision(ss, pkg, ps);
|
|
||||||
|
|
||||||
if (ps->flags & APK_PKGSTF_ALT_BRANCH) {
|
if (ps->flags & APK_PKGSTF_ALT_BRANCH) {
|
||||||
dbg_printf("next_branch: undo decision at topology_position %d\n",
|
dbg_printf("next_branch: undo decision at topology_position %d\n",
|
||||||
ss->topology_position);
|
ss->topology_position);
|
||||||
ps->flags &= ~(APK_PKGSTF_ALT_BRANCH | APK_PKGSTF_DECIDED);
|
ps->flags &= ~(APK_PKGSTF_ALT_BRANCH | APK_PKGSTF_DECIDED);
|
||||||
|
undo_decision(ss, pkg, ps);
|
||||||
|
|
||||||
ss->latest_decision = ps->backtrack;
|
ss->latest_decision = ps->backtrack;
|
||||||
ss->refresh_name_states = 1;
|
ss->refresh_name_states = 1;
|
||||||
} else {
|
} else {
|
||||||
dbg_printf("next_branch: swapping BRANCH at topology_position %d\n",
|
dbg_printf("next_branch: swapping BRANCH at topology_position %d\n",
|
||||||
ss->topology_position);
|
ss->topology_position);
|
||||||
|
|
||||||
|
undo_decision(ss, pkg, ps);
|
||||||
|
|
||||||
ps->flags |= APK_PKGSTF_ALT_BRANCH;
|
ps->flags |= APK_PKGSTF_ALT_BRANCH;
|
||||||
ps->flags ^= APK_PKGSTF_INSTALL;
|
ps->flags ^= APK_PKGSTF_INSTALL;
|
||||||
|
|
||||||
|
@ -626,8 +635,12 @@ static void apply_constraint(struct apk_solver_state *ss, struct apk_dependency
|
||||||
prepare_name(ss, name, ns);
|
prepare_name(ss, name, ns);
|
||||||
|
|
||||||
if (ns->locked) {
|
if (ns->locked) {
|
||||||
dbg_printf(PKG_VER_FMT " selected already for %s\n",
|
if (ns->chosen)
|
||||||
PKG_VER_PRINTF(ns->chosen), dep->name->name);
|
dbg_printf("%s: locked to " PKG_VER_FMT " already\n",
|
||||||
|
dep->name->name, PKG_VER_PRINTF(ns->chosen));
|
||||||
|
else
|
||||||
|
dbg_printf("%s: locked to empty\n",
|
||||||
|
dep->name->name);
|
||||||
if (!apk_dep_is_satisfied(dep, ns->chosen))
|
if (!apk_dep_is_satisfied(dep, ns->chosen))
|
||||||
ss->score.unsatisfiable++;
|
ss->score.unsatisfiable++;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue