search: implement --has-origin
This option lets us search for all package with given origin.cute-signatures
parent
0a4ff4f534
commit
f69f047f25
16
src/search.c
16
src/search.c
|
@ -23,6 +23,7 @@ struct search_ctx {
|
||||||
int show_all : 1;
|
int show_all : 1;
|
||||||
int search_exact : 1;
|
int search_exact : 1;
|
||||||
int search_description : 1;
|
int search_description : 1;
|
||||||
|
int search_origin : 1;
|
||||||
|
|
||||||
unsigned int matches;
|
unsigned int matches;
|
||||||
struct apk_string_array *filter;
|
struct apk_string_array *filter;
|
||||||
|
@ -88,6 +89,11 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
|
||||||
case 'r':
|
case 'r':
|
||||||
ictx->print_result = print_rdepends;
|
ictx->print_result = print_rdepends;
|
||||||
break;
|
break;
|
||||||
|
case 0x10000:
|
||||||
|
ictx->search_origin = 1;
|
||||||
|
ictx->search_exact = 1;
|
||||||
|
ictx->show_all = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +112,13 @@ static void print_result_pkg(struct search_ctx *ctx, struct apk_package *pkg)
|
||||||
}
|
}
|
||||||
return;
|
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:
|
match:
|
||||||
ctx->print_result(ctx, pkg);
|
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)
|
if (ctx->print_result == NULL)
|
||||||
ctx->print_result = ctx->print_package;
|
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);
|
return apk_hash_foreach(&db->available.packages, print_pkg, ctx);
|
||||||
|
|
||||||
if (!ctx->search_exact) {
|
if (!ctx->search_exact) {
|
||||||
|
@ -171,6 +184,7 @@ static struct apk_option search_options[] = {
|
||||||
{ 'e', NULL, "Synonym for -x (deprecated)" },
|
{ 'e', NULL, "Synonym for -x (deprecated)" },
|
||||||
{ 'o', "origin", "Print origin package name instead of the subpackage" },
|
{ 'o', "origin", "Print origin package name instead of the subpackage" },
|
||||||
{ 'r', "rdepends", "Print reverse dependencies of package" },
|
{ 'r', "rdepends", "Print reverse dependencies of package" },
|
||||||
|
{ 0x10000, "has-origin","List packages that have the given origin" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct apk_applet apk_search = {
|
static struct apk_applet apk_search = {
|
||||||
|
|
Loading…
Reference in New Issue