summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-12-08 08:30:58 +0200
committerTimo Teräs <timo.teras@iki.fi>2014-12-08 08:31:41 +0200
commit02cd5a9c76cd676545c232bb567d7eb01e5bd6fd (patch)
treece05b50bff40784b36c310eee0916be229e640b2 /src/fetch.c
parent6697ed5e86e64516ac56894d2f81c575ff72fd4f (diff)
downloadapk-tools-02cd5a9c76cd676545c232bb567d7eb01e5bd6fd.tar.gz
apk-tools-02cd5a9c76cd676545c232bb567d7eb01e5bd6fd.tar.bz2
apk-tools-02cd5a9c76cd676545c232bb567d7eb01e5bd6fd.tar.xz
apk-tools-02cd5a9c76cd676545c232bb567d7eb01e5bd6fd.zip
make del, fetch, fix and info return errors
In case all applet arguments are packages names (that is are not including wildcards), return error if they do not match to some package.
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/fetch.c b/src/fetch.c
index 3c40963..7caf9d4 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -207,7 +207,7 @@ static void mark_error(struct fetch_ctx *ctx, const char *match, struct apk_name
if (strchr(match, '*') != NULL)
return;
- apk_message("%s: unable to select package (or it's dependencies)", name->name);
+ apk_message("%s: unable to select package (or it's dependencies)", name ? name->name : match);
ctx->errors++;
}
@@ -223,6 +223,11 @@ static void mark_name_recursive(struct apk_database *db, const char *match, stru
struct apk_change *change;
int r;
+ if (!name) {
+ mark_error(ctx, match, name);
+ return;
+ }
+
apk_dependency_array_init(&world);
*apk_dependency_array_add(&world) = dep;
r = apk_solver_solve(db, 0, world, &changeset);
@@ -241,14 +246,18 @@ static void mark_name(struct apk_database *db, const char *match, struct apk_nam
struct apk_package *pkg = NULL;
struct apk_provider *p;
+ if (!name) goto err;
+
foreach_array_item(p, name->providers)
if (pkg == NULL || apk_pkg_version_compare(p->pkg, pkg) == APK_VERSION_GREATER)
pkg = p->pkg;
- if (pkg != NULL)
- mark_package(ctx, pkg);
- else
- mark_error(ctx, match, name);
+ if (!pkg) goto err;
+ mark_package(ctx, pkg);
+ return;
+
+err:
+ mark_error(ctx, match, name);
}
static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_array *args)
@@ -272,8 +281,10 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
}
ctx->db = db;
+
apk_name_foreach_matching(db, args, apk_foreach_genid(), mark, ctx);
- apk_hash_foreach(&db->available.packages, fetch_package, ctx);
+ if (!ctx->errors)
+ apk_hash_foreach(&db->available.packages, fetch_package, ctx);
return ctx->errors;
}