diff options
Diffstat (limited to 'src/hooks.c')
| -rw-r--r-- | src/hooks.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/hooks.c b/src/hooks.c index 6053575..81c3fc5 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -163,25 +163,30 @@ bool bldit_file_exists(package_t *pkg) { bool bldit_hook_set(package_t *pkg) { if (luaL_loadfile(L, pkg->bldit.data) || lua_pcall(L, 0, 1, 0)) { - log_warn("bldit brokie"); + log_warn( + "%.*s is broken: %s", + str_fmt(&pkg->bldit), + lua_tostring(L, -1) + ); lua_pop(L, 1); return false; } + if (!lua_istable(L, -1)) { + log_error("%.*s does not return a table", str_fmt(&pkg->bldit)); + lua_pop(L, 1); + lua_close(L); + return false; + } lua_setglobal(L, "__pkgit_bldit_config"); lua_pop(L, 1); return true; } bool bldit_hook_recipe(package_t *pkg, const char *recipe) { -// luaL_dofile(L, pkg->bldit.data); -// lua_setglobal(L, "__pkgit_bldit_config"); lua_getglobal(L, "__pkgit_bldit_config"); - printf("\n%s\n\n", lua_tostring(L, -1)); - log_info("entered bldit config"); + //printf("\n%s\n\n", lua_tostring(L, -1)); lua_get_field_type("recipe", table, &pkg->bldit, 2); - log_info("entered bldit recipe"); - lua_get_field_type(recipe, table, &pkg->bldit, 3); - log_info("entered bldit recipe function: %s", recipe); + lua_get_field_type(recipe, function, &pkg->bldit, 3); lua_run_function(recipe, &pkg->bldit, 0, 1, 3); if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) { lua_pop(L, 3); |
