diff options
author | Timo Teräs <timo.teras@iki.fi> | 2011-06-28 15:40:52 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2011-06-28 15:40:52 +0300 |
commit | 433da92e374d8924abda3b78b6652971870b9697 (patch) | |
tree | cf834bbab98f83fd3c98ea17937368e74c22b173 /src/index.c | |
parent | 95555ede4d732878d576415e5d338b0104b78ad6 (diff) | |
download | apk-tools-433da92e374d8924abda3b78b6652971870b9697.tar.gz apk-tools-433da92e374d8924abda3b78b6652971870b9697.tar.bz2 apk-tools-433da92e374d8924abda3b78b6652971870b9697.tar.xz apk-tools-433da92e374d8924abda3b78b6652971870b9697.zip |
index: handle errors instead of silently failing
Make indexer keep noise about errors that prevent index generation.
Detect certain errors in the APKs better. And also have the applet
return error in these scenarios.
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c index 442e98a..f3f6992 100644 --- a/src/index.c +++ b/src/index.c @@ -90,7 +90,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) struct counts counts = {0}; struct apk_ostream *os; struct apk_file_info fi; - int total, r, i, j, found, newpkgs = 0; + int total, r, i, j, found, newpkgs = 0, errors = 0; struct index_ctx *ictx = (struct index_ctx *) ctx; struct apk_package *pkg; @@ -160,13 +160,20 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) if (!found) { struct apk_sign_ctx sctx; apk_sign_ctx_init(&sctx, ictx->method, NULL, db->keys_fd); - if (apk_pkg_read(db, argv[i], &sctx, &pkg) == 0) + r = apk_pkg_read(db, argv[i], &sctx, &pkg); + if (r < 0) { + apk_error("%s: %s", argv[i], apk_error_str(r)); + errors++; + } else { newpkgs++; + } if (ictx->rewrite_arch != NULL) pkg->arch = ictx->rewrite_arch; apk_sign_ctx_free(&sctx); } } + if (errors) + return -1; if (ictx->output != NULL) os = apk_ostream_to_file(AT_FDCWD, ictx->output, NULL, 0644); @@ -202,6 +209,11 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) } os->close(os); + if (total < 0) { + apk_error("Index generation failed: %s", apk_error_str(r)); + return total; + } + apk_hash_foreach(&db->available.names, warn_if_no_providers, &counts); if (counts.unsatisfied != 0) |