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);
|
r = chown(fn, ae->uid, ae->gid);
|
||||||
else
|
else
|
||||||
r = lchown(fn, ae->uid, ae->gid);
|
r = lchown(fn, ae->uid, ae->gid);
|
||||||
|
if (r < 0)
|
||||||
|
apk_error("Failed to set ownership on %s: %s", fn,
|
||||||
|
strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
apk_error("Failed to extract %s\n", ae->name);
|
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);
|
fchdir(db->root_fd);
|
||||||
|
|
||||||
fd = open("var/lib/apk/world", O_RDONLY);
|
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;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fstat(fd, &st);
|
fstat(fd, &st);
|
||||||
buf = malloc(st.st_size);
|
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 = strdup(root);
|
||||||
db->root_fd = open(root, O_RDONLY);
|
db->root_fd = open(root, O_RDONLY);
|
||||||
if (db->root_fd < 0) {
|
if (db->root_fd < 0) {
|
||||||
|
apk_error("%s: %s", root, strerror(errno));
|
||||||
free(db->root);
|
free(db->root);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -791,8 +794,10 @@ int apk_db_install_pkg(struct apk_database *db,
|
||||||
db->repos[0].url, newpkg->name->name, newpkg->version);
|
db->repos[0].url, newpkg->name->name, newpkg->version);
|
||||||
|
|
||||||
fd = open(file, O_RDONLY);
|
fd = open(file, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
|
apk_error("%s: %s", file, strerror(errno));
|
||||||
return errno;
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -354,9 +355,11 @@ int apk_pkg_run_script(struct apk_package *pkg, int root_fd,
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
chroot(".");
|
if (chroot(".") < 0) {
|
||||||
execle(fn, script_types[script->type],
|
apk_error("chroot: %s", strerror(errno));
|
||||||
pkg->version, "", NULL, environment);
|
} else
|
||||||
|
execle(fn, script_types[script->type],
|
||||||
|
pkg->version, "", NULL, environment);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
Loading…
Reference in New Issue