summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-04-21 08:17:17 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-04-21 08:17:17 +0000
commit9d22718d1dfd95c335ba6b978aae47c437c97b5d (patch)
treea4352d59117ec80bc232a7c58b83e44c10450054
parent1ae6f9d972456ace0d3e4b099ba1933c93d58e88 (diff)
downloadapk-tools-9d22718d1dfd95c335ba6b978aae47c437c97b5d.tar.gz
apk-tools-9d22718d1dfd95c335ba6b978aae47c437c97b5d.tar.bz2
apk-tools-9d22718d1dfd95c335ba6b978aae47c437c97b5d.tar.xz
apk-tools-9d22718d1dfd95c335ba6b978aae47c437c97b5d.zip
db: improve error reporting
apk_db_add_repository does its own error reporting and does not set errno reliable. This patch also tell which repository it failed to load the index for rather than just say it failed to open "APK_INDEX.gz" which does not tell much.
-rw-r--r--src/database.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/database.c b/src/database.c
index 2af55bf..a9cdae7 100644
--- a/src/database.c
+++ b/src/database.c
@@ -646,7 +646,7 @@ static int apk_db_create(struct apk_database *db)
int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
{
apk_blob_t blob;
- const char *apk_repos = getenv("APK_REPOS"), *msg;
+ const char *apk_repos = getenv("APK_REPOS"), *msg = NULL;
int r;
struct apk_repository_url *repo = NULL;
@@ -719,10 +719,8 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
r = apk_blob_for_each_segment(blob, "\n",
apk_db_add_repository, db);
free(blob.ptr);
- if (r != 0) {
- msg = "Unable to load repositories";
+ if (r != 0)
goto ret_r;
- }
}
}
@@ -740,7 +738,8 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags)
ret_errno:
r = -errno;
ret_r:
- apk_error("%s: %s", msg, strerror(-r));
+ if (msg != NULL)
+ apk_error("%s: %s", msg, strerror(-r));
apk_db_close(db);
fchdir(apk_cwd_fd);
return r;
@@ -1008,7 +1007,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
is = apk_bstream_gunzip(apk_repository_file_open(&db->repos[r], name), 1);
}
if (is == NULL) {
- apk_error("Failed to open index file %s", name);
+ apk_error("Failed to open index for %s", db->repos[r].url);
return -1;
}
apk_db_index_read(db, is, r);