Commit ec1a3d57 authored by Timo Teräs's avatar Timo Teräs
Browse files

solver: do not consider packages in cache as 'available'

'available' really means 'available in one or more configured
repository'. Cache is not a repository we track, so those are
only available for installation, but not available as preferred
to be installed from repository. fixes #2831.
parent 8dce7755
...@@ -218,9 +218,12 @@ static void discover_name(struct apk_solver_state *ss, struct apk_name *name) ...@@ -218,9 +218,12 @@ static void discover_name(struct apk_solver_state *ss, struct apk_name *name)
pkg->ss.pinning_preferred = APK_DEFAULT_PINNING_MASK; pkg->ss.pinning_preferred = APK_DEFAULT_PINNING_MASK;
pkg->ss.pkg_available = pkg->ss.pkg_available =
(pkg->filename != NULL) || (pkg->filename != NULL) ||
(pkg->installed_size == 0) || (pkg->repos & db->available_repos & ~BIT(APK_REPOSITORY_CACHED));
(pkg->repos & db->available_repos); /* Package is in 'cached' repository if filename is provided,
pkg->ss.pkg_selectable = pkg->ss.pkg_available || pkg->ipkg; * or it's a 'virtual' package with install_size zero */
pkg->ss.pkg_selectable =
(pkg->repos & db->available_repos) ||
pkg->ipkg;
repos = get_pkg_repos(db, pkg); repos = get_pkg_repos(db, pkg);
pkg->ss.tag_preferred = pkg->ss.tag_preferred =
...@@ -497,10 +500,14 @@ static int compare_providers(struct apk_solver_state *ss, ...@@ -497,10 +500,14 @@ static int compare_providers(struct apk_solver_state *ss,
return r; return r;
/* Prefer available */ /* Prefer available */
if (solver_flags & (APK_SOLVERF_AVAILABLE | APK_SOLVERF_REINSTALL)) { if (solver_flags & APK_SOLVERF_AVAILABLE) {
r = (int)pkgA->ss.pkg_available - (int)pkgB->ss.pkg_available; r = (int)pkgA->ss.pkg_available - (int)pkgB->ss.pkg_available;
if (r) if (r)
return r; return r;
} else if (solver_flags & APK_SOLVERF_REINSTALL) {
r = (int)pkgA->ss.pkg_selectable - (int)pkgB->ss.pkg_selectable;
if (r)
return r;
} }
} else { } else {
/* Prefer without errors */ /* Prefer without errors */
...@@ -529,10 +536,14 @@ static int compare_providers(struct apk_solver_state *ss, ...@@ -529,10 +536,14 @@ static int compare_providers(struct apk_solver_state *ss,
return r; return r;
/* Prefer available */ /* Prefer available */
if (solver_flags & (APK_SOLVERF_AVAILABLE | APK_SOLVERF_REINSTALL)) { if (solver_flags & APK_SOLVERF_AVAILABLE) {
r = (int)pkgA->ss.pkg_available - (int)pkgB->ss.pkg_available; r = (int)pkgA->ss.pkg_available - (int)pkgB->ss.pkg_available;
if (r) if (r)
return r; return r;
} else if (solver_flags & APK_SOLVERF_REINSTALL) {
r = (int)pkgA->ss.pkg_selectable - (int)pkgB->ss.pkg_selectable;
if (r)
return r;
} }
/* Prefer preferred pinning */ /* Prefer preferred pinning */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment