give more helpful error messages
parent
219a1b2ee8
commit
cb25f35ed4
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,7 +355,9 @@ int apk_pkg_run_script(struct apk_package *pkg, int root_fd,
|
|||
if (pid == -1)
|
||||
return -1;
|
||||
if (pid == 0) {
|
||||
chroot(".");
|
||||
if (chroot(".") < 0) {
|
||||
apk_error("chroot: %s", strerror(errno));
|
||||
} else
|
||||
execle(fn, script_types[script->type],
|
||||
pkg->version, "", NULL, environment);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue