diff options
author | Paul Spooren <mail@aparcar.org> | 2021-12-23 13:43:11 +0000 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-12-27 10:29:10 +0200 |
commit | f3fc0105f8c621bd1a77363cbb53f843c58100f4 (patch) | |
tree | 4215a1d720ab9e86f913db92983b6a1ed5478470 /src/app_list.c | |
parent | 0baf59627bb62a72de99ed05c77f6e39be00cd03 (diff) | |
download | apk-tools-f3fc0105f8c621bd1a77363cbb53f843c58100f4.tar.gz apk-tools-f3fc0105f8c621bd1a77363cbb53f843c58100f4.tar.bz2 apk-tools-f3fc0105f8c621bd1a77363cbb53f843c58100f4.tar.xz apk-tools-f3fc0105f8c621bd1a77363cbb53f843c58100f4.zip |
list --manifest
print installed packages in `<name> <version>` format. The format is
currently used in OpenWrt and allows downstream tools to compare what's
installed in the firmware.
Signed-off-by: Paul Spooren <mail@aparcar.org>
Diffstat (limited to 'src/app_list.c')
-rw-r--r-- | src/app_list.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/app_list.c b/src/app_list.c index 5e14fe1..9489ee6 100644 --- a/src/app_list.c +++ b/src/app_list.c @@ -26,6 +26,7 @@ struct list_ctx { unsigned int match_origin : 1; unsigned int match_depends : 1; unsigned int match_providers : 1; + unsigned int manifest : 1; struct apk_string_array *filters; }; @@ -121,6 +122,11 @@ static void print_package(const struct apk_package *pkg, const struct list_ctx * printf("\n"); } +static void print_manifest(const struct apk_package *pkg, const struct list_ctx *ctx) +{ + printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version)); +} + static void filter_package(const struct apk_package *pkg, const struct list_ctx *ctx) { if (ctx->match_origin && !origin_matches(ctx, pkg)) @@ -138,7 +144,10 @@ static void filter_package(const struct apk_package *pkg, const struct list_ctx if (ctx->upgradable && !is_upgradable(pkg->name, pkg)) return; - print_package(pkg, ctx); + if (ctx->manifest) + print_manifest(pkg, ctx); + else + print_package(pkg, ctx); } static void iterate_providers(const struct apk_name *name, const struct list_ctx *ctx) @@ -180,6 +189,7 @@ static void print_result(struct apk_database *db, const char *match, struct apk_ OPT(OPT_LIST_orphaned, APK_OPT_SH("O") "orphaned") \ OPT(OPT_LIST_providers, APK_OPT_SH("P") "providers") \ OPT(OPT_LIST_upgradable, APK_OPT_SH("u") "upgradable") \ + OPT(OPT_LIST_manifest, "manifest") \ OPT(OPT_LIST_upgradeable, "upgradeable") APK_OPT_APPLET(option_desc, LIST_OPTIONS); @@ -209,6 +219,10 @@ static int option_parse_applet(void *pctx, struct apk_ctx *ac, int opt, const ch case OPT_LIST_providers: ctx->match_providers = 1; break; + case OPT_LIST_manifest: + ctx->manifest = 1; + ctx->installed = 1; + break; case OPT_LIST_upgradable: case OPT_LIST_upgradeable: ctx->available = 1; |