[openwrt/openwrt] apk: Implement apk list --full patch
LEDE Commits
lede-commits at lists.infradead.org
Sat Nov 9 17:14:06 PST 2024
ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/79f06827ff7145b850e072c0ed26802573a2199f
commit 79f06827ff7145b850e072c0ed26802573a2199f
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Wed Oct 23 01:13:15 2024 +0200
apk: Implement apk list --full patch
Implement apk list --full patch to mimik opkg package info.
Link: https://github.com/openwrt/openwrt/pull/16759
Link: https://github.com/openwrt/openwrt/pull/16759
Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
.../apk/patches/0010-app_list-add-full-print.patch | 91 ++++++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/package/system/apk/patches/0010-app_list-add-full-print.patch b/package/system/apk/patches/0010-app_list-add-full-print.patch
new file mode 100644
index 0000000000..d0b2b7243d
--- /dev/null
+++ b/package/system/apk/patches/0010-app_list-add-full-print.patch
@@ -0,0 +1,91 @@
+From f74ca42e0fa5bf131644a46d8259edd493bf072c Mon Sep 17 00:00:00 2001
+From: Christian Marangi <ansuelsmth at gmail.com>
+Date: Wed, 23 Oct 2024 01:11:01 +0200
+Subject: [PATCH] app_list: add full print
+
+Add full print variant to dump info about each package.
+
+Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
+---
+ src/app_list.c | 42 +++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 41 insertions(+), 1 deletion(-)
+
+--- a/src/app_list.c
++++ b/src/app_list.c
+@@ -27,6 +27,7 @@ struct list_ctx {
+ unsigned int match_depends : 1;
+ unsigned int match_providers : 1;
+ unsigned int manifest : 1;
++ unsigned int full : 1;
+
+ struct apk_string_array *filters;
+ };
+@@ -118,6 +119,40 @@ static void print_manifest(const struct
+ printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version));
+ }
+
++static void print_full(const struct apk_package *pkg, const struct list_ctx *ctx)
++{
++ struct apk_dependency *d;
++
++ printf("Package: %s\n", pkg->name->name);
++ printf("Version: " BLOB_FMT "\n", BLOB_PRINTF(*pkg->version));
++ if (apk_array_len(pkg->depends)) {
++ int i = 0;
++
++ printf("Depends: ");
++ foreach_array_item(d, pkg->depends) {
++ i++;
++ printf("%s%s", d->name->name, i < apk_array_len(pkg->depends) ? ", ": "\n");
++ }
++ }
++ if (apk_array_len(pkg->provides)) {
++ int i = 0;
++
++ printf("Provides: ");
++ foreach_array_item(d, pkg->provides) {
++ i++;
++ printf("%s%s", d->name->name, i < apk_array_len(pkg->provides) ? ", ": "\n");
++ }
++ }
++ if (pkg->ipkg && ctx->installed)
++ printf("Status: install ok %s\n", pkg->marked ? "hold" : "installed");
++ if (pkg->description)
++ printf("Description: " BLOB_FMT "\n", BLOB_PRINTF(*pkg->description));
++ printf("License: " BLOB_FMT "\n", BLOB_PRINTF(*pkg->license));
++ printf("Installed-Size: %zu\n", pkg->installed_size);
++ printf("Size: %zu\n", pkg->size);
++ printf("\n");
++}
++
+ static void filter_package(const struct apk_database *db, const struct apk_package *pkg, const struct list_ctx *ctx, const struct apk_name *name)
+ {
+ if (ctx->match_origin && !origin_matches(ctx, pkg))
+@@ -138,7 +173,9 @@ static void filter_package(const struct
+ if (ctx->match_providers)
+ printf("<%s> ", name->name);
+
+- if (ctx->manifest)
++ if (ctx->full)
++ print_full(pkg, ctx);
++ else if (ctx->manifest)
+ print_manifest(pkg, ctx);
+ else
+ print_package(db, pkg, ctx);
+@@ -178,6 +215,7 @@ static int print_result(struct apk_datab
+ OPT(OPT_LIST_depends, APK_OPT_SH("d") "depends") \
+ OPT(OPT_LIST_installed, APK_OPT_SH("I") "installed") \
+ OPT(OPT_LIST_manifest, "manifest") \
++ OPT(OPT_LIST_full, "full") \
+ OPT(OPT_LIST_origin, APK_OPT_SH("o") "origin") \
+ OPT(OPT_LIST_orphaned, APK_OPT_SH("O") "orphaned") \
+ OPT(OPT_LIST_providers, APK_OPT_SH("P") "providers") \
+@@ -191,6 +229,8 @@ static int option_parse_applet(void *pct
+ struct list_ctx *ctx = pctx;
+
+ switch (opt) {
++ case OPT_LIST_full:
++ ctx->full = 1;
+ case OPT_LIST_available:
+ ctx->available = 1;
+ ctx->orphaned = 0;
More information about the lede-commits
mailing list