Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
lua: hook the new lua_exec and load all functions in triggers
Baptiste Daroussin committed 5 years ago
commit 895c9f7fa4bfa7f80f9fd830a4702f627e540926
parent 76bb3c5
2 files changed +12 -0
modified libpkg/lua_scripts.c
@@ -90,6 +90,7 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
				{ "filecmp", lua_pkg_filecmp },
				{ "copy", lua_pkg_copy },
				{ "stat", lua_stat },
+
				{ "exec", lua_exec },
				{ NULL, NULL },
			};
			close(cur_pipe[0]);
modified libpkg/triggers.c
@@ -381,6 +381,17 @@ trigger_execute_lua(const char *script, kh_strings_t *args)
		L = luaL_newstate();
		luaL_openlibs(L);
		lua_override_ios(L, false);
+
		static const luaL_Reg pkg_lib[] = {
+
			{ "print_msg", lua_print_msg },
+
			{ "prefixed_path", lua_prefix_path },
+
			{ "filecmp", lua_pkg_filecmp },
+
			{ "copy", lua_pkg_copy },
+
			{ "stat", lua_stat },
+
			{ "exec", lua_exec },
+
			{ NULL, NULL },
+
		};
+
		luaL_newlib(L, pkg_lib);
+
		lua_setglobal(L, "pkg");
		char *dir;
		char **arguments = NULL;
		int i = 0;