state: check package availability always
even if we have only one package as candidate, we need to check it's availability. otherwise we can endup with bad changeset referring to unavailable package.cute-signatures
parent
73cbc38794
commit
b40b2f0429
23
src/state.c
23
src/state.c
|
@ -157,6 +157,16 @@ static void ns_free(apk_name_state_t name)
|
||||||
name_choices_unref(ns_to_choices(name));
|
name_choices_unref(ns_to_choices(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int apk_state_pkg_available(struct apk_state *state,
|
||||||
|
struct apk_package *pkg)
|
||||||
|
{
|
||||||
|
if (pkg->filename != NULL)
|
||||||
|
return TRUE;
|
||||||
|
if (apk_db_select_repo(state->db, pkg) != NULL)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
struct apk_state *apk_state_new(struct apk_database *db)
|
struct apk_state *apk_state_new(struct apk_database *db)
|
||||||
{
|
{
|
||||||
struct apk_state *state;
|
struct apk_state *state;
|
||||||
|
@ -263,16 +273,16 @@ int apk_state_prune_dependency(struct apk_state *state,
|
||||||
c->pkgs[i] = c->pkgs[c->num - 1];
|
c->pkgs[i] = c->pkgs[c->num - 1];
|
||||||
c->num--;
|
c->num--;
|
||||||
}
|
}
|
||||||
if (c->num == 0) {
|
if (c->num == 1 && apk_state_pkg_available(state, c->pkgs[0])) {
|
||||||
name_choices_unref(c);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (c->num == 1) {
|
|
||||||
struct apk_package *pkg = c->pkgs[0];
|
struct apk_package *pkg = c->pkgs[0];
|
||||||
name_choices_unref(c);
|
name_choices_unref(c);
|
||||||
state->name[name->id] = ns_from_pkg(pkg);
|
state->name[name->id] = ns_from_pkg(pkg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (c->num <= 1) {
|
||||||
|
name_choices_unref(c);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
state->name[name->id] = ns_from_choices(c);
|
state->name[name->id] = ns_from_choices(c);
|
||||||
return c->num;
|
return c->num;
|
||||||
|
@ -301,8 +311,7 @@ int apk_state_lock_dependency(struct apk_state *state,
|
||||||
|
|
||||||
if (pkg->ipkg != NULL)
|
if (pkg->ipkg != NULL)
|
||||||
installed = pkg;
|
installed = pkg;
|
||||||
else if (pkg->filename == NULL &&
|
else if (!apk_state_pkg_available(state, pkg))
|
||||||
apk_db_select_repo(state->db, pkg) == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (latest == NULL) {
|
if (latest == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue