package: remove package script after use (fixes #7974)

this is a regression introduced in commit 349c61c9
("add support for pre and post commit hooks")
cute-signatures
Timo Teräs 2017-10-04 16:56:07 +03:00
parent 806a476190
commit 8f0938a056
1 changed files with 9 additions and 6 deletions

View File

@ -1018,21 +1018,24 @@ void apk_ipkg_run_script(struct apk_installed_package *ipkg,
if (fd < 0) {
mkdirat(root_fd, "var/cache/misc", 0755);
fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0755);
if (fd < 0)
goto error;
if (fd < 0) goto err_log;
}
if (write(fd, ipkg->script[type].ptr, ipkg->script[type].len) < 0) {
close(fd);
goto error;
goto err_log;
}
close(fd);
if (apk_db_run_script(db, fn, argv) < 0)
ipkg->broken_script = 1;
return;
error:
goto err;
goto cleanup;
err_log:
apk_error("%s: failed to execute: %s", &fn[15], apk_error_str(errno));
err:
ipkg->broken_script = 1;
cleanup:
unlinkat(root_fd, fn, 0);
}
static int parse_index_line(void *ctx, apk_blob_t line)