summaryrefslogtreecommitdiff
path: root/src/info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/info.c')
-rw-r--r--src/info.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/info.c b/src/info.c
index 2e41742..c981c18 100644
--- a/src/info.c
+++ b/src/info.c
@@ -54,6 +54,38 @@ static int info_exists(struct apk_database *db, int argc, char **argv)
return 0;
}
+static int info_who_owns(struct apk_database *db, int argc, char **argv)
+{
+ struct apk_package *pkg;
+ struct apk_dependency_array *deps = NULL;
+ struct apk_dependency dep;
+ int i;
+
+ for (i = 0; i < argc; i++) {
+ pkg = apk_db_get_file_owner(db, APK_BLOB_STR(argv[i]));
+ if (pkg == NULL)
+ continue;
+
+ if (apk_quiet) {
+ dep = (struct apk_dependency) {
+ .name = pkg->name,
+ };
+ apk_deps_add(&deps, &dep);
+ } else {
+ printf("%s is owned by %s-%s\n", argv[i],
+ pkg->name->name, pkg->version);
+ }
+ }
+ if (apk_quiet && deps != NULL) {
+ char buf[512];
+ apk_deps_format(buf, sizeof(buf), deps);
+ printf("%s\n", buf);
+ free(deps);
+ }
+
+ return 0;
+}
+
static int info_parse(void *ctx, int optch, int optindex, const char *optarg)
{
struct info_ctx *ictx = (struct info_ctx *) ctx;
@@ -62,6 +94,9 @@ static int info_parse(void *ctx, int optch, int optindex, const char *optarg)
case 'e':
ictx->action = info_exists;
break;
+ case 'W':
+ ictx->action = info_who_owns;
+ break;
default:
return -1;
}
@@ -88,6 +123,7 @@ static int info_main(void *ctx, int argc, char **argv)
static struct option info_options[] = {
{ "installed", no_argument, NULL, 'e' },
+ { "who-owns", no_argument, NULL, 'W' },
};
static struct apk_applet apk_info = {