Commit 0fe3f396 authored by Timo Teräs's avatar Timo Teräs

fetch: fix --recursive mode to work with pure virtual packages

The virtual package provider still needs to be explicitly
given on command line.
parent 6542d4ca
......@@ -100,6 +100,7 @@ struct apk_name {
struct apk_name_array *rdepends;
struct apk_name_array *rinstall_if;
unsigned is_dependency : 1;
unsigned auto_select_virtual: 1;
unsigned int foreach_genid;
union {
struct apk_solver_name_state ss;
......
......@@ -216,6 +216,11 @@ static void mark_error(struct fetch_ctx *ctx, const char *match, struct apk_name
ctx->errors++;
}
static void mark_name_flags(struct apk_database *db, const char *match, struct apk_name *name, void *ctx)
{
name->auto_select_virtual = 1;
}
static void mark_name_recursive(struct apk_database *db, const char *match, struct apk_name *name, void *ctx)
{
struct apk_changeset changeset = {};
......@@ -299,7 +304,7 @@ static int purge_package(void *pctx, int dirfd, const char *filename)
static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_array *args)
{
struct fetch_ctx *ctx = (struct fetch_ctx *) pctx;
void *mark = (ctx->flags & FETCH_RECURSIVE) ? mark_name_recursive : mark_name;
void *mark;
if (ctx->flags & FETCH_STDOUT) {
apk_flags &= ~APK_PROGRESS;
......@@ -318,6 +323,12 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
ctx->db = db;
if (ctx->flags & FETCH_RECURSIVE) {
apk_name_foreach_matching(db, args, apk_foreach_genid(), mark_name_flags, ctx);
mark = mark_name_recursive;
} else {
mark = mark_name;
}
apk_name_foreach_matching(db, args, apk_foreach_genid(), mark, ctx);
if (!ctx->errors)
apk_hash_foreach(&db->available.packages, fetch_package, ctx);
......
......@@ -640,7 +640,9 @@ static void select_package(struct apk_solver_state *ss, struct apk_name *name)
!p->pkg->ss.tag_ok))
continue;
/* Virtual packages cannot be autoselected */
if (p->version == &apk_null_blob && p->pkg->name->ss.requirers == 0)
if (p->version == &apk_null_blob &&
p->pkg->name->auto_select_virtual == 0 &&
p->pkg->name->ss.requirers == 0)
continue;
if (compare_providers(ss, p, &chosen) > 0)
chosen = *p;
......
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