diff options
author | Timo Teräs <timo.teras@iki.fi> | 2023-03-04 14:48:43 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2023-04-11 20:47:43 +0300 |
commit | adafc698009724342762d61176f0edea422bc2b1 (patch) | |
tree | 64937302abad3d4a28fa54bbe4da41d3d20c0340 /src/app_index.c | |
parent | 67f5a753e50da8737dc28b0ea2c2194b21d76fdd (diff) | |
download | apk-tools-adafc698009724342762d61176f0edea422bc2b1.tar.gz apk-tools-adafc698009724342762d61176f0edea422bc2b1.tar.bz2 apk-tools-adafc698009724342762d61176f0edea422bc2b1.tar.xz apk-tools-adafc698009724342762d61176f0edea422bc2b1.zip |
index: report unsatisfied dependency warnings in sorted indented list
Diffstat (limited to 'src/app_index.c')
-rw-r--r-- | src/app_index.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/app_index.c b/src/app_index.c index 18c240f..e37d0af 100644 --- a/src/app_index.c +++ b/src/app_index.c @@ -20,7 +20,9 @@ #define APK_INDEXF_NO_WARNINGS 0x0001 struct counts { + struct apk_indent indent; int unsatisfied; + int header : 1; }; struct index_ctx { @@ -86,29 +88,26 @@ static int index_read_file(struct apk_database *db, struct index_ctx *ictx) return apk_db_index_read_file(db, ictx->index, 0); } -static int warn_if_no_providers(apk_hash_item item, void *ctx) +static int warn_if_no_providers(struct apk_database *db, const char *match, struct apk_name *name, void *ctx) { struct counts *counts = (struct counts *) ctx; - struct apk_name *name = (struct apk_name *) item; if (!name->is_dependency) return 0; if (name->providers->num) return 0; - if (++counts->unsatisfied < 10) { - apk_warning("No provider for dependency '%s'", - name->name); - } else if (counts->unsatisfied == 10) { - apk_warning("Too many unsatisfiable dependencies, " - "not reporting the rest."); + if (!counts->header) { + apk_print_indented_group(&counts->indent, 2, "WARNING: No provider for the dependencies:\n"); + counts->header = 1; } - + apk_print_indented(&counts->indent, APK_BLOB_STR(name->name)); + counts->unsatisfied++; return 0; } static int index_main(void *ctx, struct apk_database *db, struct apk_string_array *args) { - struct counts counts = {0}; - struct apk_ostream *os; + struct counts counts = { .unsatisfied=0 }; + struct apk_ostream *os, *counter; struct apk_file_info fi; int total, r, found, newpkgs = 0, errors = 0; struct index_ctx *ictx = (struct index_ctx *) ctx; @@ -205,8 +204,6 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra if (IS_ERR_OR_NULL(os)) return -1; if (ictx->method == APK_SIGN_GENERATE) { - struct apk_ostream *counter; - memset(&fi, 0, sizeof(fi)); fi.mode = 0644 | S_IFREG; fi.name = "APKINDEX"; @@ -243,7 +240,9 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra total = r; if (!(ictx->index_flags & APK_INDEXF_NO_WARNINGS)) { - apk_hash_foreach(&db->available.names, warn_if_no_providers, &counts); + apk_print_indented_init(&counts.indent, 1); + apk_db_foreach_sorted_name(db, NULL, warn_if_no_providers, &counts); + apk_print_indented_end(&counts.indent); } if (counts.unsatisfied != 0) |