Skip to content

Commit 4d03145

Browse files
committedMar 1, 2023
pkg-register ignores failed pre-install/post-install scripts (#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 #2073
1 parent 6c55d7b commit 4d03145

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed
 

‎libpkg/pkg_add.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,10 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
13571357
if (retcode != EPKG_OK)
13581358
goto cleanup;
13591359
if ((flags & PKG_ADD_NOSCRIPT) == 0) {
1360-
pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, (local != NULL));
1361-
pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, (local != NULL));
1360+
if ((retcode = pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, (local != NULL))) != EPKG_OK)
1361+
goto cleanup;
1362+
if ((retcode = pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, (local != NULL))) != EPKG_OK)
1363+
goto cleanup;
13621364
}
13631365

13641366
/*

‎libpkg/pkg_ports.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,10 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,
12141214

12151215
if (!testing) {
12161216
/* Execute pre-install scripts */
1217-
pkg_lua_script_run(pkg, PKG_LUA_PRE_INSTALL, false);
1218-
pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL, false);
1217+
if ((rc = pkg_lua_script_run(pkg, PKG_LUA_PRE_INSTALL, false)) != EPKG_OK)
1218+
goto cleanup;
1219+
if ((rc = pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL, false)) != EPKG_OK)
1220+
goto cleanup;
12191221

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

12311233
/* Execute post-install scripts */
1232-
pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, false);
1233-
pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false);
1234+
if ((rc = pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL, false)) != EPKG_OK)
1235+
goto cleanup;
1236+
if ((rc = pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL, false)) != EPKG_OK)
1237+
goto cleanup;
12341238
}
12351239

12361240
if (rc == EPKG_OK) {

0 commit comments

Comments
 (0)