summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-08-28 14:17:07 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-08-28 14:17:45 +0000
commitf69f047f2528932221a7036a13bfe8cc8c6522b9 (patch)
tree90bc6dff5f5187cfde25fdfbf9187c7e02a49ffe /src
parent0a4ff4f53485c09b08606179c635d59abe75750a (diff)
downloadapk-tools-f69f047f2528932221a7036a13bfe8cc8c6522b9.tar.gz
apk-tools-f69f047f2528932221a7036a13bfe8cc8c6522b9.tar.bz2
apk-tools-f69f047f2528932221a7036a13bfe8cc8c6522b9.tar.xz
apk-tools-f69f047f2528932221a7036a13bfe8cc8c6522b9.zip
search: implement --has-origin
This option lets us search for all package with given origin.
Diffstat (limited to 'src')
-rw-r--r--src/search.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/search.c b/src/search.c
index c85892b..84fcbb1 100644
--- a/src/search.c
+++ b/src/search.c
@@ -23,6 +23,7 @@ struct search_ctx {
int show_all : 1;
int search_exact : 1;
int search_description : 1;
+ int search_origin : 1;
unsigned int matches;
struct apk_string_array *filter;
@@ -88,6 +89,11 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
case 'r':
ictx->print_result = print_rdepends;
break;
+ case 0x10000:
+ ictx->search_origin = 1;
+ ictx->search_exact = 1;
+ ictx->show_all = 1;
+ break;
default:
return -1;
}
@@ -106,6 +112,13 @@ static void print_result_pkg(struct search_ctx *ctx, struct apk_package *pkg)
}
return;
}
+ if (ctx->search_origin) {
+ foreach_array_item(pmatch, ctx->filter) {
+ if (pkg->origin != NULL && strcmp(*pmatch, apk_blob_cstr(*pkg->origin)) == 0)
+ goto match;
+ }
+ return;
+ }
match:
ctx->print_result(ctx, pkg);
}
@@ -148,7 +161,7 @@ static int search_main(void *pctx, struct apk_database *db, struct apk_string_ar
if (ctx->print_result == NULL)
ctx->print_result = ctx->print_package;
- if (ctx->search_description)
+ if (ctx->search_description || ctx->search_origin)
return apk_hash_foreach(&db->available.packages, print_pkg, ctx);
if (!ctx->search_exact) {
@@ -171,6 +184,7 @@ static struct apk_option search_options[] = {
{ 'e', NULL, "Synonym for -x (deprecated)" },
{ 'o', "origin", "Print origin package name instead of the subpackage" },
{ 'r', "rdepends", "Print reverse dependencies of package" },
+ { 0x10000, "has-origin","List packages that have the given origin" },
};
static struct apk_applet apk_search = {