From aa85786f999e252de6419087d936c2ff766d8699 Mon Sep 17 00:00:00 2001 From: dacctal Date: Tue, 26 May 2026 00:08:09 +0000 Subject: bldit install functions work now --- src/lua_state.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/lua_state.c b/src/lua_state.c index fe7d94f..3418dde 100644 --- a/src/lua_state.c +++ b/src/lua_state.c @@ -188,7 +188,6 @@ bool bldit(const char *target) { lua_close(B); return false; } - if (lua_pcall(B, 0, 0, 0) != LUA_OK) { printf("build failed: %s\n", lua_tostring(B, -1)); lua_pop(B, 1); @@ -196,9 +195,38 @@ bool bldit(const char *target) { lua_close(B); return false; } + printf("%sbldit function 'build' ran successfully.\n", print_pkgit); + + lua_getfield(B, -1, "pre_install"); + if (!lua_isfunction(B, -1)) { + printf("%s'repositories' lua variable 'pre_install' is not a function.\n", print_warning); + } + if (lua_pcall(B, 0, 0, 0) != LUA_OK) { + printf("build failed: %s\n", lua_tostring(B, -1)); + } + printf("%sbldit function 'pre_install' ran successfully.\n", print_pkgit); + + lua_getfield(B, -1, "install"); + if (!lua_isfunction(B, -1)) { + printf("%s'repositories' lua variable 'install' is not a function.\n", print_warning); + } else { + is_auto_installed = false; + } + if (lua_pcall(B, 0, 0, 0) != LUA_OK) { + printf("build failed: %s\n", lua_tostring(B, -1)); + } + printf("%sbldit function 'install' ran successfully.\n", print_pkgit); + + lua_getfield(B, -1, "post_install"); + if (!lua_isfunction(B, -1)) { + printf("%s'repositories' lua variable 'post_install' is not a function.\n", print_warning); + } + if (lua_pcall(B, 0, 0, 0) != LUA_OK) { + printf("build failed: %s\n", lua_tostring(B, -1)); + } + printf("%sbldit function 'post_install' ran successfully.\n", print_pkgit); lua_pop(B, 2); - printf("%sbldit function 'build' ran successfully.\n", print_pkgit); lua_close(B); return true; } -- cgit v1.2.3