RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   08-Apr-2009 19:31:56
  Branch: HEAD                             Handle: 2009040817315501

  Added files:
    rpm/rpmio               rpmruby.c rpmruby.h truby.c
  Modified files:
    rpm                     CHANGES configure.ac devtool.conf
    rpm/rpmio               .cvsignore Makefile.am librpmio.vers poptIO.c
                            rpmio.c

  Log:
    - ruby: add --with-ruby for embedding ruby.

  Summary:
    Revision    Changes     Path
    1.2910      +1  -0      rpm/CHANGES
    2.358       +8  -0      rpm/configure.ac
    2.278       +1  -0      rpm/devtool.conf
    1.37        +1  -0      rpm/rpmio/.cvsignore
    1.222       +9  -6      rpm/rpmio/Makefile.am
    2.107       +4  -0      rpm/rpmio/librpmio.vers
    1.41        +6  -0      rpm/rpmio/poptIO.c
    1.185       +4  -0      rpm/rpmio/rpmio.c
    2.1         +108 -0     rpm/rpmio/rpmruby.c
    2.1         +103 -0     rpm/rpmio/rpmruby.h
    2.1         +54 -0      rpm/rpmio/truby.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2909 -r1.2910 CHANGES
  --- rpm/CHANGES       8 Apr 2009 06:09:58 -0000       1.2909
  +++ rpm/CHANGES       8 Apr 2009 17:31:55 -0000       1.2910
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - 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
       - jbj: python: wire-up %post -p <python>. arg1/arg2, persistent interp, 
todo++.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/configure.ac
  ============================================================================
  $ cvs diff -u -r2.357 -r2.358 configure.ac
  --- rpm/configure.ac  7 Apr 2009 22:57:47 -0000       2.357
  +++ rpm/configure.ac  8 Apr 2009 17:31:55 -0000       2.358
  @@ -1256,6 +1256,14 @@
       [
       ], [])
   
  +dnl # Ruby embedding
  +RPM_CHECK_LIB(
  +    [Ruby embedding], [ruby],
  +    [ruby], [ruby_init], [ruby.h],
  +    [no,external:none], [],
  +    [
  +    ], [])
  +
   dnl # Tcl
   RPM_CHECK_LIB(
       [Tcl], [tcl],
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/devtool.conf
  ============================================================================
  $ cvs diff -u -r2.277 -r2.278 devtool.conf
  --- rpm/devtool.conf  7 Apr 2009 22:57:47 -0000       2.277
  +++ rpm/devtool.conf  8 Apr 2009 17:31:55 -0000       2.278
  @@ -96,6 +96,7 @@
           --with-pythonembed=/usr/lib:/usr/include/python \
           --with-perl \
           --with-perlembed=/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE \
  +        --with-ruby=/usr/lib:/usr/lib/ruby/1.8/1386-linux \
           --with-build-extlibdep \
           --with-build-maxextlibdep \
           --enable-build-pic \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/.cvsignore
  ============================================================================
  $ cvs diff -u -r1.36 -r1.37 .cvsignore
  --- rpm/rpmio/.cvsignore      7 Apr 2009 22:57:48 -0000       1.36
  +++ rpm/rpmio/.cvsignore      8 Apr 2009 17:31:56 -0000       1.37
  @@ -48,5 +48,6 @@
   tpython
   tring
   trpmio
  +truby
   tsw
   ttcl
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.221 -r1.222 Makefile.am
  --- rpm/rpmio/Makefile.am     7 Apr 2009 22:57:48 -0000       1.221
  +++ rpm/rpmio/Makefile.am     8 Apr 2009 17:31:56 -0000       1.222
  @@ -18,7 +18,7 @@
        rpmgenbasedir rpmgenpkglist rpmgensrclist rpmgpg \
        rpmpbzip2 rpmpigz rpmtar rpmz \
        tdir tfts tget tglob thkp thtml tinv tkey tmacro tmagic tmire \
  -     tperl tpython tput tpw trpmio tsw ttcl dumpasn1 lookup3
  +     tperl tpython tput tpw trpmio truby tsw ttcl dumpasn1 lookup3
   
   bin_PROGRAMS =
   man_MANS =
  @@ -66,9 +66,9 @@
        salsa10.h salsa20.h tiger.h \
        poptIO.h rpmbc.h rpmbz.h rpmdav.h \
        rpmgc.h rpmhash.h rpmhook.h rpmio_internal.h rpmkeyring.h rpmku.h \
  -     rpmlua.h rpmmg.h rpmnss.h rpmperl.h rpmpython.h rpmsq.h rpmssl.h \
  -     rpmio-stub.h rpmtcl.h rpmurl.h rpmuuid.h rpmxar.h rpmz.h rpmzq.h \
  -     tar.h ugid.h
  +     rpmlua.h rpmmg.h rpmnss.h rpmperl.h rpmpython.h rpmruby.h rpmsq.h \
  +     rpmssl.h rpmtcl.h rpmurl.h rpmuuid.h rpmxar.h rpmz.h rpmzq.h \
  +     tar.h ugid.h rpmio-stub.h
   
   usrlibdir = $(libdir)
   usrlib_LTLIBRARIES = librpmio.la
  @@ -80,8 +80,8 @@
        salsa10.c salsa20.c tiger.c \
        rpmbc.c rpmdav.c rpmgc.c rpmhash.c rpmhook.c rpmio.c rpmiob.c 
rpmio-stub.c \
        rpmkeyring.c rpmku.c rpmlog.c rpmlua.c rpmmalloc.c rpmmg.c rpmnss.c \
  -     rpmperl.c rpmpgp.c rpmpython.c rpmrpc.c rpmsq.c rpmssl.c rpmsw.c 
rpmtcl.c \
  -     rpmuuid.c rpmxar.c rpmzlog.c rpmzq.c \
  +     rpmperl.c rpmpgp.c rpmpython.c rpmrpc.c rpmruby.c rpmsq.c \
  +     rpmssl.c rpmsw.c rpmtcl.c rpmuuid.c rpmxar.c rpmzlog.c rpmzq.c \
        strcasecmp.c strtolocale.c tar.c url.c ugid.c xzdio.c yarn.c
   librpmio_la_LDFLAGS = -release $(LT_CURRENT).$(LT_REVISION)
   if HAVE_LD_VERSION_SCRIPT
  @@ -334,6 +334,9 @@
   trpmio_SOURCES = trpmio.c
   trpmio_LDADD = $(RPMIO_LDADD_COMMON)
   
  +truby_SOURCES = truby.c
  +truby_LDADD = $(RPMIO_LDADD_COMMON)
  +
   tsw_SOURCES = tsw.c
   tsw_LDFLAGS = $(RPMIO_LDADD_COMMON)
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.106 -r2.107 librpmio.vers
  --- rpm/rpmio/librpmio.vers   7 Apr 2009 22:57:48 -0000       2.106
  +++ rpm/rpmio/librpmio.vers   8 Apr 2009 17:31:56 -0000       2.107
  @@ -398,6 +398,10 @@
       rpmpythonNew;
       rpmpythonRun;
       rpmpythonRunFile;
  +    _rpmruby_debug;
  +    rpmrubyNew;
  +    rpmrubyRun;
  +    rpmrubyRunFile;
       _rpmsq_debug;
       rpmsqAction;
       rpmsqCaught;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/poptIO.c
  ============================================================================
  $ cvs diff -u -r1.40 -r1.41 poptIO.c
  --- rpm/rpmio/poptIO.c        8 Apr 2009 06:09:59 -0000       1.40
  +++ rpm/rpmio/poptIO.c        8 Apr 2009 17:31:56 -0000       1.41
  @@ -72,6 +72,8 @@
   /*...@unchecked@*/
   extern int _rpmpython_debug;
   /*...@unchecked@*/
  +extern int _rpmruby_debug;
  +/*...@unchecked@*/
   extern int _rpmsq_debug;
   /*...@unchecked@*/
   extern int _rpmtcl_debug;
  @@ -427,6 +429,10 @@
    { "rpmpythondebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
&_rpmpython_debug, -1,
        N_("Debug embedded Python interpreter"), NULL},
   #endif
  +#ifdef WITH_RUBY
  + { "rpmrubydebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
&_rpmruby_debug, -1,
  +     N_("Debug embedded Ruby interpreter"), NULL},
  +#endif
    { "rpmsqdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmsq_debug, 
-1,
        N_("Debug rpmsq Signal Queue"), NULL},
   #ifdef WITH_TCL
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.184 -r1.185 rpmio.c
  --- rpm/rpmio/rpmio.c 8 Apr 2009 06:09:59 -0000       1.184
  +++ rpm/rpmio/rpmio.c 8 Apr 2009 17:31:56 -0000       1.185
  @@ -3132,6 +3132,7 @@
       extern rpmioPool _rpmtclPool;
       extern rpmioPool _rpmperlPool;
       extern rpmioPool _rpmpythonPool;
  +    extern rpmioPool _rpmrubyPool;
   /*...@=nestedextern@*/
   
   #if defined(WITH_LUA)
  @@ -3148,6 +3149,9 @@
   #endif
       urlFreeCache();
   
  +#if defined(WITH_RUBY)
  +    _rpmrubyPool = rpmioFreePool(_rpmrubyPool);
  +#endif
   #if defined(WITH_PYTHONEMBED)
       _rpmpythonPool = rpmioFreePool(_rpmpythonPool);
   #endif
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmruby.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmruby.c
  --- /dev/null 2009-04-08 19:30:19 +0200
  +++ rpmruby.c 2009-04-08 19:31:56 +0200
  @@ -0,0 +1,108 @@
  +/* XXX grrr, ruby.h includes its own config.h too. */
  +#ifdef       HAVE_CONFIG_H
  +#include "config.h"
  +#endif
  +#undef       PACKAGE_NAME
  +#undef       PACKAGE_TARNAME
  +#undef       PACKAGE_VERSION
  +#undef       PACKAGE_STRING
  +#undef       PACKAGE_BUGREPORT
  +
  +#include <ruby.h>
  +
  +#define _RPMRUBY_INTERNAL
  +#include "rpmruby.h"
  +
  +#include "debug.h"
  +
  +/*...@unchecked@*/
  +int _rpmruby_debug = 0;
  +
  +static void rpmrubyFini(void * _ruby)
  +        /*...@globals fileSystem @*/
  +        /*...@modifies *_ruby, fileSystem @*/
  +{
  +    rpmruby ruby = _ruby;
  +
  +    ruby->fn = _free(ruby->fn);
  +    ruby->flags = 0;
  +#if defined(WITH_RUBY)
  +    ruby_finalize();
  +    ruby_cleanup(0);
  +#endif
  +    ruby->I = NULL;
  +}
  +
  +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  +rpmioPool _rpmrubyPool;
  +
  +static rpmruby rpmrubyGetPool(/*...@null@*/ rpmioPool pool)
  +        /*...@globals _rpmrubyPool, fileSystem @*/
  +        /*...@modifies pool, _rpmrubyPool, fileSystem @*/
  +{
  +    rpmruby ruby;
  +
  +    if (_rpmrubyPool == NULL) {
  +        _rpmrubyPool = rpmioNewPool("ruby", sizeof(*ruby), -1, 
_rpmruby_debug,
  +                        NULL, NULL, rpmrubyFini);
  +        pool = _rpmrubyPool;
  +    }
  +    return (rpmruby) rpmioGetPool(pool, sizeof(*ruby));
  +}
  +
  +rpmruby rpmrubyNew(const char * fn, int flags)
  +{
  +    rpmruby ruby = rpmrubyGetPool(_rpmrubyPool);
  +
  +    if (fn)
  +     ruby->fn = strdup(fn);
  +    ruby->flags = flags;
  +
  +#if defined(WITH_RUBY)
  +    ruby_init();
  +    ruby_script("rpmruby");
  +#endif
  +
  +    return rpmrubyLink(ruby);
  +}
  +
  +rpmRC rpmrubyRunFile(rpmruby ruby, const char * fn, const char ** resultp)
  +{
  +    rpmRC rc = RPMRC_FAIL;
  +
  +if (_rpmruby_debug)
  +fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, ruby, fn);
  +
  +    if (fn != NULL) {
  +#if defined(WITH_RUBY)
  +     rb_load_file(fn);
  +     ruby->state = ruby_exec();
  +     rc = RPMRC_OK;
  +#ifdef       NOTYET
  +     if (resultp)
  +         *resultp = Tcl_GetStringResult(ruby->I);
  +#endif
  +#endif
  +    }
  +    return rc;
  +}
  +
  +rpmRC rpmrubyRun(rpmruby ruby, const char * str, const char ** resultp)
  +{
  +    rpmRC rc = RPMRC_FAIL;
  +
  +if (_rpmruby_debug)
  +fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, ruby, str);
  +
  +    if (str != NULL) {
  +#if defined(WITH_RUBY)
  +     ruby->state = rb_eval_string(str);
  +     rc = RPMRC_OK;
  +#ifdef       NOTYET
  +     if (resultp)
  +         *resultp = Tcl_GetStringResult(ruby->I);
  +#endif
  +#endif
  +    }
  +    return rc;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmruby.h
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmruby.h
  --- /dev/null 2009-04-08 19:30:19 +0200
  +++ rpmruby.h 2009-04-08 19:31:56 +0200
  @@ -0,0 +1,103 @@
  +#ifndef RPMRUBY_H
  +#define RPMRUBY_H
  +
  +/** \ingroup rpmio
  + * \file rpmio/rpmruby.h
  + */
  +
  +#include <rpmiotypes.h>
  +#include <rpmio.h>
  +
  +typedef /*...@abstract@*/ struct rpmruby_s * rpmruby;
  +
  +/*...@unchecked@*/
  +extern int _rpmruby_debug;
  +
  +#if defined(_RPMRUBY_INTERNAL)
  +struct rpmruby_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
  +    const char * fn;
  +    int flags;
  +    void * I;
  +    unsigned long state;
  +};
  +#endif /* _RPMRUBY_INTERNAL */
  +
  +#ifdef __cplusplus
  +extern "C" {
  +#endif
  +
  +/**
  + * Unreference a ruby interpreter instance.
  + * @param ruby               ruby interpreter
  + * @return           NULL on last dereference
  + */
  +/*...@unused@*/ /*...@null@*/
  +rpmruby rpmrubyUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmruby 
ruby)
  +     /*...@modifies ruby @*/;
  +#define      rpmrubyUnlink(_ds)      \
  +    ((rpmruby)rpmioUnlinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, 
__FILE__, __LINE__))
  +
  +/**
  + * Reference a ruby interpreter instance.
  + * @param ruby               ruby interpreter
  + * @return           new ruby interpreter reference
  + */
  +/*...@unused@*/ /*...@newref@*/ /*...@null@*/
  +rpmruby rpmrubyLink (/*...@null@*/ rpmruby ruby)
  +     /*...@modifies ruby @*/;
  +#define      rpmrubyLink(_ruby)      \
  +    ((rpmruby)rpmioLinkPoolItem((rpmioItem)(_ruby), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Destroy a ruby interpreter.
  + * @param ruby               ruby interpreter
  + * @return           NULL on last dereference
  + */
  +/*...@null@*/
  +rpmruby rpmrubyFree(/*...@killref@*/ /*...@null@*/rpmruby ruby)
  +     /*...@globals fileSystem @*/
  +     /*...@modifies ruby, fileSystem @*/;
  +#define      rpmrubyFree(_ruby)      \
  +    ((rpmruby)rpmioFreePoolItem((rpmioItem)(_ruby), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Create and load a ruby interpreter.
  + * @param fn         (unimplemented) ruby file to load (or NULL)
  + * @param flags              (unimplemented) ruby interpreter flags
  + * @return           new ruby interpreter
  + */
  +/*...@newref@*/ /*...@null@*/
  +rpmruby rpmrubyNew(/*...@null@*/ const char * fn, int flags)
  +     /*...@globals fileSystem, internalState @*/
  +     /*...@modifies fileSystem, internalState @*/;
  +
  +/**
  + * Execute ruby from a file.
  + * @param ruby               ruby interpreter
  + * @param fn         ruby file to run (or NULL)
  + * @param *resultp   ruby exec result
  + * @return           RPMRC_OK on success
  + */
  +rpmRC rpmrubyRunFile(rpmruby ruby, /*...@null@*/ const char * fn,
  +             /*...@null@*/ const char ** resultp)
  +     /*...@globals fileSystem, internalState @*/
  +     /*...@modifies ruby, fileSystem, internalState @*/;
  +
  +/**
  + * Execute ruby string.
  + * @param ruby               ruby interpreter
  + * @param str                ruby string to execute (or NULL)
  + * @param *resultp   ruby exec result
  + * @return           RPMRC_OK on success
  + */
  +rpmRC rpmrubyRun(rpmruby ruby, /*...@null@*/ const char * str,
  +             /*...@null@*/ const char ** resultp)
  +     /*...@globals fileSystem, internalState @*/
  +     /*...@modifies ruby, *resultp, fileSystem, internalState @*/;
  +
  +#ifdef __cplusplus
  +}
  +#endif
  +
  +#endif /* RPMRUBY_H */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/truby.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 truby.c
  --- /dev/null 2009-04-08 19:30:19 +0200
  +++ truby.c   2009-04-08 19:31:56 +0200
  @@ -0,0 +1,54 @@
  +#include "system.h"
  +
  +#include <rpmio_internal.h>
  +#include <poptIO.h>
  +
  +#define      _RPMRUBY_INTERNAL
  +#include <rpmruby.h>
  +
  +#include "debug.h"
  +
  +static struct poptOption optionsTable[] = {
  +
  + { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
  +     N_("Common options for all rpmio executables:"),
  +     NULL },
  +
  +  POPT_AUTOHELP
  +  POPT_TABLEEND
  +};
  +
  +int
  +main(int argc, char *argv[])
  +{
  +    poptContext optCon = rpmioInit(argc, argv, optionsTable);
  +    const char * rubyFN = NULL;
  +    int rubyFlags = 0;
  +    rpmruby ruby = rpmrubyNew(rubyFN, rubyFlags);
  +    ARGV_t av = poptGetArgs(optCon);
  +    int ac = argvCount(av);
  +    const char * fn;
  +    int rc = 1;              /* assume failure */
  +
  +    if (ac < 1) {
  +     poptPrintUsage(optCon, stderr, 0);
  +     goto exit;
  +    }
  +
  +    while ((fn = *av++) != NULL) {
  +     const char * result;
  +     rpmRC ret;
  +     result = NULL;
  +     if ((ret = rpmrubyRunFile(ruby, fn, &result)) != RPMRC_OK)
  +         goto exit;
  +     if (result != NULL && *result != '\0')
  +         fprintf(stdout, "%s\n", result);
  +    }
  +    rc = 0;
  +
  +exit:
  +    ruby = rpmrubyFree(ruby);
  +    optCon = rpmioFini(optCon);
  +
  +    return rc;
  +}
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to