Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ignore failed pre-install/post-install scripts/lua files in pkg-register(8) (#2073) #2111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libpkg/pkg_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,10 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
if (retcode != EPKG_OK)
goto cleanup;
if ((flags & PKG_ADD_NOSCRIPT) == 0) {
pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, (local != NULL));
pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, (local != NULL));
if ((retcode = pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, (local != NULL))) != EPKG_OK)
goto cleanup;
if ((retcode = pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, (local != NULL))) != EPKG_OK)
goto cleanup;
}

/*
Expand Down
12 changes: 8 additions & 4 deletions libpkg/pkg_ports.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,10 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,

if (!testing) {
/* Execute pre-install scripts */
pkg_lua_script_run(pkg, PKG_LUA_PRE_INSTALL, false);
pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL, false);
if ((rc = pkg_lua_script_run(pkg, PKG_LUA_PRE_INSTALL, false)) != EPKG_OK)
goto cleanup;
if ((rc = pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL, false)) != EPKG_OK)
goto cleanup;

if (input_path != NULL) {
pkg_register_cleanup_callback(pkg_rollback_cb, pkg);
Expand All @@ -1229,8 +1231,10 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,
}

/* Execute post-install scripts */
pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, false);
pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false);
if ((rc = pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, false)) != EPKG_OK)
goto cleanup;
if ((rc = pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false)) != EPKG_OK)
goto cleanup;
}

if (rc == EPKG_OK) {
Expand Down
6 changes: 3 additions & 3 deletions tests/frontend/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tests_init \
metalog \
reinstall \
pre_script_fail \
post_script_ignored \
post_script_fail \
install_missing_dep

test_setup()
Expand Down Expand Up @@ -150,7 +150,7 @@ EOF
pkg -o REPOS_DIR="/dev/null" install -y ${TMPDIR}/test-1.pkg
}

post_script_ignored_body()
post_script_fail_body()
{
atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg test test 1
cat << EOF >> test.ucl
Expand All @@ -167,7 +167,7 @@ EOF

atf_check -o ignore \
-e inline:"${PROGNAME}: POST-INSTALL script failed\n" \
-s exit:0 \
-s exit:3 \
pkg -o REPOS_DIR="/dev/null" install -y ${TMPDIR}/test-1.pkg
}

Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/lua.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pkg: lua script failed\n"
mkdir -p ${TMPDIR}/target
atf_check \
-e inline:"${ERR}" \
-s exit:0 \
-s exit:3 \
pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.pkg
}

Expand Down