RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Olivier Thauvin Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 05-Aug-2007 14:47:14 Branch: HEAD Handle: 2007080513471400 Added files: rpm/perl RPM_Transaction.xs Modified files: rpm/perl Makefile.am typemap Removed files: rpm/perl RPM_Ts.xs Log: - rename perl xs for RPM::Transaction, create test and .pm file Summary: Revision Changes Path 1.13 +1 -1 rpm/perl/Makefile.am 1.1 +260 -0 rpm/perl/RPM_Transaction.xs 1.4 +0 -260 rpm/perl/RPM_Ts.xs 1.7 +4 -4 rpm/perl/typemap ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/perl/Makefile.am ============================================================================ $ cvs diff -u -r1.12 -r1.13 Makefile.am --- rpm/perl/Makefile.am 5 Aug 2007 01:42:53 -0000 1.12 +++ rpm/perl/Makefile.am 5 Aug 2007 12:47:14 -0000 1.13 @@ -10,7 +10,7 @@ RPM.xs RPM.pm t/01.rpm.t \ RPM/Constant.pm RPM_Constant.xs t/02.rpmconstant.t \ RPM_Header.xs RPM/Header.pm t/03.header.t \ - RPM_Ts.xs \ + RPM_Transaction.xs RPM/Transaction.pm t/04.transaction.t \ t/00.pod.coverage.t t/00.pod.t \ hdlist-test.hdr test-rpm-1.0-1.noarch.rpm test-rpm-1.0-1.src.rpm @@ . patch -p0 <<'@@ .' Index: rpm/perl/RPM_Transaction.xs ============================================================================ $ cvs diff -u -r0 -r1.1 RPM_Transaction.xs --- /dev/null 2007-08-05 14:44:00 +0200 +++ RPM_Transaction.xs 2007-08-05 14:47:14 +0200 @@ -0,0 +1,260 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#undef Fflush +#undef Mkdir +#undef Stat + +#include <stdio.h> +#include <string.h> +#include <utime.h> + +#include "rpmlib.h" +#include "rpmio.h" +#include "rpmcli.h" +#include "rpmts.h" +#include "rpmte.h" +#include "header.h" +#include "rpmdb.h" +#include "misc.h" + + +/* Chip, this is somewhat stripped down from the default callback used by + the rpmcli. It has to be here to insure that we open the pkg again. + If we don't do this we get segfaults. I also, kept the updating of some + of the rpmcli static vars, but I may not have needed to do this. + + Also, we probably want to give a nice interface such that we could allow + users of RPM to do their own callback, but that will have to come later. +*/ +static void * _null_callback( + const void * arg, + const rpmCallbackType what, + const unsigned long long amount, + const unsigned long long total, + fnpyKey key, + rpmCallbackData data) +{ + Header h = (Header) arg; + int flags = (int) ((long)data); + void * rc = NULL; + const char * filename = (const char *)key; + static FD_t fd = NULL; + int xx; + + /* Code stolen from rpminstall.c and modified */ + switch(what) { + case RPMCALLBACK_INST_OPEN_FILE: + if (filename == NULL || filename[0] == '\0') + return NULL; + fd = Fopen(filename, "r.ufdio"); + /* FIX: still necessary? */ + if (fd == NULL || Ferror(fd)) { + fprintf(stderr, "open of %s failed!\n", filename); + if (fd != NULL) { + xx = Fclose(fd); + fd = NULL; + } + } else + fd = fdLink(fd, "persist (showProgress)"); + return (void *)fd; + break; + + case RPMCALLBACK_INST_CLOSE_FILE: + /* FIX: still necessary? */ + fd = fdFree(fd, "persist (showProgress)"); + if (fd != NULL) { + xx = Fclose(fd); + fd = NULL; + } + break; + + case RPMCALLBACK_INST_START: + rpmcliHashesCurrent = 0; + if (h == NULL || !(flags & INSTALL_LABEL)) + break; + break; + + case RPMCALLBACK_TRANS_PROGRESS: + case RPMCALLBACK_INST_PROGRESS: + break; + + case RPMCALLBACK_TRANS_START: + rpmcliHashesCurrent = 0; + rpmcliProgressTotal = 1; + rpmcliProgressCurrent = 0; + break; + + case RPMCALLBACK_TRANS_STOP: + rpmcliProgressTotal = rpmcliPackagesTotal; + rpmcliProgressCurrent = 0; + break; + + case RPMCALLBACK_REPACKAGE_START: + rpmcliHashesCurrent = 0; + rpmcliProgressTotal = total; + rpmcliProgressCurrent = 0; + break; + + case RPMCALLBACK_REPACKAGE_PROGRESS: + break; + + case RPMCALLBACK_REPACKAGE_STOP: + rpmcliProgressTotal = total; + rpmcliProgressCurrent = total; + rpmcliProgressTotal = rpmcliPackagesTotal; + rpmcliProgressCurrent = 0; + break; + + case RPMCALLBACK_UNINST_PROGRESS: + break; + case RPMCALLBACK_UNINST_START: + break; + case RPMCALLBACK_UNINST_STOP: + break; + case RPMCALLBACK_UNPACK_ERROR: + break; + case RPMCALLBACK_CPIO_ERROR: + break; + case RPMCALLBACK_UNKNOWN: + break; + default: + break; + } + + return rc; +} + +MODULE = RPM_Ts PACKAGE = RPM::Transaction + +void +DESTROY(t) + rpmts t + CODE: + t = rpmtsFree(t); + +# XXX: Add relocations some day. +int +_add_install(t, h, fn, upgrade) + rpmts t + Header h + char * fn + int upgrade + PREINIT: + rpmRC rc = 0; + CODE: + rc = rpmtsAddInstallElement(t, h, (fnpyKey) fn, upgrade, NULL); + RETVAL = (rc == RPMRC_OK) ? 1 : 0; + OUTPUT: + RETVAL + +int +_add_delete(t, h, offset) + rpmts t + Header h + unsigned int offset + PREINIT: + rpmRC rc = 0; + CODE: + rc = rpmtsAddEraseElement(t, h, offset); + RETVAL = (rc == RPMRC_OK) ? 1 : 0; + OUTPUT: + RETVAL + +int +_element_count(t) + rpmts t +PREINIT: + int ret; +CODE: + ret = rpmtsNElements(t); + RETVAL = ret; +OUTPUT: + RETVAL + +int +_close_db(t) + rpmts t +PREINIT: + int ret; +CODE: + ret = rpmtsCloseDB(t); + RETVAL = (ret == 0) ? 1 : 0; +OUTPUT: + RETVAL + +int +_check(t) + rpmts t +PREINIT: + int ret; +CODE: + ret = rpmtsCheck(t); + RETVAL = (ret == 0) ? 1 : 0; +OUTPUT: + RETVAL + +int +_order(t) + rpmts t +PREINIT: + int ret; +CODE: + ret = rpmtsOrder(t); + /* XXX: May want to do something different here. It actually + returns the number of non-ordered elements...maybe we + want this? + */ + RETVAL = (ret == 0) ? 1 : 0; +OUTPUT: + RETVAL + +void +_elements(t, type) + rpmts t; + rpmElementType type; +PREINIT: + rpmtsi i; + rpmte te; + const char * NEVR; +PPCODE: + i = rpmtsiInit(t); + if(i == NULL) { + printf("Did not get a thing!\n"); + return; + } else { + while((te = rpmtsiNext(i, type)) != NULL) { + NEVR = rpmteNEVR(te); + XPUSHs(sv_2mortal(newSVpv(NEVR, 0))); + } + i = rpmtsiFree(i); + } + +int +_run(t, ok_probs, prob_filter) + rpmts t + rpmprobFilterFlags prob_filter + PREINIT: + int ret; + CODE: + /* Make sure we could run this transactions */ + ret = rpmtsCheck(t); + if (ret != 0) { + RETVAL = 0; + return; + } + ret = rpmtsOrder(t); + if (ret != 0) { + RETVAL = 0; + return; + } + + /* XXX: Should support callbacks eventually */ + (void) rpmtsSetNotifyCallback(t, _null_callback, (void *) ((long)0)); + ret = rpmtsRun(t, NULL, prob_filter); + RETVAL = (ret == 0) ? 1 : 0; + OUTPUT: + RETVAL + + @@ . rm -f rpm/perl/RPM_Ts.xs <<'@@ .' Index: rpm/perl/RPM_Ts.xs ============================================================================ [NO CHANGE SUMMARY BECAUSE FILE AS A WHOLE IS JUST REMOVED] @@ . patch -p0 <<'@@ .' Index: rpm/perl/typemap ============================================================================ $ cvs diff -u -r1.6 -r1.7 typemap --- rpm/perl/typemap 4 Aug 2007 21:25:42 -0000 1.6 +++ rpm/perl/typemap 5 Aug 2007 12:47:14 -0000 1.7 @@ -1,8 +1,8 @@ TYPEMAP -rpmdb O_OBJECT_rpmdb +rpmdb O_OBJECT_rpmdb rpmdbMatchIterator O_OBJECT_rpmmi -Header O_OBJECT_header -rpmts O_OBJECT_rpmts +Header O_OBJECT_header +rpmts O_OBJECT_rpmts rpmprobFilterFlags T_IV rpmElementType T_IV @@ -47,4 +47,4 @@ O_OBJECT_header sv_setref_pv( $arg, "RPM::Header", (void*)$var ); O_OBJECT_rpmts - sv_setref_pv( $arg, "RPM::C::Transaction", (void*)$var ); + sv_setref_pv( $arg, "RPM::Transaction", (void*)$var ); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org