@@ -850,8 +850,7 @@ int main(int argc, char **argv)
}
}
- if (lua_handlers_init())
- printf("\nCustom handlers not found, no error, skipping...\n\n");
+ lua_handlers_init();
if(!get_hw_revision(&swcfg.hw))
printf("Running on %s Revision %s\n", swcfg.hw.boardname, swcfg.hw.revision);
@@ -472,22 +472,24 @@ int lua_handlers_init(void)
{
int ret = -1;
- gL = NULL;
gL = luaL_newstate();
if (gL) {
- printf("Searching for custom Lua handlers :");
/* load standard libraries */
luaL_openlibs(gL);
luaL_requiref( gL, "swupdate", luaopen_swupdate, 1 );
/* try to load lua handlers for the swupdate system */
- ret = luaL_dostring(gL,"require (\"swupdate_handlers\")");
- if(ret != 0)
- {
- TRACE("No lua handler found:\n%s", lua_tostring(gL, -1));
- } else
- printf(" OK\n");
+ if ((ret = luaL_dostring(gL, "require (\"swupdate_handlers\")")) != 0) {
+ INFO("No Lua handler(s) found.");
+ if (luaL_dostring(gL, "return package.path:gsub(';','\\n'):gsub('?','swupdate_handlers')") == 0) {
+ lua_pop(gL, 1);
+ TRACE("Lua handler search path:\n%s", lua_tostring(gL, -1));
+ lua_pop(gL, 1);
+ }
+ } else {
+ INFO("Lua handler(s) found.");
+ }
} else {
- printf ("Unable to register Lua context for callbacks\n");
+ WARN("Unable to register Lua context for callbacks\n");
}
return ret;
@@ -44,7 +44,7 @@ static inline lua_State *lua_parser_init(const char __attribute__ ((__unused__))
static inline int lua_parser_fn(lua_State __attribute__ ((__unused__)) *L,
const char __attribute__ ((__unused__)) *fcn,
struct img_type __attribute__ ((__unused__)) *img) { return -1; }
-#define lua_handlers_init(void) (0)
+#define lua_handlers_init(void) { return 0; }
#endif
Currently, a stack dump is printed on a failed require("swupdate_handlers") which is thereafter clarified as being no error. Make this message more friendly. Only package.path is shown as it's assumed that custom Lua handlers won't be written as a .so. In this case, they may be written as a regular handler in C in the first place. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/swupdate.c | 3 +-- corelib/lua_interface.c | 20 +++++++++++--------- include/lua_util.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-)