Skip to content

Commit

Permalink
Don't ignore failed pre-install/post-install scripts/lua files in pkg…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
michael-o committed Mar 1, 2023
1 parent 6c55d7b commit b14da2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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

0 comments on commit b14da2a

Please sign in to comment.