summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-23 11:35:40 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-23 11:35:40 +0300
commita388f4bfa6e92a06d95de576aee94f2ae5695cfe (patch)
treea9c6266888ab79be0c49715efabec769802816fa
parent90aaa28a95f28206e6bf4ed0d5a798595165cb8c (diff)
downloadapk-tools-a388f4bfa6e92a06d95de576aee94f2ae5695cfe.tar.gz
apk-tools-a388f4bfa6e92a06d95de576aee94f2ae5695cfe.tar.bz2
apk-tools-a388f4bfa6e92a06d95de576aee94f2ae5695cfe.tar.xz
apk-tools-a388f4bfa6e92a06d95de576aee94f2ae5695cfe.zip
index: more informative error message
when failed to load an existing index.
-rw-r--r--src/apk.c2
-rw-r--r--src/database.c14
-rw-r--r--src/index.c8
-rw-r--r--src/package.c2
4 files changed, 16 insertions, 10 deletions
diff --git a/src/apk.c b/src/apk.c
index 89dd53d..1783eea 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -67,6 +67,8 @@ const char *apk_error_str(int error)
return "IO ERROR";
case EBADMSG:
return "BAD archive";
+ case ENOMSG:
+ return "archive does not contain expected data";
default:
return strerror(error);
}
diff --git a/src/database.c b/src/database.c
index 719a445..076f72f 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1165,12 +1165,14 @@ static int load_apkindex(void *sctx, const struct apk_file_info *fi,
apk_db_index_read(ctx->db, bs, ctx->repo);
bs->close(bs, NULL);
- return 0;
+ return -ECANCELED;
}
static int load_index(struct apk_database *db, struct apk_bstream *bs,
int targz, int repo)
{
+ int r = 0;
+
if (targz) {
struct apk_istream *is;
struct apkindex_ctx ctx;
@@ -1179,17 +1181,19 @@ static int load_index(struct apk_database *db, struct apk_bstream *bs,
ctx.repo = repo;
apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY, NULL);
is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx);
- apk_tar_parse(is, load_apkindex, &ctx);
+ r = apk_tar_parse(is, load_apkindex, &ctx);
is->close(is);
apk_sign_ctx_free(&ctx.sctx);
- if (!ctx.sctx.data_verified)
- return -1;
+ if (r == 0)
+ r = -ENOMSG;
+ else if (r == -ECANCELED)
+ r = 0;
} else {
bs = apk_bstream_from_istream(apk_bstream_gunzip(bs));
apk_db_index_read(db, bs, repo);
bs->close(bs, NULL);
}
- return 0;
+ return r;
}
int apk_db_index_read_file(struct apk_database *db, const char *file, int repo)
diff --git a/src/index.c b/src/index.c
index cd0c0b5..c27d020 100644
--- a/src/index.c
+++ b/src/index.c
@@ -86,7 +86,7 @@ static int index_main(void *ctx, int argc, char **argv)
struct counts counts = {0};
struct apk_ostream *os;
struct apk_file_info fi;
- int total, i, j, found, newpkgs = 0;
+ int total, r, i, j, found, newpkgs = 0;
struct index_ctx *ictx = (struct index_ctx *) ctx;
if (isatty(STDOUT_FILENO) && ictx->output == NULL &&
@@ -100,10 +100,10 @@ static int index_main(void *ctx, int argc, char **argv)
ictx->method = APK_SIGN_GENERATE;
apk_db_open(&db, NULL, APK_OPENF_READ);
- if (index_read_file(&db, ictx) < 0) {
+ if ((r = index_read_file(&db, ictx)) < 0) {
apk_db_close(&db);
- apk_error("The index is corrupt, or of unknown format.");
- return -1;
+ apk_error("%s: %s", ictx->index, apk_error_str(r));
+ return r;
}
for (i = 0; i < argc; i++) {
diff --git a/src/package.c b/src/package.c
index 1c9ff3d..1d2e50a 100644
--- a/src/package.c
+++ b/src/package.c
@@ -723,7 +723,7 @@ int apk_pkg_read(struct apk_database *db, const char *file,
if (r < 0 && r != -ECANCELED)
goto err;
if (ctx.pkg->name == NULL) {
- r = -EBADMSG;
+ r = -ENOMSG;
goto err;
}
if (sctx->action != APK_SIGN_VERIFY)