summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-09-16 15:36:43 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-11 17:48:03 +0300
commiteab57121d92d3deb03cde80fc4f986ab4a19cf14 (patch)
treea189fff44bb246d1c71a22e1f06e309e9a5c1e13
parente3307250cef5efb0c7f27f4bd7451a4bb294adfa (diff)
downloadlibrpm-tizen-eab57121d92d3deb03cde80fc4f986ab4a19cf14.tar.gz
librpm-tizen-eab57121d92d3deb03cde80fc4f986ab4a19cf14.tar.bz2
librpm-tizen-eab57121d92d3deb03cde80fc4f986ab4a19cf14.zip
lua: fall through failed lua scripts
Just print a warning. In addition, set Lua output buffer to contain string "1" for failed scripts. Change-Id: Id0478b64ac942fe6839f3cd8c9bb75c9b15382b2 Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--rpmio/macro.c12
-rw-r--r--rpmio/rpmlua.c2
2 files changed, 10 insertions, 4 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 0876ea88e..c1bb04334 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -1233,6 +1233,7 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
}
#ifdef WITH_LUA
+#define LUA_FAILURE_OUTPUT "1"
if (STREQ("lua", f, fn)) {
rpmlua lua = NULL; /* Global state. */
const char *ls = s+sizeof("{lua:")-1;
@@ -1242,9 +1243,14 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
memcpy(scriptbuf, ls, lse-ls);
scriptbuf[lse-ls] = '\0';
rpmluaPushPrintBuffer(lua);
- if (rpmluaRunScript(lua, scriptbuf, NULL) == -1)
- rc = 1;
- printbuf = rpmluaPopPrintBuffer(lua);
+ if (rpmluaRunScript(lua, scriptbuf, NULL) == -1) {
+ printbuf = rpmluaPopPrintBuffer(lua);
+ rpmlog(RPMLOG_WARNING, _("lua: using fallback output '%s'\n"), LUA_FAILURE_OUTPUT);
+ printbuf = (char *)xcalloc(1, sizeof(LUA_FAILURE_OUTPUT));
+ strcpy(printbuf, LUA_FAILURE_OUTPUT);
+ } else {
+ printbuf = rpmluaPopPrintBuffer(lua);
+ }
if (printbuf) {
mbAppendStr(mb, printbuf);
free(printbuf);
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index 8e6841d4e..53c0cf908 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -530,7 +530,7 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
lua_pop(L, 1);
ret = -1;
} else if (lua_pcall(L, 0, 0, 0) != 0) {
- rpmlog(RPMLOG_ERR, _("lua script failed: %s\n"),
+ rpmlog(RPMLOG_WARNING, _("lua script failed: %s\n"),
lua_tostring(L, -1));
lua_pop(L, 1);
ret = -1;