From: Panu Matilainen Date: Mon, 14 Apr 2008 11:31:51 +0000 (+0300) Subject: Streamline lua scriptlet name formatting - just do it once X-Git-Tag: tznext/4.11.0.1.tizen20130304~4408 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=647ff16b50dab2172d25b62dedb7db15a38811ea;p=tools%2Flibrpm-tizen.git Streamline lua scriptlet name formatting - just do it once --- diff --git a/lib/psm.c b/lib/psm.c index 63987c5..35feead 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -503,17 +503,20 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, const char *script, int arg1, int arg2) { const rpmts ts = psm->ts; - const char * sln = tag2sln(stag); + char *nevra, *sname = NULL; int rootFd = -1; - const char *n, *v, *r; rpmRC rc = RPMRC_OK; int i; int xx; rpmlua lua = NULL; /* Global state. */ rpmluav var; - xx = headerNVR(h, &n, &v, &r); + nevra = headerGetNEVRA(h, NULL); + rasprintf(&sname, "%s(%s)", tag2sln(stag), nevra); + free(nevra); + rpmlog(RPMLOG_DEBUG, "%s: %s running scriptlet.\n", + psm->stepName, sname); if (!rpmtsChrootDone(ts)) { const char *rootDir = rpmtsRootDir(ts); xx = chdir("/"); @@ -547,14 +550,11 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, rpmluaPop(lua); { - char *buf = NULL; - rasprintf(&buf, "%s(%s-%s-%s)", sln, n, v, r); - if (rpmluaRunScript(lua, script, buf) == -1) { + if (rpmluaRunScript(lua, script, sname) == -1) { void * ptr; ptr = rpmtsNotify(ts, psm->te, RPMCALLBACK_SCRIPT_ERROR, stag, 1); rc = RPMRC_FAIL; } - free(buf); } rpmluaDelVar(lua, "arg"); @@ -567,6 +567,7 @@ static rpmRC runLuaScript(rpmpsm psm, Header h, rpmTag stag, xx = chroot("."); xx = rpmtsSetChrootDone(ts, 0); } + free(sname); return rc; } @@ -628,9 +629,6 @@ static rpmRC runScript(rpmpsm psm, Header h, rpmTag stag, if (progArgv && strcmp(progArgv[0], "") == 0) { #ifdef WITH_LUA - rpmlog(RPMLOG_DEBUG, - "%s: %s(%s-%s-%s.%s) running scriptlet.\n", - psm->stepName, sln, n, v, r, a); return runLuaScript(psm, h, stag, progArgc, progArgv, script, arg1, arg2); #else