Added -o option to apk info to list repository packages

cute-signatures
Cameron Banta 2009-03-06 03:29:56 +00:00 committed by Timo Teras
parent 9b48288831
commit e93cb1ffe5
1 changed files with 29 additions and 1 deletions

View File

@ -35,6 +35,30 @@ static int info_list(struct apk_database *db, int argc, char **argv)
return 0; return 0;
} }
static int info_repo_pkgs_print(apk_hash_item item, void *ctx)
{
struct apk_database *db = (struct apk_database *) ctx;
struct apk_package *pkg = (struct apk_package *) item;
printf("%s", pkg->name->name);
if (apk_verbosity > 0)
printf("-%s", pkg->version);
if (apk_verbosity > 1) {
printf("\n\t%s", db->repos[pkg->repos].url);
printf("\n\t%s", pkg->description);
}
printf("\n");
return 0;
}
static int info_repo_pkgs(struct apk_database *db, int argc, char **argv)
{
apk_hash_foreach(&db->available.packages, info_repo_pkgs_print, db);
return 0;
}
static int info_exists(struct apk_database *db, int argc, char **argv) static int info_exists(struct apk_database *db, int argc, char **argv)
{ {
struct apk_name *name; struct apk_name *name;
@ -183,6 +207,9 @@ static int info_parse(void *ctx, int optch, int optindex, const char *optarg)
case 'R': case 'R':
ictx->action = info_depends; ictx->action = info_depends;
break; break;
case 'o':
ictx->action = info_repo_pkgs;
break;
default: default:
return -1; return -1;
} }
@ -212,11 +239,12 @@ static struct option info_options[] = {
{ "installed", no_argument, NULL, 'e' }, { "installed", no_argument, NULL, 'e' },
{ "who-owns", no_argument, NULL, 'W' }, { "who-owns", no_argument, NULL, 'W' },
{ "depends", no_argument, NULL, 'R' }, { "depends", no_argument, NULL, 'R' },
{ "repo-pkgs", no_argument, NULL, 'o' },
}; };
static struct apk_applet apk_info = { static struct apk_applet apk_info = {
.name = "info", .name = "info",
.usage = "", .usage = "[--repo-pkgs|-o]",
.context_size = sizeof(struct info_ctx), .context_size = sizeof(struct info_ctx),
.num_options = ARRAY_SIZE(info_options), .num_options = ARRAY_SIZE(info_options),
.options = info_options, .options = info_options,