summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-22 14:56:27 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-22 14:56:27 +0300
commit93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8 (patch)
tree84261f2a088ff9bf53a6db30669602f159a01b00 /src/package.c
parent0a7991f70dcfe9f8e05f6a4a4a59af21be878915 (diff)
downloadapk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.gz
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.bz2
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.xz
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.zip
various: more informative error messages
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/package.c b/src/package.c
index 5bf4478..e480c6f 100644
--- a/src/package.c
+++ b/src/package.c
@@ -693,8 +693,8 @@ static int read_info_entry(void *ctx, const struct apk_file_info *ae,
return 0;
}
-struct apk_package *apk_pkg_read(struct apk_database *db, const char *file,
- struct apk_sign_ctx *sctx)
+int apk_pkg_read(struct apk_database *db, const char *file,
+ struct apk_sign_ctx *sctx, struct apk_package **pkg)
{
struct read_info_ctx ctx;
struct apk_file_info fi;
@@ -704,16 +704,17 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file,
int r;
if (realpath(file, realfile) < 0)
- return NULL;
- if (apk_file_get_info(realfile, APK_CHECKSUM_NONE, &fi) < 0)
- return NULL;
+ return -errno;
+ r = apk_file_get_info(realfile, APK_CHECKSUM_NONE, &fi);
+ if (r != 0)
+ return r;
memset(&ctx, 0, sizeof(ctx));
ctx.sctx = sctx;
ctx.pkg = apk_pkg_new();
+ r = -ENOMEM;
if (ctx.pkg == NULL)
- return NULL;
-
+ goto err;
bs = apk_bstream_from_file(realfile);
if (bs == NULL)
goto err;
@@ -727,11 +728,10 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file,
tar->close(tar);
if (r < 0 && r != -ECANCELED)
goto err;
- if (ctx.pkg->name == NULL)
- goto err;
- if (sctx->action == APK_SIGN_VERIFY && !sctx->data_verified &&
- !(apk_flags & APK_FORCE))
+ if (ctx.pkg->name == NULL) {
+ r = -EBADMSG;
goto err;
+ }
if (sctx->action != APK_SIGN_VERIFY)
ctx.pkg->csum = sctx->identity;
@@ -744,10 +744,13 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file,
}
ctx.pkg->filename = strdup(realfile);
- return apk_db_pkg_add(db, ctx.pkg);
+ ctx.pkg = apk_db_pkg_add(db, ctx.pkg);
+ if (pkg != NULL)
+ *pkg = ctx.pkg;
+ r = 0;
err:
apk_pkg_free(ctx.pkg);
- return NULL;
+ return r;
}
void apk_pkg_free(struct apk_package *pkg)