RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [email protected] Module: rpm Date: 08-Apr-2009 20:13:05 Branch: HEAD Handle: 2009040818130401 Modified files: rpm CHANGES rpm/build parseScript.c rpm/lib psm.c rpmds.c rpm/rpmio macro.c Log: - ruby: wire-up %post -p <ruby>. arg1/arg2, persistent interp, todo++. - ruby: wire-up %{ruby:...}. the string result is bogus, todo++. Summary: Revision Changes Path 1.2911 +2 -0 rpm/CHANGES 2.70 +6 -0 rpm/build/parseScript.c 2.358 +16 -3 rpm/lib/psm.c 2.147 +5 -0 rpm/lib/rpmds.c 2.220 +38 -1 rpm/rpmio/macro.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2910 -r1.2911 CHANGES --- rpm/CHANGES 8 Apr 2009 17:31:55 -0000 1.2910 +++ rpm/CHANGES 8 Apr 2009 18:13:04 -0000 1.2911 @@ -1,5 +1,7 @@ 5.2a3 -> 5.2a4: + - jbj: ruby: wire-up %post -p <ruby>. arg1/arg2, persistent interp, todo++. + - jbj: ruby: wire-up %{ruby:...}. the string result is bogus, todo++. - jbj: ruby: add --with-ruby for embedding ruby. - jbj: yarn: convert rpmluav to usage mutex with refcounts - jbj: yarn: convert rpmlua to usage mutex with refcounts @@ . patch -p0 <<'@@ .' Index: rpm/build/parseScript.c ============================================================================ $ cvs diff -u -r2.69 -r2.70 parseScript.c --- rpm/build/parseScript.c 7 Apr 2009 23:32:59 -0000 2.69 +++ rpm/build/parseScript.c 8 Apr 2009 18:13:04 -0000 2.70 @@ -325,6 +325,12 @@ "BuiltinPythonScripts", "5.2-1"); } else #endif +#ifdef WITH_RUBY + if (!strcmp(progArgv[0], "<ruby>")) { + (void) rpmlibNeedsFeature(pkg->header, + "BuiltinRubyScripts", "5.2-1"); + } else +#endif #ifdef WITH_TCL if (!strcmp(progArgv[0], "<tcl>")) { (void) rpmlibNeedsFeature(pkg->header, @@ . patch -p0 <<'@@ .' Index: rpm/lib/psm.c ============================================================================ $ cvs diff -u -r2.357 -r2.358 psm.c --- rpm/lib/psm.c 7 Apr 2009 23:32:59 -0000 2.357 +++ rpm/lib/psm.c 8 Apr 2009 18:13:05 -0000 2.358 @@ -14,6 +14,7 @@ #include <rpmlua.h> #include <rpmperl.h> #include <rpmpython.h> +#include <rpmruby.h> #include <rpmtcl.h> #include <rpmtag.h> #include <rpmtypes.h> @@ -557,7 +558,7 @@ } #endif /* WITH_LUA */ -#if defined(WITH_LUA) || defined(WITH_TCL) || defined(WITH_PERL) +#if defined(WITH_LUA) || defined(WITH_TCL) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBY) static int enterChroot(rpmpsm psm, int * fdnop) /*...@globals fileSystem, internalState @*/ /*...@modifies *fdnop, fileSystem, internalState @*/ @@ -667,6 +668,17 @@ python = rpmpythonFree(python); } else #endif +#if defined(WITH_RUBY) + if (!strcmp(Phe->p.argv[0], "<ruby>")) { + rpmruby ruby = rpmrubyNew(NULL, 0); + /* XXX TODO: wire up arg1 and arg2, handle other args too. */ + if (rpmrubyRun(ruby, script, NULL) == RPMRC_OK) + rc = RPMRC_OK; + else + rc = RPMRC_FAIL; + ruby = rpmrubyFree(ruby); + } else +#endif #if defined(WITH_TCL) if (!strcmp(Phe->p.argv[0], "<tcl>")) { rpmtcl tcl = rpmtclNew(NULL, 0); @@ -690,7 +702,7 @@ return rc; } -#endif /* defined(WITH_LUA) || defined(WITH_TCL) */ +#endif /** */ @@ -767,9 +779,10 @@ if (!strcmp(Phe->p.argv[0], "<lua>") || !strcmp(Phe->p.argv[0], "<perl>") || !strcmp(Phe->p.argv[0], "<python>") + || !strcmp(Phe->p.argv[0], "<ruby>") || !strcmp(Phe->p.argv[0], "<tcl>")) { -#if defined(WITH_LUA) || defined(WITH_TCL) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) +#if defined(WITH_LUA) || defined(WITH_TCL) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBY) rpmlog(RPMLOG_DEBUG, D_("%s: %s(%s) running %s scriptlet.\n"), psm->stepName, tag2sln(psm->scriptTag), NVRA, Phe->p.argv[0]); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.c ============================================================================ $ cvs diff -u -r2.146 -r2.147 rpmds.c --- rpm/lib/rpmds.c 7 Apr 2009 23:32:59 -0000 2.146 +++ rpm/lib/rpmds.c 8 Apr 2009 18:13:05 -0000 2.147 @@ -1484,6 +1484,11 @@ ( RPMSENSE_EQUAL), N_("internal embedded python scripts.") }, #endif +#if defined(WITH_RUBY) + { "rpmlib(BuiltinRubyScripts)", "5.2-1", + ( RPMSENSE_EQUAL), + N_("internal embedded ruby scripts.") }, +#endif #if defined(WITH_TCL) { "rpmlib(BuiltinTclScripts)", "5.2-1", ( RPMSENSE_EQUAL), @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.219 -r2.220 macro.c --- rpm/rpmio/macro.c 7 Apr 2009 23:33:00 -0000 2.219 +++ rpm/rpmio/macro.c 8 Apr 2009 18:13:05 -0000 2.220 @@ -78,6 +78,10 @@ #include <rpmpython.h> #endif +#ifdef WITH_RUBY +#include <rpmruby.h> +#endif + #ifdef WITH_TCL #include <rpmtcl.h> #endif @@ -1735,13 +1739,16 @@ scriptbuf[lse-ls] = '\0'; if (rpmperlRun(perl, scriptbuf, &result) != RPMRC_OK) rc = 1; - else if (result != NULL && *result != '\0') { + else { + if (result == NULL) result = "FIXME"; + if (result != NULL && *result != '\0') { size_t len = strlen(result); if (len > mb->nb) len = mb->nb; memcpy(mb->t, result, len); mb->t += len; mb->nb -= len; + } } scriptbuf = _free(scriptbuf); perl = rpmperlFree(perl); @@ -1780,6 +1787,36 @@ } #endif +#ifdef WITH_RUBY + if (STREQ("ruby", f, fn)) { + rpmruby ruby = rpmrubyNew(NULL, 0); + const char *ls = s+sizeof("{ruby:")-1; + const char *lse = se-sizeof("}")+1; + char *scriptbuf = (char *)xmalloc((lse-ls)+1); + const char * result = NULL; + + memcpy(scriptbuf, ls, lse-ls); + scriptbuf[lse-ls] = '\0'; + if (rpmrubyRun(ruby, scriptbuf, &result) != RPMRC_OK) + rc = 1; + else { + if (result == NULL) result = "FIXME"; + if (result != NULL && *result != '\0') { + size_t len = strlen(result); + if (len > mb->nb) + len = mb->nb; + memcpy(mb->t, result, len); + mb->t += len; + mb->nb -= len; + } + } + scriptbuf = _free(scriptbuf); + ruby = rpmrubyFree(ruby); + s = se; + continue; + } +#endif + #ifdef WITH_TCL if (STREQ("tcl", f, fn)) { rpmtcl tcl = rpmtclNew(NULL, 0); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository [email protected]
