summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2008-10-26 11:35:34 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2008-10-26 11:35:34 +0000
commitcb25f35ed4db520b12ecd301c040a2202d91efbd (patch)
tree6738ad168bfffe004eb1e4dc9b72db36393e3435 /src/database.c
parent219a1b2ee8f4c3c2caf57e79bcb9780e32da7155 (diff)
downloadapk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.tar.gz
apk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.tar.bz2
apk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.tar.xz
apk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.zip
give more helpful error messages
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c
index 8da8d6f..eed584e 100644
--- a/src/database.c
+++ b/src/database.c
@@ -434,8 +434,10 @@ static int apk_db_read_config(struct apk_database *db)
fchdir(db->root_fd);
fd = open("var/lib/apk/world", O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ apk_error("Please run 'apk create' to initialize root");
return -1;
+ }
fstat(fd, &st);
buf = malloc(st.st_size);
@@ -470,6 +472,7 @@ int apk_db_open(struct apk_database *db, const char *root)
db->root = strdup(root);
db->root_fd = open(root, O_RDONLY);
if (db->root_fd < 0) {
+ apk_error("%s: %s", root, strerror(errno));
free(db->root);
return -1;
}
@@ -791,8 +794,10 @@ int apk_db_install_pkg(struct apk_database *db,
db->repos[0].url, newpkg->name->name, newpkg->version);
fd = open(file, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ apk_error("%s: %s", file, strerror(errno));
return errno;
+ }
fcntl(fd, F_SETFD, FD_CLOEXEC);