summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/search.c')
-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 = {