diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-01-13 10:37:30 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-01-13 10:39:06 +0200 |
commit | 2ea61da9d99a64aa0358b9186447310c98de9a77 (patch) | |
tree | 2543c5780eaeea41fa271b9ebd64c91aaf5546e7 | |
parent | 1f9a36de6828b87ba9d7dedcae2de6092eed4f41 (diff) | |
download | apk-tools-2ea61da9d99a64aa0358b9186447310c98de9a77.tar.gz apk-tools-2ea61da9d99a64aa0358b9186447310c98de9a77.tar.bz2 apk-tools-2ea61da9d99a64aa0358b9186447310c98de9a77.tar.xz apk-tools-2ea61da9d99a64aa0358b9186447310c98de9a77.zip |
add: make repository tag pinning stronger
Previously we would not upgrade just by doing "apk add foo@tag" if
foo was already installed. It required explicit '-u'. This allows
'apk add' to explicitly prefer the newly specified pinning.
-rw-r--r-- | src/add.c | 2 | ||||
-rw-r--r-- | src/apk_solver.h | 1 | ||||
-rw-r--r-- | src/solver.c | 27 |
3 files changed, 21 insertions, 9 deletions
@@ -127,7 +127,7 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv) if (virtpkg == NULL) { apk_deps_add(&world, &dep); apk_solver_set_name_flags(dep.name, - actx->solver_flags, + actx->solver_flags | APK_SOLVERF_PREFER_TAG, actx->solver_flags); } else { apk_deps_add(&virtpkg->depends, &dep); diff --git a/src/apk_solver.h b/src/apk_solver.h index 4f5f29a..235ac0c 100644 --- a/src/apk_solver.h +++ b/src/apk_solver.h @@ -25,6 +25,7 @@ struct apk_changeset { #define APK_SOLVERF_UPGRADE 0x0001 #define APK_SOLVERF_AVAILABLE 0x0002 #define APK_SOLVERF_REINSTALL 0x0004 +#define APK_SOLVERF_PREFER_TAG 0x0008 void apk_solver_set_name_flags(struct apk_name *name, unsigned short solver_flags, diff --git a/src/solver.c b/src/solver.c index 074df6b..9231fd9 100644 --- a/src/solver.c +++ b/src/solver.c @@ -287,13 +287,21 @@ static int compare_package_preference(unsigned short solver_flags, struct apk_package *pkgA, struct apk_package *pkgB) { - /* preferred repository pinning */ - if ((pkgA->ipkg || pkgA->filename || (pkgA->repos & preferred_repos)) && - !(pkgB->ipkg || pkgB->filename || (pkgB->repos & preferred_repos))) - return 1; - if ((pkgB->ipkg || pkgA->filename || (pkgB->repos & preferred_repos)) && - !(pkgA->ipkg || pkgB->filename || (pkgA->repos & preferred_repos))) - return -1; + if (solver_flags & APK_SOLVERF_PREFER_TAG) { + /* preferred repository pinning */ + if ((pkgA->repos & preferred_repos) && !(pkgB->repos & preferred_repos)) + return 1; + if ((pkgB->repos & preferred_repos) && !(pkgA->repos & preferred_repos)) + return -1; + } else { + /* preferred repository pinning */ + if ((pkgA->ipkg || pkgA->filename || (pkgA->repos & preferred_repos)) && + !(pkgB->ipkg || pkgB->filename || (pkgB->repos & preferred_repos))) + return 1; + if ((pkgB->ipkg || pkgA->filename || (pkgB->repos & preferred_repos)) && + !(pkgA->ipkg || pkgB->filename || (pkgA->repos & preferred_repos))) + return -1; + } if (solver_flags & APK_SOLVERF_AVAILABLE) { if (pkgA->repos != 0 && pkgB->repos == 0) @@ -332,10 +340,13 @@ static int get_preference(struct apk_solver_state *ss, unsigned short name_flags = ns->solver_flags_local | ns->solver_flags_inherited | ss->solver_flags; - unsigned int preferred_repos = ns->preferred_repos | ss->db->repo_tags[0].allowed_repos; + unsigned int preferred_repos = ns->preferred_repos; unsigned short preference = 0; int i; + if (preferred_repos == 0) + preferred_repos = ss->db->repo_tags[0].allowed_repos; + for (i = 0; i < name->pkgs->num; i++) { struct apk_package *pkg0 = name->pkgs->item[i]; struct apk_package_state *ps0 = pkg_to_ps(pkg0); |