diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2008-10-26 11:35:34 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2008-10-26 11:35:34 +0000 |
commit | cb25f35ed4db520b12ecd301c040a2202d91efbd (patch) | |
tree | 6738ad168bfffe004eb1e4dc9b72db36393e3435 | |
parent | 219a1b2ee8f4c3c2caf57e79bcb9780e32da7155 (diff) | |
download | apk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.tar.bz2 apk-tools-cb25f35ed4db520b12ecd301c040a2202d91efbd.tar.xz |
give more helpful error messages
-rw-r--r-- | src/archive.c | 3 | ||||
-rw-r--r-- | src/database.c | 9 | ||||
-rw-r--r-- | src/package.c | 9 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/archive.c b/src/archive.c index 18031a0..6de998b 100644 --- a/src/archive.c +++ b/src/archive.c @@ -276,6 +276,9 @@ int apk_archive_entry_extract(struct apk_archive_entry *ae, const char *fn) r = chown(fn, ae->uid, ae->gid); else r = lchown(fn, ae->uid, ae->gid); + if (r < 0) + apk_error("Failed to set ownership on %s: %s", fn, + strerror(errno)); } else { apk_error("Failed to extract %s\n", ae->name); } 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); diff --git a/src/package.c b/src/package.c index 5cde906..2f14c80 100644 --- a/src/package.c +++ b/src/package.c @@ -9,6 +9,7 @@ * by the Free Software Foundation. See http://www.gnu.org/ for details. */ +#include <errno.h> #include <fcntl.h> #include <ctype.h> #include <stdio.h> @@ -354,9 +355,11 @@ int apk_pkg_run_script(struct apk_package *pkg, int root_fd, if (pid == -1) return -1; if (pid == 0) { - chroot("."); - execle(fn, script_types[script->type], - pkg->version, "", NULL, environment); + if (chroot(".") < 0) { + apk_error("chroot: %s", strerror(errno)); + } else + execle(fn, script_types[script->type], + pkg->version, "", NULL, environment); exit(1); } waitpid(pid, &status, 0); |