parent
f8cf7a0a0d
commit
ff7c8f6ee9
|
@ -32,6 +32,9 @@ specified.
|
||||||
*Note*: this option is incompatible with *-o*, *-R*, and the global
|
*Note*: this option is incompatible with *-o*, *-R*, and the global
|
||||||
*--progress* option.
|
*--progress* option.
|
||||||
|
|
||||||
|
*-w, --world*
|
||||||
|
Download packages needed to satisfy _world_. Implies *--recursive*.
|
||||||
|
|
||||||
*--simulate*
|
*--simulate*
|
||||||
Simulate the requested operation without making any changes.
|
Simulate the requested operation without making any changes.
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
#include "apk_print.h"
|
#include "apk_print.h"
|
||||||
#include "apk_solver.h"
|
#include "apk_solver.h"
|
||||||
|
|
||||||
#define FETCH_RECURSIVE 1
|
#define FETCH_RECURSIVE 0x01
|
||||||
#define FETCH_STDOUT 2
|
#define FETCH_STDOUT 0x02
|
||||||
#define FETCH_LINK 4
|
#define FETCH_LINK 0x04
|
||||||
#define FETCH_URL 8
|
#define FETCH_URL 0x08
|
||||||
|
#define FETCH_WORLD 0x10
|
||||||
|
|
||||||
struct fetch_ctx {
|
struct fetch_ctx {
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
@ -75,6 +76,7 @@ static int cup(void)
|
||||||
OPT(OPT_FETCH_simulate, "simulate") \
|
OPT(OPT_FETCH_simulate, "simulate") \
|
||||||
OPT(OPT_FETCH_stdout, APK_OPT_SH("s") "stdout") \
|
OPT(OPT_FETCH_stdout, APK_OPT_SH("s") "stdout") \
|
||||||
OPT(OPT_FETCH_url, "url") \
|
OPT(OPT_FETCH_url, "url") \
|
||||||
|
OPT(OPT_FETCH_world, APK_OPT_SH("w") "world") \
|
||||||
|
|
||||||
APK_OPT_APPLET(option_desc, FETCH_OPTIONS);
|
APK_OPT_APPLET(option_desc, FETCH_OPTIONS);
|
||||||
|
|
||||||
|
@ -101,6 +103,10 @@ static int option_parse_applet(void *ctx, struct apk_ctx *ac, int opt, const cha
|
||||||
case OPT_FETCH_url:
|
case OPT_FETCH_url:
|
||||||
fctx->flags |= FETCH_URL;
|
fctx->flags |= FETCH_URL;
|
||||||
break;
|
break;
|
||||||
|
case OPT_FETCH_world:
|
||||||
|
fctx->flags |= FETCH_WORLD | FETCH_RECURSIVE;
|
||||||
|
ac->open_flags &= ~APK_OPENF_NO_WORLD;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +224,12 @@ static void mark_error(struct fetch_ctx *ctx, const char *match, struct apk_name
|
||||||
ctx->errors++;
|
ctx->errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mark_dep_flags(struct fetch_ctx *ctx, struct apk_dependency *dep)
|
||||||
|
{
|
||||||
|
dep->name->auto_select_virtual = 1;
|
||||||
|
apk_deps_add(&ctx->world, dep);
|
||||||
|
}
|
||||||
|
|
||||||
static void mark_name_flags(struct apk_database *db, const char *match, struct apk_name *name, void *pctx)
|
static void mark_name_flags(struct apk_database *db, const char *match, struct apk_name *name, void *pctx)
|
||||||
{
|
{
|
||||||
struct fetch_ctx *ctx = (struct fetch_ctx *) pctx;
|
struct fetch_ctx *ctx = (struct fetch_ctx *) pctx;
|
||||||
|
@ -228,8 +240,7 @@ static void mark_name_flags(struct apk_database *db, const char *match, struct a
|
||||||
};
|
};
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
name->auto_select_virtual = 1;
|
mark_dep_flags(ctx, &dep);
|
||||||
apk_deps_add(&ctx->world, &dep);
|
|
||||||
} else {
|
} else {
|
||||||
ctx->errors++;
|
ctx->errors++;
|
||||||
mark_error(ctx, match, name);
|
mark_error(ctx, match, name);
|
||||||
|
@ -310,6 +321,7 @@ static int fetch_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *a
|
||||||
struct apk_out *out = &ac->out;
|
struct apk_out *out = &ac->out;
|
||||||
struct apk_database *db = ac->db;
|
struct apk_database *db = ac->db;
|
||||||
struct fetch_ctx *ctx = (struct fetch_ctx *) pctx;
|
struct fetch_ctx *ctx = (struct fetch_ctx *) pctx;
|
||||||
|
struct apk_dependency *dep;
|
||||||
|
|
||||||
ctx->db = db;
|
ctx->db = db;
|
||||||
ctx->prog = db->ctx->progress;
|
ctx->prog = db->ctx->progress;
|
||||||
|
@ -329,6 +341,8 @@ static int fetch_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *a
|
||||||
|
|
||||||
if (ctx->flags & FETCH_RECURSIVE) {
|
if (ctx->flags & FETCH_RECURSIVE) {
|
||||||
apk_dependency_array_init(&ctx->world);
|
apk_dependency_array_init(&ctx->world);
|
||||||
|
foreach_array_item(dep, db->world)
|
||||||
|
mark_dep_flags(ctx, dep);
|
||||||
apk_name_foreach_matching(db, args, apk_foreach_genid(), mark_name_flags, ctx);
|
apk_name_foreach_matching(db, args, apk_foreach_genid(), mark_name_flags, ctx);
|
||||||
if (ctx->errors == 0)
|
if (ctx->errors == 0)
|
||||||
mark_names_recursive(db, args, ctx);
|
mark_names_recursive(db, args, ctx);
|
||||||
|
@ -349,7 +363,7 @@ static int fetch_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *a
|
||||||
|
|
||||||
static struct apk_applet apk_fetch = {
|
static struct apk_applet apk_fetch = {
|
||||||
.name = "fetch",
|
.name = "fetch",
|
||||||
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
|
.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE,
|
||||||
.context_size = sizeof(struct fetch_ctx),
|
.context_size = sizeof(struct fetch_ctx),
|
||||||
.optgroups = { &optgroup_global, &optgroup_applet },
|
.optgroups = { &optgroup_global, &optgroup_applet },
|
||||||
.main = fetch_main,
|
.main = fetch_main,
|
||||||
|
|
Loading…
Reference in New Issue