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

pkg-register ignores failed pre-install/post-install scripts #2073

Open
jhgit opened this issue Sep 12, 2022 · 2 comments · May be fixed by #2111
Open

pkg-register ignores failed pre-install/post-install scripts #2073

jhgit opened this issue Sep 12, 2022 · 2 comments · May be fixed by #2111

Comments

@jhgit
Copy link

jhgit commented Sep 12, 2022

If the pre-install or post-install script for a package fails, pkg register ignores the failure. pkg add dies as I would expect.

Looking in like libpkg/pkg_ports:pkg_add_port(), indeed the functions that are invoked to run the scripts (e.g., pkg_lua_script_run, pkg_script_run) do ignore the return code, whereas libpkg/pkg_add.c:pkg_add_common() checks the script return code.

See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206951

@michael-o
Copy link
Contributor

michael-o commented Mar 1, 2023

@michael-o
Copy link
Contributor

Here are the problems:

root@deblndw013x3j:/usr/ports/ports-mgmt/pkg/work/pkg-1.19.0
# grep -r -e "pkg, PKG_SCRIPT_POST_INSTALL" -e "pkg, PKG_SCRIPT_PRE_INSTALL"  .
./libpkg/pkg_add.c:             pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, (local != NULL));
./libpkg/pkg_ports.c:           pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL, false);
./libpkg/pkg_ports.c:           pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false);

They just ignore the return code.

Boils down to:

pkg/libpkg/pkg_add.c

Lines 1359 to 1362 in 6c55d7b

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));
}

pkg/libpkg/pkg_ports.c

Lines 1215 to 1234 in 6c55d7b

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 (input_path != NULL) {
pkg_register_cleanup_callback(pkg_rollback_cb, pkg);
rc = pkg_add_fromdir(pkg, input_path);
pkg_unregister_cleanup_callback(pkg_rollback_cb, pkg);
if (rc != EPKG_OK) {
pkg_rollback_pkg(pkg);
if (db != NULL)
pkg_delete_dirs(db, pkg, NULL);
}
}
/* Execute post-install scripts */
pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, false);
pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false);
}

michael-o added a commit to michael-o/pkg that referenced this issue Mar 1, 2023
…#2073)

When a package is registered through pkg-register(8) the return codes of
pre-install and post-install scripts and lua files  are ignored. Now they are
respected as with pkg-add(8).

This fixes freebsd#2073
michael-o added a commit to michael-o/pkg that referenced this issue Mar 1, 2023
…-register(8) (freebsd#2073)

When a package is registered through pkg-register(8) the return codes of
pre-install and post-install scripts and lua files  are ignored. Now they are
respected as with pkg-add(8).

This fixes freebsd#2073
michael-o added a commit to michael-o/pkg that referenced this issue Mar 1, 2023
…-register(8) (freebsd#2073)

When a package is registered through pkg-register(8) the return codes of
pre-install and post-install scripts and lua files  are ignored. Now they are
respected as with pkg-add(8).

This fixes freebsd#2073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants