1
0
Fork 0
forked from mirror/openwrt
openwrt/package/system/apk/patches/0010-app_list-add-full-print.patch
Christian Marangi e408030cec
apk-tools: fix compilation warning from downstream full print patch
Fix trivial compilation warning caused by downstream full print patch.

../src/app_list.c: In function 'print_full':
../src/app_list.c:85:35: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
   85 |         printf("Installed-Size: %zu\n", pkg->installed_size);
      |                                 ~~^     ~~~~~~~~~~~~~~~~~~~
      |                                   |        |
      |                                   |        uint64_t {aka long long unsigned int}
      |                                   unsigned int
      |                                 %llu
../src/app_list.c:86:25: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
   86 |         printf("Size: %zu\n", pkg->size);
      |                       ~~^     ~~~~~~~~~
      |                         |        |
      |                         |        uint64_t {aka long long unsigned int}
      |                         unsigned int
      |                       %llu
../src/app_list.c:58:31: warning: unused variable 'd' [-Wunused-variable]
   58 |         struct apk_dependency d;

Remove unused variable and use PRIu64 to handle uint64_t type.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2025-10-14 17:15:07 +02:00

92 lines
2.9 KiB
Diff

From f74ca42e0fa5bf131644a46d8259edd493bf072c Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@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@gmail.com>
---
src/app_list.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
--- a/src/app_list.c
+++ b/src/app_list.c
@@ -49,12 +49,51 @@ struct list_ctx {
unsigned int match_providers : 1;
unsigned int match_depends : 1;
unsigned int manifest : 1;
+ unsigned int installed : 1; /* Solely for print_full patch */
+ unsigned int full : 1;
};
+static void print_full(const struct apk_package *pkg, const struct list_ctx *ctx)
+{
+ 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: ");
+ apk_array_foreach(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: ");
+ apk_array_foreach(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: %" PRIu64 "\n", pkg->installed_size);
+ printf("Size: %" PRIu64 "\n", pkg->size);
+ printf("\n");
+}
+
static void print_package(const struct apk_database *db, const struct apk_name *name, const struct apk_package *pkg, const struct list_ctx *ctx)
{
if (ctx->match_providers) printf("<%s> ", name->name);
+ if (ctx->full) {
+ print_full(pkg, ctx);
+ return;
+ }
+
if (ctx->manifest) {
printf("%s " BLOB_FMT "\n", pkg->name->name, BLOB_PRINTF(*pkg->version));
return;
@@ -96,6 +135,7 @@ static void print_package(const struct a
OPT(OPT_LIST_depends, APK_OPT_SH("d") "depends") \
OPT(OPT_LIST_installed, APK_OPT_SH("I")) \
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")) \
OPT(OPT_LIST_providers, APK_OPT_SH("P") "providers") \
@@ -109,6 +149,9 @@ static int list_parse_option(void *pctx,
struct apk_query_spec *qs = &ac->query;
switch (opt) {
+ case OPT_LIST_full:
+ ctx->full = 1;
+ break;
case OPT_LIST_available:
qs->filter.available = 1;
break;
@@ -117,6 +160,7 @@ static int list_parse_option(void *pctx,
break;
case OPT_LIST_installed:
installed:
+ ctx->installed = 1;
qs->filter.installed = 1;
ac->open_flags |= APK_OPENF_NO_SYS_REPOS;
break;