Commit 7b6e44b1 authored by Timo Teräs's avatar Timo Teräs

upgrade: reset world dependencies during traversal

This allows us to get apk-tools dependencies get reset at proper
time in world. As a bonus, it reduces code amount.
parent 4e72075f
...@@ -138,6 +138,10 @@ static struct apk_name_choices *name_choices_new(struct apk_database *db, ...@@ -138,6 +138,10 @@ static struct apk_name_choices *name_choices_new(struct apk_database *db,
if (dep->name != name) if (dep->name != name)
continue; continue;
if (apk_flags & APK_PREFER_AVAILABLE) {
dep->version = apk_blob_atomize(APK_BLOB_NULL);
dep->result_mask = APK_DEPMASK_REQUIRE;
} else {
for (j = 0; j < nc->num; ) { for (j = 0; j < nc->num; ) {
if (apk_dep_is_satisfied(dep, nc->pkgs[j])) { if (apk_dep_is_satisfied(dep, nc->pkgs[j])) {
j++; j++;
...@@ -147,6 +151,8 @@ static struct apk_name_choices *name_choices_new(struct apk_database *db, ...@@ -147,6 +151,8 @@ static struct apk_name_choices *name_choices_new(struct apk_database *db,
} }
} }
} }
break;
}
return nc; return nc;
} }
......
...@@ -33,21 +33,10 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts, ...@@ -33,21 +33,10 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
int apk_do_self_upgrade(struct apk_database *db, struct apk_state *state) int apk_do_self_upgrade(struct apk_database *db, struct apk_state *state)
{ {
struct apk_dependency dep; struct apk_dependency dep;
int r, i; int r;
apk_dep_from_blob(&dep, db, APK_BLOB_STR("apk-tools")); apk_dep_from_blob(&dep, db, APK_BLOB_STR("apk-tools"));
if (apk_flags & APK_PREFER_AVAILABLE) {
for (i = 0; i < db->world->num; i++) {
struct apk_dependency *dep0 = &db->world->item[i];
if (dep0->name != dep.name)
continue;
dep0->version = apk_blob_atomize(APK_BLOB_NULL);
dep0->result_mask = APK_DEPMASK_REQUIRE;
break;
}
}
r = apk_state_lock_dependency(state, &dep); r = apk_state_lock_dependency(state, &dep);
if (r != 0 || state->num_changes == 0) if (r != 0 || state->num_changes == 0)
return r; return r;
...@@ -74,7 +63,6 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg ...@@ -74,7 +63,6 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
{ {
struct apk_state *state = NULL; struct apk_state *state = NULL;
struct apk_name_array *missing; struct apk_name_array *missing;
apk_blob_t *null_atom = apk_blob_atomize(APK_BLOB_NULL);
int i, r = 0; int i, r = 0;
apk_flags |= APK_UPGRADE; apk_flags |= APK_UPGRADE;
...@@ -92,11 +80,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg ...@@ -92,11 +80,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
for (i = 0; i < db->world->num; i++) { for (i = 0; i < db->world->num; i++) {
struct apk_dependency *dep = &db->world->item[i]; struct apk_dependency *dep = &db->world->item[i];
if (dep->version != null_atom &&
(apk_flags & APK_PREFER_AVAILABLE)) {
dep->result_mask = APK_DEPMASK_REQUIRE;
dep->version = null_atom;
}
if (dep->name->pkgs->num != 0) if (dep->name->pkgs->num != 0)
r |= apk_state_lock_dependency(state, dep); r |= apk_state_lock_dependency(state, dep);
else else
......
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