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:   07-Apr-2009 19:17:22
  Branch: HEAD                             Handle: 2009040717172100

  Added files:
    rpm/rpmio               rpmperl.c rpmperl.h tperl.c
  Modified files:
    rpm                     CHANGES configure.ac devtool.conf
    rpm/rpmio               .cvsignore Makefile.am librpmio.vers rpmio.c
                            rpmtcl.c rpmtcl.h

  Log:
    - jbj: perl: add --with-perlembed for embedding perl.

  Summary:
    Revision    Changes     Path
    1.2903      +1  -0      rpm/CHANGES
    2.356       +10 -2      rpm/configure.ac
    2.276       +1  -0      rpm/devtool.conf
    1.35        +2  -1      rpm/rpmio/.cvsignore
    1.220       +8  -4      rpm/rpmio/Makefile.am
    2.105       +4  -1      rpm/rpmio/librpmio.vers
    1.181       +4  -0      rpm/rpmio/rpmio.c
    2.1         +94 -0      rpm/rpmio/rpmperl.c
    2.1         +93 -0      rpm/rpmio/rpmperl.h
    2.4         +0  -1      rpm/rpmio/rpmtcl.c
    2.3         +2  -2      rpm/rpmio/rpmtcl.h
    2.1         +67 -0      rpm/rpmio/tperl.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2902 -r1.2903 CHANGES
  --- rpm/CHANGES       6 Apr 2009 23:43:17 -0000       1.2902
  +++ rpm/CHANGES       7 Apr 2009 17:17:21 -0000       1.2903
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - jbj: perl: add --with-perlembed for embedding perl.
       - jbj: tcl: wire-up %post -p <tcl>. arg1/arg2, persistent interp, todo++.
       - jbj: tcl: wire-up %{tcl:...} with a string result.
       - jbj: tcl: add --with-tcl for embedding tcl.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/configure.ac
  ============================================================================
  $ cvs diff -u -r2.355 -r2.356 configure.ac
  --- rpm/configure.ac  7 Apr 2009 14:39:42 -0000       2.355
  +++ rpm/configure.ac  7 Apr 2009 17:17:21 -0000       2.356
  @@ -918,8 +918,8 @@
   fi
   AC_ARG_WITH(perl, AS_HELP_STRING([--with-perl], [build with RPM Perl 
language bindings]), [
       if test ".$withval" != .no; then
  -         PERL_INSTALLDIRS=""
  -         if test "$withval" == "vendor"; then
  +     PERL_INSTALLDIRS=""
  +        if test "$withval" == "vendor"; then
                    PERL_INSTALLDIRS="'INSTALLDIRS'     => 'vendor',"
            fi
            if test "$withval" == "site"; then
  @@ -1240,6 +1240,14 @@
   ])
   AC_SUBST(DBAPI)
   
  +dnl # Perl ExtUtils::Embed
  +RPM_CHECK_LIB(
  +    [Perl ExtUtils::Embed], [perlembed],
  +    [perl], [perl_alloc], [perl.h],
  +    [no,external:none], [],
  +    [
  +    ], [])
  +
   dnl # Tcl
   RPM_CHECK_LIB(
       [Tcl], [tcl],
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/devtool.conf
  ============================================================================
  $ cvs diff -u -r2.275 -r2.276 devtool.conf
  --- rpm/devtool.conf  6 Apr 2009 20:34:09 -0000       2.275
  +++ rpm/devtool.conf  7 Apr 2009 17:17:21 -0000       2.276
  @@ -94,6 +94,7 @@
           --with-selinux \
           --with-python \
           --with-perl \
  +        --with-perlembed=/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE \
           --with-build-extlibdep \
           --with-build-maxextlibdep \
           --enable-build-pic \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/.cvsignore
  ============================================================================
  $ cvs diff -u -r1.34 -r1.35 .cvsignore
  --- rpm/rpmio/.cvsignore      6 Apr 2009 20:34:10 -0000       1.34
  +++ rpm/rpmio/.cvsignore      7 Apr 2009 17:17:21 -0000       1.35
  @@ -42,8 +42,9 @@
   tmacro
   tmagic
   tmire
  -tpw
  +tperl
   tput
  +tpw
   tring
   trpmio
   tsw
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.219 -r1.220 Makefile.am
  --- rpm/rpmio/Makefile.am     6 Apr 2009 20:34:10 -0000       1.219
  +++ rpm/rpmio/Makefile.am     7 Apr 2009 17:17:21 -0000       1.220
  @@ -18,7 +18,7 @@
        rpmgenbasedir rpmgenpkglist rpmgensrclist rpmgpg \
        rpmpbzip2 rpmpigz rpmtar rpmz \
        tdir tfts tget tglob thkp thtml tinv tkey tmacro tmagic tmire \
  -     tput tpw trpmio tsw ttcl dumpasn1 lookup3
  +     tperl tput tpw trpmio tsw ttcl dumpasn1 lookup3
   
   bin_PROGRAMS =
   man_MANS =
  @@ -66,7 +66,7 @@
        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 rpmsq.h rpmssl.h \
  +     rpmlua.h rpmmg.h rpmnss.h rpmperl.h rpmsq.h rpmssl.h \
        rpmio-stub.h rpmtcl.h rpmurl.h rpmuuid.h rpmxar.h rpmz.h rpmzq.h \
        tar.h ugid.h
   
  @@ -79,8 +79,9 @@
        md2.c md4.c rmd128.c rmd160.c rmd256.c rmd320.c sha224.c \
        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 
rpmpgp.c \
  -     rpmrpc.c rpmsq.c rpmssl.c rpmsw.c rpmtcl.c rpmuuid.c rpmxar.c rpmzlog.c 
rpmzq.c \
  +     rpmkeyring.c rpmku.c rpmlog.c rpmlua.c rpmmalloc.c rpmmg.c rpmnss.c \
  +     rpmperl.c rpmpgp.c rpmrpc.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
  @@ -318,6 +319,9 @@
   tmire_SOURCES = tmire.c
   tmire_LDADD = $(RPMIO_LDADD_COMMON)
   
  +tperl_SOURCES = tperl.c
  +tperl_LDADD = $(RPMIO_LDADD_COMMON)
  +
   tput_SOURCES = tput.c
   tput_LDADD = $(RPMIO_LDADD_COMMON)
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.104 -r2.105 librpmio.vers
  --- rpm/rpmio/librpmio.vers   6 Apr 2009 21:41:16 -0000       2.104
  +++ rpm/rpmio/librpmio.vers   7 Apr 2009 17:17:21 -0000       2.105
  @@ -391,9 +391,12 @@
       rpmmgFile;
       rpmmgBuffer;
       rpmnssImplVecs;
  +    _rpmperl_debug;
  +    rpmperlNew;
  +    rpmperlRun;
  +    _rpmsq_debug;
       rpmsqAction;
       rpmsqCaught;
  -    _rpmsq_debug;
       rpmsqEnable;
       rpmsqExecve;
       rpmsqFork;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.180 -r1.181 rpmio.c
  --- rpm/rpmio/rpmio.c 7 Apr 2009 10:02:49 -0000       1.180
  +++ rpm/rpmio/rpmio.c 7 Apr 2009 17:17:21 -0000       1.181
  @@ -3128,6 +3128,7 @@
   /*...@=shadow@*/
       extern rpmioPool _rpmmgPool;
       extern rpmioPool _rpmtclPool;
  +    extern rpmioPool _rpmperlPool;
   /*...@=nestedextern@*/
   
   #if defined(WITH_LUA)
  @@ -3144,6 +3145,9 @@
   #endif
       urlFreeCache();
   
  +#if defined(WITH_PERLEMBED)
  +    _rpmperlPool = rpmioFreePool(_rpmperlPool);
  +#endif
   #if defined(WITH_TCL)
       _rpmtclPool = rpmioFreePool(_rpmtclPool);
   #endif
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmperl.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmperl.c
  --- /dev/null 2009-04-07 19:15:28 +0200
  +++ rpmperl.c 2009-04-07 19:17:22 +0200
  @@ -0,0 +1,94 @@
  +#include "system.h"
  +
  +#undef       _       /* XXX everyone gotta be different */
  +
  +#define _RPMPERL_INTERNAL
  +#include "rpmperl.h"
  +
  +#include "debug.h"
  +
  +#define      my_perl (perl->I)
  +
  +/*...@unchecked@*/
  +int _rpmperl_debug = 0;
  +
  +static void rpmperlFini(void * _perl)
  +        /*...@globals fileSystem @*/
  +        /*...@modifies *_perl, fileSystem @*/
  +{
  +    rpmperl perl = _perl;
  +
  +    perl->fn = _free(perl->fn);
  +    perl->flags = 0;
  +#if defined(WITH_PERLEMBED)
  +    PERL_SET_CONTEXT(my_perl);
  +    PL_perl_destruct_level = 1;
  +    perl_destruct(my_perl);
  +    perl_free(my_perl);
  +#endif
  +    my_perl = NULL;
  +}
  +
  +/*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  +rpmioPool _rpmperlPool;
  +
  +static rpmperl rpmperlGetPool(/*...@null@*/ rpmioPool pool)
  +        /*...@globals _rpmperlPool, fileSystem @*/
  +        /*...@modifies pool, _rpmperlPool, fileSystem @*/
  +{
  +    rpmperl perl;
  +
  +    if (_rpmperlPool == NULL) {
  +        _rpmperlPool = rpmioNewPool("perl", sizeof(*perl), -1, 
_rpmperl_debug,
  +                        NULL, NULL, rpmperlFini);
  +        pool = _rpmperlPool;
  +    }
  +    return (rpmperl) rpmioGetPool(pool, sizeof(*perl));
  +}
  +
  +rpmperl rpmperlNew(const char * fn, int flags)
  +{
  +    static char *embedding[] = { "", "-e", "0" };
  +    rpmperl perl = rpmperlGetPool(_rpmperlPool);
  +    int xx;
  +
  +    if (fn)
  +     perl->fn = xstrdup(fn);
  +    perl->flags = flags;
  +
  +
  +#if defined(WITH_PERLEMBED)
  +    my_perl = perl_alloc();
  +    PERL_SET_CONTEXT(my_perl);
  +    PL_perl_destruct_level = 1;
  +    perl_construct(my_perl);
  +
  +    PL_origalen = 1; /* don't let $0 assignment update 
proctitle/embedding[0] */
  +    xx = perl_parse(my_perl, NULL, 3, embedding, NULL);
  +    PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
  +    perl_run(my_perl);
  +#endif
  +
  +    return rpmperlLink(perl);
  +}
  +
  +rpmRC rpmperlRun(rpmperl perl, const char * str, const char ** resultp)
  +{
  +    rpmRC rc = RPMRC_FAIL;
  +
  +if (_rpmperl_debug)
  +fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, perl, str);
  +
  +    if (str != NULL) {
  +#if defined(WITH_PERLEMBED)
  +     STRLEN n_a;
  +     SV * retSV;
  +     PERL_SET_CONTEXT(my_perl);
  +     retSV = Perl_eval_pv(my_perl, str, TRUE);
  +     if (resultp)
  +         *resultp = SvPV(retSV, n_a);
  +#endif
  +     rc = RPMRC_OK;
  +    }
  +    return rc;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmperl.h
  ============================================================================
  $ cvs diff -u -r0 -r2.1 rpmperl.h
  --- /dev/null 2009-04-07 19:15:28 +0200
  +++ rpmperl.h 2009-04-07 19:17:22 +0200
  @@ -0,0 +1,93 @@
  +#ifndef RPMPERL_H
  +#define RPMPERL_H
  +
  +/** \ingroup rpmio
  + * \file rpmio/rpmperl.h
  + */
  +
  +#include <rpmiotypes.h>
  +#include <rpmio.h>
  +
  +typedef /*...@abstract@*/ struct rpmperl_s * rpmperl;
  +
  +/*...@unchecked@*/
  +extern int _rpmperl_debug;
  +
  +#if defined(_RPMPERL_INTERNAL)
  +#include <EXTERN.h>
  +#include <perl.h>
  +
  +struct rpmperl_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
  +    const char * fn;
  +    int flags;
  +    PerlInterpreter * I;
  +};
  +#endif /* _RPMPERL_INTERNAL */
  +
  +#ifdef __cplusplus
  +extern "C" {
  +#endif
  +
  +/**
  + * Unreference a perl interpreter instance.
  + * @param perl               perl interpreter
  + * @return           NULL on last dereference
  + */
  +/*...@unused@*/ /*...@null@*/
  +rpmperl rpmperlUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmperl 
perl)
  +     /*...@modifies perl @*/;
  +#define      rpmperlUnlink(_ds)      \
  +    ((rpmperl)rpmioUnlinkPoolItem((rpmioItem)(_perl), __FUNCTION__, 
__FILE__, __LINE__))
  +
  +/**
  + * Reference a perl interpreter instance.
  + * @param perl               perl interpreter
  + * @return           new perl interpreter reference
  + */
  +/*...@unused@*/ /*...@newref@*/ /*...@null@*/
  +rpmperl rpmperlLink (/*...@null@*/ rpmperl perl)
  +     /*...@modifies perl @*/;
  +#define      rpmperlLink(_perl)      \
  +    ((rpmperl)rpmioLinkPoolItem((rpmioItem)(_perl), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Destroy a perl interpreter.
  + * @param perl               perl interpreter
  + * @return           NULL on last dereference
  + */
  +/*...@null@*/
  +rpmperl rpmperlFree(/*...@killref@*/ /*...@null@*/rpmperl perl)
  +     /*...@globals fileSystem @*/
  +     /*...@modifies perl, fileSystem @*/;
  +#define      rpmperlFree(_perl)      \
  +    ((rpmperl)rpmioFreePoolItem((rpmioItem)(_perl), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Create and load a perl interpreter.
  + * @param fn         (unimplemented) perl file to load (or NULL)
  + * @param flags              (unimplemented) perl interpreter flags
  + * @return           new perl interpreter
  + */
  +/*...@newref@*/ /*...@null@*/
  +rpmperl rpmperlNew(/*...@null@*/ const char * fn, int flags)
  +     /*...@globals fileSystem, internalState @*/
  +     /*...@modifies fileSystem, internalState @*/;
  +
  +/**
  + * Execute perl string.
  + * @param perl               perl interpreter
  + * @param str                perl string to execute (or NULL)
  + * @param *resultp   perl exec result
  + * @return           RPMRC_OK on success
  + */
  +rpmRC rpmperlRun(rpmperl perl, /*...@null@*/ const char * str,
  +             /*...@null@*/ const char ** resultp)
  +     /*...@globals fileSystem, internalState @*/
  +     /*...@modifies perl, *resultp, fileSystem, internalState @*/;
  +
  +#ifdef __cplusplus
  +}
  +#endif
  +
  +#endif /* RPMPERL_H */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.c
  ============================================================================
  $ cvs diff -u -r2.3 -r2.4 rpmtcl.c
  --- rpm/rpmio/rpmtcl.c        7 Apr 2009 10:02:49 -0000       2.3
  +++ rpm/rpmio/rpmtcl.c        7 Apr 2009 17:17:21 -0000       2.4
  @@ -22,7 +22,6 @@
   #endif
       tcl->I = NULL;
   }
  -/*...@=mustmod@*/
   
   /*...@unchecked@*/ /*...@only@*/ /*...@null@*/
   rpmioPool _rpmtclPool;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.h
  ============================================================================
  $ cvs diff -u -r2.2 -r2.3 rpmtcl.h
  --- rpm/rpmio/rpmtcl.h        6 Apr 2009 21:41:16 -0000       2.2
  +++ rpm/rpmio/rpmtcl.h        7 Apr 2009 17:17:21 -0000       2.3
  @@ -64,8 +64,8 @@
   
   /**
    * Create and load a tcl interpreter.
  - * @param fn         tcl file to load (or NULL)
  - * @param flags              tcl interpretr flags
  + * @param fn         (unimplemented) tcl file to load (or NULL)
  + * @param flags              (unimplemented) tcl interpreter flags
    * @return           new tcl interpreter
    */
   /*...@newref@*/ /*...@null@*/
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tperl.c
  ============================================================================
  $ cvs diff -u -r0 -r2.1 tperl.c
  --- /dev/null 2009-04-07 19:15:28 +0200
  +++ tperl.c   2009-04-07 19:17:22 +0200
  @@ -0,0 +1,67 @@
  +#include "system.h"
  +
  +#undef  _    /* XXX everyone gotta be different */
  +
  +#include <rpmio_internal.h>
  +#include <poptIO.h>
  +
  +#define      _RPMPERL_INTERNAL
  +#include <rpmperl.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 * perlFN = NULL;
  +    int perlFlags = 0;
  +    rpmperl perl = rpmperlNew(perlFN, perlFlags);
  +    ARGV_t av = poptGetArgs(optCon);
  +    int ac = argvCount(av);
  +#ifdef       NOTYET
  +    const char * fn;
  +#endif
  +    const char * result;
  +    int rc = 1;              /* assume failure */
  +
  +#ifdef       NOTYET
  +    if (ac < 1) {
  +     poptPrintUsage(optCon, stderr, 0);
  +     goto exit;
  +    }
  +
  +    while ((fn = *av++) != NULL) {
  +     rpmRC ret;
  +     result = NULL;
  +     if ((ret = rpmperlRunFile(perl, fn, &result)) != RPMRC_OK)
  +         goto exit;
  +     if (result != NULL && *result != '\0')
  +         fprintf(stdout, "%s\n", result);
  +    }
  +    rc = 0;
  +#else
  +    result = NULL;
  +    if (rpmperlRun(perl, "print \"Hello, world!\n\";", &result) != RPMRC_OK)
  +     goto exit;
  +    if (result && *result)
  +     fprintf(stdout, "%s\n", result);
  +    rc = 0;
  +#endif
  +
  +exit:
  +    perl = rpmperlFree(perl);
  +    optCon = rpmioFini(optCon);
  +
  +    return rc;
  +}
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to