summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-12 15:25:16 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-13 18:22:00 +0300
commit59678309ea7350a159a3f5ee61c2fb5218dee6d5 (patch)
tree92c9d2dd24da6f628683b58e93b1a881804cd4fa
parente7fd4d03bfd430053cca5161846889d5e2b1e2a1 (diff)
downloadapk-tools-59678309ea7350a159a3f5ee61c2fb5218dee6d5.tar.gz
apk-tools-59678309ea7350a159a3f5ee61c2fb5218dee6d5.tar.bz2
apk-tools-59678309ea7350a159a3f5ee61c2fb5218dee6d5.tar.xz
apk-tools-59678309ea7350a159a3f5ee61c2fb5218dee6d5.zip
solver: corner case fixes
- try harder to not change anything during self-upgrade - also honor locking to packages that where earlier used in merging common dependencies - clarify upgrade applet help messages
-rw-r--r--src/apk_solver_data.h2
-rw-r--r--src/solver.c22
-rw-r--r--src/upgrade.c11
3 files changed, 27 insertions, 8 deletions
diff --git a/src/apk_solver_data.h b/src/apk_solver_data.h
index b1047f0..fa59fd0 100644
--- a/src/apk_solver_data.h
+++ b/src/apk_solver_data.h
@@ -45,6 +45,8 @@ struct apk_solver_package_state {
unsigned tag_ok : 1;
unsigned tag_preferred : 1;
unsigned available : 1;
+ unsigned dependencies_used : 1;
+ unsigned dependencies_merged : 1;
unsigned in_changeset : 1;
unsigned iif_triggered : 1;
};
diff --git a/src/solver.c b/src/solver.c
index 59214e2..4823ece 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -329,6 +329,7 @@ static void reconsider_name(struct apk_solver_state *ss, struct apk_name *name)
struct apk_package *pkg = p0->pkg;
/* check if this pkg's dependencies have become unsatisfiable */
+ pkg->ss.dependencies_merged = 0;
if (reevaluate_deps) {
if (!pkg->ss.available)
continue;
@@ -360,6 +361,7 @@ static void reconsider_name(struct apk_solver_state *ss, struct apk_name *name)
num_tag_not_ok += !pkg->ss.tag_ok;
/* merge common dependencies */
+ pkg->ss.dependencies_merged = 1;
if (first_candidate == -1)
first_candidate = i;
for (j = 0; j < pkg->depends->num; j++) {
@@ -377,6 +379,10 @@ static void reconsider_name(struct apk_solver_state *ss, struct apk_name *name)
queue_unresolved(ss, name);
if (first_candidate != -1) {
+ for (i = 0; i < name->providers->num; i++) {
+ struct apk_package *pkg = name->providers->item[i].pkg;
+ pkg->ss.dependencies_used = pkg->ss.dependencies_merged;
+ }
/* TODO: could merge versioning bits too */
/* propagate down common dependencies */
pkg = name->providers->item[first_candidate].pkg;
@@ -418,13 +424,25 @@ static int compare_providers(struct apk_solver_state *ss,
if (r)
return r;
+ /* Prefer those that were in last dependency merging group */
+ r = (int)pkgA->ss.dependencies_used - (int)pkgB->ss.dependencies_used;
+ if (r)
+ return r;
+
+ /* Prefer installed on self-upgrade */
+ solver_flags = pkgA->ss.solver_flags | pkgB->ss.solver_flags;
+ if (db->performing_self_update && !(solver_flags & APK_SOLVERF_UPGRADE)) {
+ r = (pkgA->ipkg != NULL) - (pkgB->ipkg != NULL);
+ if (r)
+ return r;
+ }
+
/* Prefer allowed pinning */
r = (int)pkgA->ss.tag_ok - (int)pkgB->ss.tag_ok;
if (r)
return r;
/* Prefer available */
- solver_flags = pkgA->ss.solver_flags | pkgB->ss.solver_flags;
if (solver_flags & APK_SOLVERF_AVAILABLE) {
r = !!(pkgA->repos & db->available_repos) -
!!(pkgB->repos & db->available_repos);
@@ -712,8 +730,6 @@ int apk_solver_solve(struct apk_database *db,
foreach_dependency(ss, world, discover_names);
- /* FIXME: If filename specified, force to use it */
-
dbg_printf("applying world\n");
ss->prefer_pinning = 1;
ss->solver_flags_inherit = solver_flags;
diff --git a/src/upgrade.c b/src/upgrade.c
index 1768795..60b19ec 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -60,7 +60,7 @@ int apk_do_self_upgrade(struct apk_database *db, unsigned short solver_flags)
goto ret;
}
- if (changeset.num_install + changeset.num_remove + changeset.num_adjust == 0)
+ if (changeset.num_total_changes == 0)
goto ret;
if (apk_flags & APK_SIMULATE) {
@@ -130,16 +130,17 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
static struct apk_option upgrade_options[] = {
{ 'a', "available",
- "Re-install or downgrade if currently installed package is not "
- "currently available from any repository" },
+ "Resets versioned world dependencies, and changes to prefer "
+ "replacing or downgrading packages (instead of holding them) "
+ "if the currently installed package is no longer available "
+ "from any repository" },
{ 0x10000, "no-self-upgrade",
"Do not do early upgrade of 'apk-tools' package" },
};
static struct apk_applet apk_upgrade = {
.name = "upgrade",
- .help = "Upgrade (or downgrade with -a) the currently installed "
- "packages to versions available in repositories.",
+ .help = "Upgrade currently installed packages to match repositories.",
.open_flags = APK_OPENF_WRITE,
.context_size = sizeof(struct upgrade_ctx),
.num_options = ARRAY_SIZE(upgrade_options),