summaryrefslogtreecommitdiff
path: root/src/solver.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-04-04 10:56:13 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-04-04 10:56:13 +0300
commitec1a3d57ab66e4b5159d280809e0e5f09867dcff (patch)
tree697ba3ebb2730ca6d8458a43f0a0b91cfea76a9e /src/solver.c
parent8dce7755d43cee31b4c9f9328bfe8630f6e18e32 (diff)
downloadapk-tools-ec1a3d57ab66e4b5159d280809e0e5f09867dcff.tar.gz
apk-tools-ec1a3d57ab66e4b5159d280809e0e5f09867dcff.tar.bz2
apk-tools-ec1a3d57ab66e4b5159d280809e0e5f09867dcff.tar.xz
apk-tools-ec1a3d57ab66e4b5159d280809e0e5f09867dcff.zip
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.
Diffstat (limited to 'src/solver.c')
-rw-r--r--src/solver.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/solver.c b/src/solver.c
index 0776cc0..2318d72 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -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.pkg_available =
(pkg->filename != NULL) ||
- (pkg->installed_size == 0) ||
- (pkg->repos & db->available_repos);
- pkg->ss.pkg_selectable = pkg->ss.pkg_available || pkg->ipkg;
+ (pkg->repos & db->available_repos & ~BIT(APK_REPOSITORY_CACHED));
+ /* Package is in 'cached' repository if filename is provided,
+ * 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);
pkg->ss.tag_preferred =
@@ -497,10 +500,14 @@ static int compare_providers(struct apk_solver_state *ss,
return r;
/* 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;
if (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 {
/* Prefer without errors */
@@ -529,10 +536,14 @@ static int compare_providers(struct apk_solver_state *ss,
return r;
/* 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;
if (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 */