Add rpmal bindings, Grand Renaming to rpmalFoo().

CVS patchset: 5450
CVS date: 2002/05/27 18:12:12
This commit is contained in:
jbj 2002-05-27 18:12:12 +00:00
parent ca60c30e3a
commit 259bb824cc
17 changed files with 768 additions and 376 deletions

View File

@ -189,7 +189,7 @@ int rpmtsAddPackage(rpmts ts, Header h,
if (!duplicate)
ts->orderCount++;
pkgKey = alAddPackage(&ts->addedPackages, pkgKey, rpmteKey(p),
pkgKey = rpmalAdd(&ts->addedPackages, pkgKey, rpmteKey(p),
rpmteDS(p, RPMTAG_PROVIDENAME),
rpmteFI(p, RPMTAG_BASENAMES));
if (pkgKey == RPMAL_NOMATCH) {
@ -313,7 +313,7 @@ void rpmtsAvailablePackage(rpmts ts, Header h, fnpyKey key)
rpmfi fi = rpmfiNew(ts, NULL, h, RPMTAG_BASENAMES, scareMem);
/* XXX FIXME: return code RPMAL_NOMATCH is error */
(void) alAddPackage(&ts->availablePackages, RPMAL_NOMATCH, key,
(void) rpmalAdd(&ts->availablePackages, RPMAL_NOMATCH, key,
provides, fi);
fi = rpmfiFree(fi, 1);
provides = rpmdsFree(provides);
@ -434,7 +434,7 @@ static int unsatisfiedDepend(rpmts ts, rpmds dep)
}
/* Search added packages for the dependency. */
if (alSatisfiesDepend(ts->addedPackages, dep, NULL) != NULL)
if (rpmalSatisfiesDepend(ts->addedPackages, dep, NULL) != NULL)
goto exit;
/* XXX only the installer does not have the database open here. */
@ -581,7 +581,7 @@ static int checkPackageDeps(rpmts ts, const char * pkgNEVR,
/*@-branchstate@*/
if (ts->availablePackages != NULL) {
suggestedKeys = alAllSatisfiesDepend(ts->availablePackages,
suggestedKeys = rpmalAllSatisfiesDepend(ts->availablePackages,
requires, NULL);
}
/*@=branchstate@*/
@ -995,7 +995,7 @@ static inline int addRelation(rpmts ts,
return 0;
pkgKey = RPMAL_NOMATCH;
key = alSatisfiesDepend(ts->addedPackages, requires, &pkgKey);
key = rpmalSatisfiesDepend(ts->addedPackages, requires, &pkgKey);
if (_tso_debug)
fprintf(stderr, "addRelation: pkgKey %ld\n", (long)pkgKey);
@ -1176,7 +1176,7 @@ int rpmtsOrder(rpmts ts)
int qlen;
int i, j;
alMakeIndex(ts->addedPackages);
rpmalMakeIndex(ts->addedPackages);
/*@-modfilesystem -nullpass -formattype@*/
if (_tso_debug)
@ -1608,7 +1608,7 @@ assert(newOrderCount == ts->orderCount);
}
pi = rpmteiFree(pi);
ts->addedPackages = alFree(ts->addedPackages);
ts->addedPackages = rpmalFree(ts->addedPackages);
ts->numAddedPackages = 0;
#else
rpmtsClean(ts);
@ -1670,8 +1670,8 @@ int rpmtsCheck(rpmts ts)
ts->probs = rpmpsFree(ts->probs);
ts->probs = rpmpsCreate();
alMakeIndex(ts->addedPackages);
alMakeIndex(ts->availablePackages);
rpmalMakeIndex(ts->addedPackages);
rpmalMakeIndex(ts->availablePackages);
/*
* Look at all of the added packages and make sure their dependencies

View File

@ -17,11 +17,11 @@
typedef /*@abstract@*/ struct availablePackage_s * availablePackage;
/*@unchecked@*/
static int _al_debug = 0;
int _rpmal_debug = 0;
/*@access alKey @*/
/*@access alNum @*/
/*@access availableList @*/
/*@access rpmal @*/
/*@access availablePackage @*/
/*@access fnpyKey @*/ /* XXX suggestedKeys array */
@ -107,7 +107,7 @@ struct dirInfo_s {
/** \ingroup rpmdep
* Set of available packages, items, and directories.
*/
struct availableList_s {
struct rpmal_s {
/*@owned@*/ /*@null@*/
availablePackage list; /*!< Set of packages. */
struct availableIndex_s index; /*!< Set of available items. */
@ -123,7 +123,7 @@ struct availableList_s {
* Destroy available item index.
* @param al available list
*/
static void alFreeIndex(availableList al)
static void rpmalFreeIndex(rpmal al)
/*@modifies al @*/
{
availableIndex ai = &al->index;
@ -139,14 +139,14 @@ static void alFreeIndex(availableList al)
* @param al available list
* @return no. of packages in list
*/
static int alGetSize(/*@null@*/ const availableList al)
static int alGetSize(/*@null@*/ const rpmal al)
/*@*/
{
return (al != NULL ? al->size : 0);
}
#endif
static inline alNum alKey2Num(/*@unused@*/ /*@null@*/ const availableList al,
static inline alNum alKey2Num(/*@unused@*/ /*@null@*/ const rpmal al,
/*@null@*/ alKey pkgKey)
/*@*/
{
@ -155,7 +155,7 @@ static inline alNum alKey2Num(/*@unused@*/ /*@null@*/ const availableList al,
/*@=nullret =temptrans =retalias @*/
}
static inline alKey alNum2Key(/*@unused@*/ /*@null@*/ const availableList al,
static inline alKey alNum2Key(/*@unused@*/ /*@null@*/ const rpmal al,
/*@null@*/ alNum pkgNum)
/*@*/
{
@ -172,7 +172,7 @@ static inline alKey alNum2Key(/*@unused@*/ /*@null@*/ const availableList al,
* @return available package pointer
*/
/*@dependent@*/ /*@null@*/
static availablePackage alGetPkg(/*@null@*/ const availableList al,
static availablePackage alGetPkg(/*@null@*/ const rpmal al,
/*@null@*/ alKey pkgKey)
/*@*/
{
@ -187,9 +187,9 @@ static availablePackage alGetPkg(/*@null@*/ const availableList al,
}
#endif
availableList alCreate(int delta)
rpmal rpmalCreate(int delta)
{
availableList al = xcalloc(1, sizeof(*al));
rpmal al = xcalloc(1, sizeof(*al));
availableIndex ai = &al->index;
al->delta = delta;
@ -205,7 +205,7 @@ availableList alCreate(int delta)
return al;
}
availableList alFree(availableList al)
rpmal rpmalFree(rpmal al)
{
availablePackage alp;
dirInfo die;
@ -230,7 +230,7 @@ availableList alFree(availableList al)
al->list = _free(al->list);
al->alloced = 0;
alFreeIndex(al);
rpmalFreeIndex(al);
al = _free(al);
return NULL;
}
@ -285,7 +285,7 @@ static int fieCompare(const void * one, const void * two)
return strcmp(a->baseName, b->baseName);
}
void alDelPackage(availableList al, alKey pkgKey)
void rpmalDel(rpmal al, alKey pkgKey)
{
alNum pkgNum = alKey2Num(al, pkgKey);
availablePackage alp;
@ -297,7 +297,7 @@ void alDelPackage(availableList al, alKey pkgKey)
alp = al->list + pkgNum;
/*@-modfilesys@*/
if (_al_debug)
if (_rpmal_debug)
fprintf(stderr, "*** del %p[%d]\n", al->list, pkgNum);
/*@=modfilesys@*/
@ -370,21 +370,21 @@ fprintf(stderr, "*** del %p[%d]\n", al->list, pkgNum);
return;
}
alKey alAddPackage(availableList * alistp, alKey pkgKey, fnpyKey key,
alKey rpmalAdd(rpmal * alistp, alKey pkgKey, fnpyKey key,
rpmds provides, rpmfi fi)
{
alNum pkgNum;
availableList al;
rpmal al;
availablePackage alp;
/* If list doesn't exist yet, create. */
if (*alistp == NULL)
*alistp = alCreate(5);
*alistp = rpmalCreate(5);
al = *alistp;
pkgNum = alKey2Num(al, pkgKey);
if (pkgNum >= 0 && pkgNum < al->size) {
alDelPackage(al, pkgKey);
rpmalDel(al, pkgKey);
} else {
if (al->size == al->alloced) {
al->alloced += al->delta;
@ -401,14 +401,14 @@ alKey alAddPackage(availableList * alistp, alKey pkgKey, fnpyKey key,
alp->key = key;
/*@-modfilesys@*/
if (_al_debug)
if (_rpmal_debug)
fprintf(stderr, "*** add %p[%d]\n", al->list, pkgNum);
/*@=modfilesys@*/
alp->provides = rpmdsLink(provides, "Provides (alAddPackage)");
alp->fi = rpmfiLink(fi, "Files (alAddPackage)");
alp->provides = rpmdsLink(provides, "Provides (rpmalAdd)");
alp->fi = rpmfiLink(fi, "Files (rpmalAdd)");
fi = rpmfiLink(alp->fi, "Files index (alAddPackage)");
fi = rpmfiLink(alp->fi, "Files index (rpmalAdd)");
fi = rpmfiInit(fi, 0);
if (rpmfiFC(fi) > 0) {
int * dirMapping;
@ -455,7 +455,7 @@ fprintf(stderr, "*** add %p[%d]\n", al->list, pkgNum);
die->files = NULL;
die->numFiles = 0;
/*@-modfilesys@*/
if (_al_debug)
if (_rpmal_debug)
fprintf(stderr, "+++ die[%3d] %p [%d] %s\n", al->numDirs, die, die->dirNameLen, die->dirName);
/*@=modfilesys@*/
@ -500,9 +500,9 @@ fprintf(stderr, "+++ die[%3d] %p [%d] %s\n", al->numDirs, die, die->dirNameLen,
if (origNumDirs != al->numDirs)
qsort(al->dirs, al->numDirs, sizeof(*al->dirs), dieCompare);
}
fi = rpmfiUnlink(fi, "Files index (alAddPackage)");
fi = rpmfiUnlink(fi, "Files index (rpmalAdd)");
alFreeIndex(al);
rpmalFreeIndex(al);
assert(((alNum)(alp - al->list)) == pkgNum);
return ((alKey)(alp - al->list));
@ -530,7 +530,7 @@ static int indexcmp(const void * one, const void * two)
return strcmp(a->entry, b->entry);
}
void alAddProvides(availableList al, alKey pkgKey, rpmds provides)
void rpmalAddProvides(rpmal al, alKey pkgKey, rpmds provides)
{
alNum pkgNum = alKey2Num(al, pkgKey);
availableIndex ai = &al->index;
@ -575,7 +575,7 @@ assert(ix < 0x10000);
}
}
void alMakeIndex(availableList al)
void rpmalMakeIndex(rpmal al)
{
availableIndex ai;
availablePackage alp;
@ -597,7 +597,7 @@ void alMakeIndex(availableList al)
for (i = 0; i < al->size; i++) {
alp = al->list + i;
alAddProvides(al, (alKey)i, alp->provides);
rpmalAddProvides(al, (alKey)i, alp->provides);
}
qsort(ai->index, ai->size, sizeof(*ai->index), indexcmp);
@ -605,7 +605,7 @@ void alMakeIndex(availableList al)
}
fnpyKey *
alAllFileSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
rpmalAllFileSatisfiesDepend(const rpmal al, const rpmds ds, alKey * keyp)
{
int found = 0;
const char * dirName;
@ -658,7 +658,7 @@ alAllFileSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
{
/*@-modfilesys@*/
if (_al_debug)
if (_rpmal_debug)
fprintf(stderr, "==> die %p %s\n", die, (die->dirName ? die->dirName : "(nil)"));
/*@=modfilesys@*/
@ -672,7 +672,7 @@ fprintf(stderr, "==> die %p %s\n", die, (die->dirName ? die->dirName : "(nil)"))
continue; /* XXX shouldn't happen */
/*@-modfilesys@*/
if (_al_debug)
if (_rpmal_debug)
fprintf(stderr, "==> fie %p %s\n", fie, (fie->baseName ? fie->baseName : "(nil)"));
/*@=modfilesys@*/
@ -704,7 +704,7 @@ exit:
}
fnpyKey *
alAllSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds, alKey * keyp)
{
availableIndex ai;
availableIndexEntry needle;
@ -721,7 +721,7 @@ alAllSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
return ret;
if (*KName == '/') {
ret = alAllFileSatisfiesDepend(al, ds, keyp);
ret = rpmalAllFileSatisfiesDepend(al, ds, keyp);
/* XXX Provides: /path was broken with added packages (#52183). */
if (ret != NULL && *ret != NULL)
return ret;
@ -785,9 +785,9 @@ alAllSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
}
fnpyKey
alSatisfiesDepend(const availableList al, const rpmds ds, alKey * keyp)
rpmalSatisfiesDepend(const rpmal al, const rpmds ds, alKey * keyp)
{
fnpyKey * tmp = alAllSatisfiesDepend(al, ds, keyp);
fnpyKey * tmp = rpmalAllSatisfiesDepend(al, ds, keyp);
if (tmp) {
fnpyKey ret = tmp[0];

View File

@ -6,7 +6,12 @@
* Structures used for managing added/available package lists.
*/
typedef /*@abstract@*/ struct availableList_s * availableList;
/*@unchecked@*/
extern int _rpmal_debug;
/**
*/
typedef /*@abstract@*/ struct rpmal_s * rpmal;
#ifdef __cplusplus
{
@ -19,7 +24,7 @@ typedef /*@abstract@*/ struct availableList_s * availableList;
*/
/*@-exportlocal@*/
/*@only@*/
availableList alCreate(int delta)
rpmal rpmalCreate(int delta)
/*@*/;
/*@=exportlocal@*/
@ -29,7 +34,7 @@ availableList alCreate(int delta)
* @return NULL always
*/
/*@null@*/
availableList alFree(/*@only@*/ /*@null@*/ availableList al)
rpmal rpmalFree(/*@only@*/ /*@null@*/ rpmal al)
/*@modifies al @*/;
/**
@ -38,7 +43,7 @@ availableList alFree(/*@only@*/ /*@null@*/ availableList al)
* @param pkgKey package key
*/
/*@-exportlocal@*/
void alDelPackage(/*@null@*/ availableList al, /*@null@*/ alKey pkgKey)
void rpmalDel(/*@null@*/ rpmal al, /*@null@*/ alKey pkgKey)
/*@modifies al @*/;
/*@=exportlocal@*/
@ -51,7 +56,7 @@ void alDelPackage(/*@null@*/ availableList al, /*@null@*/ alKey pkgKey)
* @param fi file info set
* @return available package index
*/
alKey alAddPackage(availableList * alistp,
alKey rpmalAdd(rpmal * alistp,
/*@dependent@*/ /*@null@*/ alKey pkgKey,
/*@dependent@*/ /*@null@*/ fnpyKey key,
/*@null@*/ rpmds provides, /*@null@*/ rpmfi fi)
@ -64,7 +69,7 @@ alKey alAddPackage(availableList * alistp,
* @param provides added package provides
*/
/*@-exportlocal@*/
void alAddProvides(availableList al,
void rpmalAddProvides(rpmal al,
/*@dependent@*/ /*@null@*/ alKey pkgKey,
/*@null@*/ rpmds provides)
/*@modifies al, provides @*/;
@ -74,7 +79,7 @@ void alAddProvides(availableList al,
* Generate index for available list.
* @param al available list
*/
void alMakeIndex(/*@null@*/ availableList al)
void rpmalMakeIndex(/*@null@*/ rpmal al)
/*@modifies al @*/;
/**
@ -86,7 +91,7 @@ void alMakeIndex(/*@null@*/ availableList al)
*/
/*@-exportlocal@*/
/*@only@*/ /*@null@*/
fnpyKey * alAllFileSatisfiesDepend(/*@null@*/ const availableList al,
fnpyKey * rpmalAllFileSatisfiesDepend(/*@null@*/ const rpmal al,
/*@null@*/ const rpmds ds, /*@null@*/ alKey * keyp)
/*@globals fileSystem @*/
/*@modifies al, *keyp, fileSystem @*/;
@ -100,7 +105,7 @@ fnpyKey * alAllFileSatisfiesDepend(/*@null@*/ const availableList al,
* @return associated package key(s), NULL if none
*/
/*@only@*/ /*@null@*/
fnpyKey * alAllSatisfiesDepend(const availableList al, const rpmds ds,
fnpyKey * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds,
/*@null@*/ alKey * keyp)
/*@globals fileSystem @*/
/*@modifies al, *keyp, fileSystem @*/;
@ -113,7 +118,7 @@ fnpyKey * alAllSatisfiesDepend(const availableList al, const rpmds ds,
* @retval keyp added package key pointer (or NULL)
* @return associated package key, NULL if none
*/
fnpyKey alSatisfiesDepend(const availableList al, const rpmds ds,
fnpyKey rpmalSatisfiesDepend(const rpmal al, const rpmds ds,
/*@null@*/ alKey * keyp)
/*@globals fileSystem @*/
/*@modifies al, *keyp, fileSystem @*/;

View File

@ -293,7 +293,7 @@ int rpmtsAvailable(rpmts ts, const rpmds ds)
if (ts->availablePackages == NULL)
return rc;
sugkey = alAllSatisfiesDepend(ts->availablePackages, ds, NULL);
sugkey = rpmalAllSatisfiesDepend(ts->availablePackages, ds, NULL);
if (sugkey == NULL)
return rc;
/* XXX no alternatives yet */
@ -334,7 +334,7 @@ void rpmtsClean(rpmts ts)
rpmteCleanDS(p);
pi = rpmteiFree(pi);
ts->addedPackages = alFree(ts->addedPackages);
ts->addedPackages = rpmalFree(ts->addedPackages);
ts->numAddedPackages = 0;
ts->suggests = _free(ts->suggests);
@ -366,7 +366,7 @@ rpmts rpmtsFree(rpmts ts)
(void) rpmtsCloseSDB(ts);
ts->availablePackages = alFree(ts->availablePackages);
ts->availablePackages = rpmalFree(ts->availablePackages);
ts->numAvailablePackages = 0;
ts->dsi = _free(ts->dsi);

View File

@ -101,12 +101,11 @@ struct rpmts_s {
int allocedRemovedPackages; /*!< Size of removed packages array. */
/*@only@*/
availableList addedPackages;/*!< Set of packages being installed. */
rpmal addedPackages; /*!< Set of packages being installed. */
int numAddedPackages; /*!< No. added package instances. */
/*@only@*/
availableList availablePackages;
/*!< Universe of available packages. */
rpmal availablePackages; /*!< Universe of available packages. */
int numAvailablePackages; /*!< No. available package instances. */
/*@owned@*/
@ -130,7 +129,8 @@ struct rpmts_s {
const char * fn; /*!< Current package fn. */
int_32 sigtag; /*!< Current package signature tag. */
int_32 sigtype; /*!< Current package signature data type. */
/*@null@*/ const void * sig; /*!< Current package signature. */
/*@null@*/
const void * sig; /*!< Current package signature. */
int_32 siglen; /*!< Current package signature length. */
/*@only@*/ /*@null@*/
@ -141,7 +141,8 @@ struct rpmts_s {
/*@null@*/
struct pgpDig_s * dig; /*!< Current signature/pubkey parameters. */
/*@refs@*/ int nrefs; /*!< Reference count. */
/*@refs@*/
int nrefs; /*!< Reference count. */
};
#endif /* _RPMTS_INTERNAL */

View File

@ -13,8 +13,8 @@ INCLUDES = -I. \
-I/usr/include/python${PYVER} \
@INCPATH@
noinst_HEADERS = \
db-py.h hash.h header-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
noinst_HEADERS = db-py.h hash.h header-py.h \
rpmal-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
mylibs= \
$(top_builddir)/lib/.libs/librpm.so \
@ -35,7 +35,7 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
noinst_LTLIBRARIES = librpmmodule.la
librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c \
db-py.c header-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
rpmmodule.so$(EXEEXT): $(librpmmodule_la_OBJECTS)
$(CC) -o $@ $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)

View File

@ -208,8 +208,8 @@ INCLUDES = -I. \
@INCPATH@
noinst_HEADERS = \
db-py.h hash.h header-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
noinst_HEADERS = db-py.h hash.h header-py.h \
rpmal-py.h rpmds-py.h rpmfi-py.h rpmts-py.h upgrade.h
mylibs = \
@ -232,7 +232,7 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
noinst_LTLIBRARIES = librpmmodule.la
librpmmodule_la_SOURCES = rpmmodule.c hash.c upgrade.c \
db-py.c header-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
db-py.c header-py.c rpmal-py.c rpmds-py.c rpmfi-py.c rpmts-py.c
subdir = python
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -243,7 +243,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
librpmmodule_la_LDFLAGS =
librpmmodule_la_LIBADD =
am_librpmmodule_la_OBJECTS = rpmmodule.lo hash.lo upgrade.lo db-py.lo \
header-py.lo rpmds-py.lo rpmfi-py.lo rpmts-py.lo
header-py.lo rpmal-py.lo rpmds-py.lo rpmfi-py.lo rpmts-py.lo
librpmmodule_la_OBJECTS = $(am_librpmmodule_la_OBJECTS)
python_PROGRAMS = rpmmodule.so$(EXEEXT) poptmodule.so$(EXEEXT)
PROGRAMS = $(python_PROGRAMS)
@ -266,9 +266,9 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/db-py.Plo ./$(DEPDIR)/hash.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/header-py.Plo ./$(DEPDIR)/poptmodule.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/rpmds-py.Plo ./$(DEPDIR)/rpmfi-py.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/rpmmodule.Plo ./$(DEPDIR)/rpmts-py.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/upgrade.Plo
@AMDEP_TRUE@ ./$(DEPDIR)/rpmal-py.Plo ./$(DEPDIR)/rpmds-py.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/rpmfi-py.Plo ./$(DEPDIR)/rpmmodule.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/rpmts-py.Plo ./$(DEPDIR)/upgrade.Plo
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@ -336,6 +336,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/header-py.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poptmodule.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmal-py.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmds-py.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmfi-py.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpmmodule.Plo@am__quote@

View File

@ -4,60 +4,35 @@
#include "system.h"
#ifdef DYING
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#include "Python.h"
#include "rpmio_internal.h"
#include "rpmcli.h" /* XXX for rpmCheckSig */
#include "rpmdb.h"
#include "misc.h"
#include "header_internal.h"
#include "upgrade.h"
#include "db-py.h"
#include "header-py.h"
#include "debug.h"
/** \ingroup python
*/
typedef struct rpmdbMIObject_s rpmdbMIObject;
/** \ingroup python
* \class rpmdbMatchIterator
* \brief A python rpmdbMatchIterator object represents the result of an RPM
* \class rpm.mi
* \brief A python rpm.mi match iterator object represents the result of an RPM
* database query.
*/
/** \ingroup python
* \name Class: rpmdbMatchIterator
* \name Class: rpm.mi
*/
/*@{*/
/** \ingroup python
*/
struct rpmdbMIObject_s {
PyObject_HEAD;
rpmdbObject *db;
rpmdbMatchIterator mi;
} ;
/** \ingroup python
*/
static PyObject *
rpmdbMINext(rpmdbMIObject * s, PyObject * args) {
rpmmi_Next(rpmmiObject * s, PyObject * args) {
/* XXX assume header? */
Header h;
hdrObject * ho;
if (!PyArg_ParseTuple (args, "")) return NULL;
if (!PyArg_ParseTuple (args, ":Next")) return NULL;
h = rpmdbNextIterator(s->mi);
if (!h) {
@ -73,18 +48,18 @@ rpmdbMINext(rpmdbMIObject * s, PyObject * args) {
/** \ingroup python
*/
static PyObject *
rpmdbMIpattern(rpmdbMIObject * s, PyObject * args) {
PyObject *index = NULL;
rpmmi_Pattern(rpmmiObject * s, PyObject * args) {
PyObject *TagN = NULL;
int type;
char * pattern;
int tag;
if (!PyArg_ParseTuple(args, "Ois", &index, &type, &pattern))
if (!PyArg_ParseTuple(args, "Ois:Pattern", &TagN, &type, &pattern))
return NULL;
if (index == NULL)
if (TagN == NULL)
tag = 0;
else if ((tag = tagNumFromPyObject (index)) == -1) {
else if ((tag = tagNumFromPyObject (TagN)) == -1) {
PyErr_SetString(PyExc_TypeError, "unknown tag type");
return NULL;
}
@ -98,21 +73,20 @@ rpmdbMIpattern(rpmdbMIObject * s, PyObject * args) {
/** \ingroup python
*/
static struct PyMethodDef rpmdbMIMethods[] = {
{"next", (PyCFunction) rpmdbMINext, 1 },
{"pattern", (PyCFunction) rpmdbMIpattern, 1 },
{NULL, NULL} /* sentinel */
static struct PyMethodDef rpmmi_methods[] = {
{"next", (PyCFunction) rpmmi_Next, METH_VARARGS,
"mi.next() -> hdr\n\
- Retrieve next header that matches.\n" },
{"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS,
"mi.pattern(TagN, mire_type, pattern)\n\
- Set a secondary match pattern on retrieved header tags\n" },
{NULL, NULL} /* sentinel */
};
/** \ingroup python
*/
static PyObject * rpmdbMIGetAttr (rpmdbObject *s, char *name) {
return Py_FindMethod (rpmdbMIMethods, (PyObject *) s, name);
}
/** \ingroup python
*/
static void rpmdbMIDealloc(rpmdbMIObject * s) {
static void rpmmi_dealloc(rpmmiObject * s)
{
if (s) {
s->mi = rpmdbFreeIterator(s->mi);
Py_DECREF (s->db);
@ -122,15 +96,27 @@ static void rpmdbMIDealloc(rpmdbMIObject * s) {
/** \ingroup python
*/
PyTypeObject rpmdbMIType = {
static PyObject * rpmmi_getattr (rpmdbObject *s, char *name)
{
return Py_FindMethod (rpmmi_methods, (PyObject *) s, name);
}
/**
*/
static char rpmmi_doc[] =
"";
/** \ingroup python
*/
PyTypeObject rpmmi_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"rpmdbMatchIterator", /* tp_name */
sizeof(rpmdbMIObject), /* tp_size */
"rpm.mi", /* tp_name */
sizeof(rpmmiObject), /* tp_size */
0, /* tp_itemsize */
(destructor) rpmdbMIDealloc, /* tp_dealloc */
(destructor) rpmmi_dealloc, /* tp_dealloc */
0, /* tp_print */
(getattrfunc) rpmdbMIGetAttr, /* tp_getattr */
(getattrfunc) rpmmi_getattr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
@ -144,7 +130,7 @@ PyTypeObject rpmdbMIType = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* tp_doc */
rpmmi_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
@ -152,7 +138,7 @@ PyTypeObject rpmdbMIType = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
rpmmi_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@ -171,7 +157,7 @@ PyTypeObject rpmdbMIType = {
/*@}*/
/** \ingroup python
* \class rpmdb
* \class rpm.db
* \brief A python rpmdb object represents an RPM database.
*
* Instances of the rpmdb object provide access to the records of a
@ -182,26 +168,29 @@ PyTypeObject rpmdbMIType = {
* The rpmdb class contains the following methods:
*
* - firstkey() Returns the index of the first record in the database.
* @deprecated Legacy, use rpmdbMatchIterator instead.
* @deprecated Use mi = db.match() instead.
*
* - nextkey(index) Returns the index of the next record after "index" in the
* database.
* @param index current rpmdb location
* @deprecated Legacy, use rpmdbMatchIterator instead.
* @deprecated Use hdr = mi.next() instead.
*
* - findbyfile(file) Returns a list of the indexes to records that own file
* "file".
* @param file absolute path to file
* @deprecated Use mi = db.match('basename') instead.
*
* - findbyname(name) Returns a list of the indexes to records for packages
* named "name".
* @param name package name
* @deprecated Use mi = db.match('name') instead.
*
* - findbyprovides(dep) Returns a list of the indexes to records for packages
* that provide "dep".
* @param dep provided dependency string
* @deprecated Use mi = db.match('providename') instead.
*
* To obtain a rpmdb object, the opendb function in the rpm module
* To obtain a db object, the opendb function in the rpm module
* must be called. The opendb function takes two optional arguments.
* The first optional argument is a boolean flag that specifies if the
* database is to be opened for read/write access or read-only access.
@ -213,33 +202,38 @@ PyTypeObject rpmdbMIType = {
* represents:
* \code
* import rpm
* rpmdb = rpm.opendb()
* index = rpmdb.firstkey()
* header = rpmdb[index]
* print header[rpm.RPMTAG_NAME]
* db = rpm.opendb()
* mi = db.match()
* h = mi.next()
* if h:
* print h[rpm.RPMTAG_NAME]
* \endcode
*
* To print all of the packages in the database that match a package
* name, the code will look like this:
* \code
* import rpm
* rpmdb = rpm.opendb()
* indexes = rpmdb.findbyname("foo")
* for index in indexes:
* header = rpmdb[index]
* print "%s-%s-%s" % (header[rpm.RPMTAG_NAME],
* header[rpm.RPMTAG_VERSION],
* header[rpm.RPMTAG_RELEASE])
* db = rpm.opendb()
* mi = db.match(rpm.RPMTAG_NAME, "foo")
* while 1:
* h = mi.next()
* if not h:
* break
* print "%s-%s-%s" % (h[rpm.RPMTAG_NAME],
* h[rpm.RPMTAG_VERSION],
* h[rpm.RPMTAG_RELEASE])
* \endcode
*/
/** \ingroup python
* \name Class: rpmdb
* \name Class: rpm.db
*/
/*@{*/
/**
*/
static PyObject * rpmdbFirst(rpmdbObject * s, PyObject * args) {
static PyObject * rpmdb_First(rpmdbObject * s, PyObject * args)
{
int first;
if (!PyArg_ParseTuple (args, "")) return NULL;
@ -276,7 +270,8 @@ static PyObject * rpmdbFirst(rpmdbObject * s, PyObject * args) {
/**
*/
static PyObject * rpmdbNext(rpmdbObject * s, PyObject * args) {
static PyObject * rpmdb_Next(rpmdbObject * s, PyObject * args)
{
int where;
if (!PyArg_ParseTuple (args, "i", &where)) return NULL;
@ -298,7 +293,8 @@ static PyObject * rpmdbNext(rpmdbObject * s, PyObject * args) {
/**
*/
static PyObject * handleDbResult(rpmdbMatchIterator mi) {
static PyObject * handleDbResult(rpmdbMatchIterator mi)
{
PyObject * list = PyList_New(0);
PyObject * o;
@ -315,7 +311,8 @@ static PyObject * handleDbResult(rpmdbMatchIterator mi) {
/**
*/
static PyObject * rpmdbByFile(rpmdbObject * s, PyObject * args) {
static PyObject * rpmdb_ByFile(rpmdbObject * s, PyObject * args)
{
char * str;
if (!PyArg_ParseTuple(args, "s", &str)) return NULL;
@ -325,7 +322,8 @@ static PyObject * rpmdbByFile(rpmdbObject * s, PyObject * args) {
/**
*/
static PyObject * rpmdbByName(rpmdbObject * s, PyObject * args) {
static PyObject * rpmdb_ByName(rpmdbObject * s, PyObject * args)
{
char * str;
if (!PyArg_ParseTuple(args, "s", &str)) return NULL;
@ -335,7 +333,8 @@ static PyObject * rpmdbByName(rpmdbObject * s, PyObject * args) {
/**
*/
static PyObject * rpmdbByProvides(rpmdbObject * s, PyObject * args) {
static PyObject * rpmdb_ByProvides(rpmdbObject * s, PyObject * args)
{
char * str;
if (!PyArg_ParseTuple(args, "s", &str)) return NULL;
@ -345,26 +344,27 @@ static PyObject * rpmdbByProvides(rpmdbObject * s, PyObject * args) {
/**
*/
static rpmdbMIObject *
py_rpmdbInitIterator (rpmdbObject * s, PyObject * args) {
PyObject *index = NULL;
static rpmmiObject *
rpmdb_InitIterator (rpmdbObject * s, PyObject * args)
{
PyObject *TagN = NULL;
char *key = NULL;
int len = 0, tag = -1;
rpmdbMIObject * mio;
rpmmiObject * mio;
if (!PyArg_ParseTuple(args, "|Ozi", &index, &key, &len))
if (!PyArg_ParseTuple(args, "|Ozi", &TagN, &key, &len))
return NULL;
if (index == NULL)
if (TagN == NULL)
tag = 0;
else if ((tag = tagNumFromPyObject (index)) == -1) {
else if ((tag = tagNumFromPyObject (TagN)) == -1) {
PyErr_SetString(PyExc_TypeError, "unknown tag type");
return NULL;
}
mio = (rpmdbMIObject *) PyObject_NEW(rpmdbMIObject, &rpmdbMIType);
mio = (rpmmiObject *) PyObject_NEW(rpmmiObject, &rpmmi_Type);
if (mio == NULL) {
PyErr_SetString(pyrpmError, "out of memory creating rpmdbMIObject");
PyErr_SetString(pyrpmError, "out of memory creating rpmmiObject");
return NULL;
}
@ -377,36 +377,28 @@ py_rpmdbInitIterator (rpmdbObject * s, PyObject * args) {
/**
*/
static struct PyMethodDef rpmdbMethods[] = {
{"firstkey", (PyCFunction) rpmdbFirst, 1 },
{"nextkey", (PyCFunction) rpmdbNext, 1 },
{"findbyfile", (PyCFunction) rpmdbByFile, 1 },
{"findbyname", (PyCFunction) rpmdbByName, 1 },
{"findbyprovides", (PyCFunction) rpmdbByProvides, 1 },
{"match", (PyCFunction) py_rpmdbInitIterator, 1 },
{NULL, NULL} /* sentinel */
static struct PyMethodDef rpmdb_methods[] = {
{"firstkey", (PyCFunction) rpmdb_First, METH_VARARGS,
NULL },
{"nextkey", (PyCFunction) rpmdb_Next, METH_VARARGS,
NULL },
{"findbyfile", (PyCFunction) rpmdb_ByFile, METH_VARARGS,
NULL },
{"findbyname", (PyCFunction) rpmdb_ByName, METH_VARARGS,
NULL },
{"findbyprovides", (PyCFunction) rpmdb_ByProvides, METH_VARARGS,
NULL },
{"match", (PyCFunction) rpmdb_InitIterator, METH_VARARGS,
"db.match([TagN, [key, [len]]]) -> mi\n\
- Create an rpm db match iterator.\n" },
{NULL, NULL} /* sentinel */
};
/**
*/
static PyObject * rpmdbGetAttr(rpmdbObject * s, char * name) {
return Py_FindMethod(rpmdbMethods, (PyObject * ) s, name);
}
/**
*/
static void rpmdbDealloc(rpmdbObject * s) {
s->offsets = _free(s->offsets);
if (s->db)
rpmdbClose(s->db);
PyMem_DEL(s);
}
#ifndef DYINGSOON /* XXX OK, when? */
/**
*/
static int
rpmdbLength(rpmdbObject * s) {
rpmdb_length(rpmdbObject * s)
{
rpmdbMatchIterator mi;
int count = 0;
@ -421,7 +413,8 @@ rpmdbLength(rpmdbObject * s) {
/**
*/
static hdrObject *
rpmdbSubscript(rpmdbObject * s, PyObject * key) {
rpmdb_subscript(rpmdbObject * s, PyObject * key)
{
int offset;
hdrObject * ho;
Header h;
@ -449,30 +442,49 @@ rpmdbSubscript(rpmdbObject * s, PyObject * key) {
/**
*/
static PyMappingMethods rpmdbAsMapping = {
(inquiry) rpmdbLength, /* mp_length */
(binaryfunc) rpmdbSubscript, /* mp_subscript */
static PyMappingMethods rpmdb_as_mapping = {
(inquiry) rpmdb_length, /* mp_length */
(binaryfunc) rpmdb_subscript, /* mp_subscript */
(objobjargproc)0, /* mp_ass_subscript */
};
#endif
/**
*/
PyTypeObject rpmdbType = {
static void rpmdb_dealloc(rpmdbObject * s) {
s->offsets = _free(s->offsets);
if (s->db)
rpmdbClose(s->db);
PyMem_DEL(s);
}
/**
*/
static PyObject * rpmdb_getattr(rpmdbObject * s, char * name) {
return Py_FindMethod(rpmdb_methods, (PyObject * ) s, name);
}
/**
*/
static char rpmdb_doc[] =
"";
/**
*/
PyTypeObject rpmdb_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"rpmdb", /* tp_name */
"rpm.db", /* tp_name */
sizeof(rpmdbObject), /* tp_size */
0, /* tp_itemsize */
(destructor) rpmdbDealloc, /* tp_dealloc */
(destructor) rpmdb_dealloc, /* tp_dealloc */
0, /* tp_print */
(getattrfunc) rpmdbGetAttr, /* tp_getattr */
(getattrfunc) rpmdb_getattr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
&rpmdbAsMapping, /* tp_as_mapping */
&rpmdb_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
@ -480,14 +492,15 @@ PyTypeObject rpmdbType = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
0, /* tp_doc */
rpmdb_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
rpmdb_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@ -500,6 +513,7 @@ PyTypeObject rpmdbType = {
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
#endif
};
rpmdb dbFromDb(rpmdbObject * db) {
@ -515,7 +529,7 @@ rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) {
if (!PyArg_ParseTuple(args, "|is", &forWrite, &root)) return NULL;
o = PyObject_NEW(rpmdbObject, &rpmdbType);
o = PyObject_NEW(rpmdbObject, &rpmdb_Type);
o->db = NULL;
o->offx = 0;
o->noffs = 0;

View File

@ -5,6 +5,10 @@
* \file python/db-py.h
*/
/** \ingroup python
*/
typedef struct rpmdbObject_s rpmdbObject;
/** \ingroup python
*/
struct rpmdbObject_s {
@ -17,10 +21,18 @@ struct rpmdbObject_s {
/** \ingroup python
*/
typedef struct rpmdbObject_s rpmdbObject;
typedef struct rpmmiObject_s rpmmiObject;
extern PyTypeObject rpmdbType;
PyTypeObject rpmdbMIType;
/** \ingroup python
*/
struct rpmmiObject_s {
PyObject_HEAD;
rpmdbMatchIterator mi;
rpmdbObject *db;
} ;
extern PyTypeObject rpmdb_Type;
extern PyTypeObject rpmmi_Type;
rpmdb dbFromDb(rpmdbObject * db);
rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args);

View File

@ -23,7 +23,7 @@
#include "debug.h"
/** \ingroup python
* \class header
* \class rpm.hdr
* \brief A python header object represents an RPM package header.
*
* All RPM packages have headers that provide metadata for the package.
@ -75,7 +75,7 @@
*/
/** \ingroup python
* \name Class: header
* \name Class: rpm.hdr
*/
/*@{*/
@ -532,27 +532,38 @@ static PyObject * hdrSprintf(hdrObject * s, PyObject * args) {
/** \ingroup python
*/
static struct PyMethodDef hdrMethods[] = {
{"keys", (PyCFunction) hdrKeyList, 1 },
{"unload", (PyCFunction) hdrUnload, METH_VARARGS|METH_KEYWORDS },
{"verifyFile", (PyCFunction) hdrVerifyFile, 1 },
{"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 },
{"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 },
{"fullFilelist", (PyCFunction) hdrFullFilelist, 1 },
{"rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS },
{"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS },
static struct PyMethodDef hdr_methods[] = {
{"keys", (PyCFunction) hdrKeyList, METH_VARARGS,
NULL },
{"unload", (PyCFunction) hdrUnload, METH_VARARGS|METH_KEYWORDS,
NULL },
{"verifyFile", (PyCFunction) hdrVerifyFile, METH_VARARGS,
NULL },
{"expandFilelist", (PyCFunction) hdrExpandFilelist,METH_VARARGS,
NULL },
{"compressFilelist",(PyCFunction) hdrCompressFilelist,METH_VARARGS,
NULL },
{"fullFilelist", (PyCFunction) hdrFullFilelist, METH_VARARGS,
NULL },
{"rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS,
NULL },
{"sprintf", (PyCFunction) hdrSprintf, METH_VARARGS,
NULL },
{"dsOfHeader", (PyCFunction)hdr_dsOfHeader, METH_VARARGS, NULL},
{"dsFromHeader", (PyCFunction)hdr_dsFromHeader, METH_VARARGS, NULL},
{"fiFromHeader", (PyCFunction)hdr_fiFromHeader, METH_VARARGS, NULL},
{"dsOfHeader", (PyCFunction)hdr_dsOfHeader, METH_VARARGS,
NULL},
{"dsFromHeader", (PyCFunction)hdr_dsFromHeader, METH_VARARGS,
NULL},
{"fiFromHeader", (PyCFunction)hdr_fiFromHeader, METH_VARARGS,
NULL},
{NULL, NULL} /* sentinel */
{NULL, NULL} /* sentinel */
};
/** \ingroup python
*/
static PyObject * hdr_getattr(hdrObject * s, char * name) {
return Py_FindMethod(hdrMethods, (PyObject * ) s, name);
return Py_FindMethod(hdr_methods, (PyObject * ) s, name);
}
/** \ingroup python
@ -748,12 +759,17 @@ static PyMappingMethods hdr_as_mapping = {
(objobjargproc)0, /* mp_ass_subscript */
};
/**
*/
static char hdr_doc[] =
"";
/** \ingroup python
*/
PyTypeObject hdr_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"header", /* tp_name */
"rpm.hdr", /* tp_name */
sizeof(hdrObject), /* tp_size */
0, /* tp_itemsize */
(destructor) hdr_dealloc, /* tp_dealloc */
@ -772,7 +788,7 @@ PyTypeObject hdr_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* tp_doc */
hdr_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
@ -780,7 +796,7 @@ PyTypeObject hdr_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
hdr_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */

178
python/rpmal-py.c Normal file
View File

@ -0,0 +1,178 @@
/** \ingroup python
* \file python/rpmal-py.c
*/
#include "system.h"
#include "Python.h"
#include <rpmlib.h>
#include "rpmps.h"
#include "rpmal.h"
#include "rpmal-py.h"
#include "rpmds-py.h"
#include "rpmfi-py.h"
#include "debug.h"
static PyObject *
rpmal_Debug(rpmalObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "i", &_rpmal_debug)) return NULL;
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
rpmal_Add(rpmalObject * s, PyObject * args)
{
rpmdsObject * dso;
rpmfiObject * fio;
PyObject * key;
alKey pkgKey;
if (!PyArg_ParseTuple(args, "iOO!O!:Add", &pkgKey, &key, &rpmds_Type, &dso, &rpmfi_Type, &fio))
return NULL;
/* XXX errors */
pkgKey = rpmalAdd(&s->al, pkgKey, key, dso->ds, fio->fi);
return Py_BuildValue("i", pkgKey);
}
static PyObject *
rpmal_Del(rpmalObject * s, PyObject * args)
{
alKey pkgKey;
if (!PyArg_ParseTuple(args, "i:Del", &pkgKey))
return NULL;
rpmalDel(s->al, pkgKey);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
rpmal_AddProvides(rpmalObject * s, PyObject * args)
{
rpmdsObject * dso;
alKey pkgKey;
if (!PyArg_ParseTuple(args, "iOO!O!:AddProvides", &pkgKey, &rpmds_Type, &dso))
return NULL;
rpmalAddProvides(s->al, pkgKey, dso->ds);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
rpmal_MakeIndex(rpmalObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, ":MakeIndex"))
return NULL;
rpmalMakeIndex(s->al);
Py_INCREF(Py_None);
return Py_None;
}
static struct PyMethodDef rpmal_methods[] = {
{"Debug", (PyCFunction)rpmal_Debug, METH_VARARGS,
NULL},
{"add", (PyCFunction)rpmal_Add, METH_VARARGS,
NULL},
{"delete", (PyCFunction)rpmal_Del, METH_VARARGS,
NULL},
{"addProvides",(PyCFunction)rpmal_AddProvides, METH_VARARGS,
NULL},
{"makeIndex",(PyCFunction)rpmal_MakeIndex, METH_VARARGS,
NULL},
{NULL, NULL} /* sentinel */
};
/* ---------- */
static void
rpmal_dealloc(rpmalObject * s)
{
if (s) {
s->al = rpmalFree(s->al);
PyMem_DEL(s);
}
}
static PyObject *
rpmal_getattr(rpmalObject * s, char * name)
{
return Py_FindMethod(rpmal_methods, (PyObject *)s, name);
}
/**
*/
static char rpmal_doc[] =
"";
PyTypeObject rpmal_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
"rpm.ds", /* tp_name */
sizeof(rpmalObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)rpmal_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)rpmal_getattr, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
rpmal_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
rpmal_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
#endif
};
/* ---------- */
rpmalObject *
rpmal_Wrap(rpmal al)
{
rpmalObject *s = PyObject_NEW(rpmalObject, &rpmal_Type);
if (s == NULL)
return NULL;
s->al = al;
return s;
}

17
python/rpmal-py.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef H_RPMAL_PY
#define H_RPMAL_PY
/** \ingroup python
* \file python/rpmal-py.h
*/
typedef struct rpmalObject_s {
PyObject_HEAD
rpmal al;
} rpmalObject;
extern PyTypeObject rpmal_Type;
rpmalObject * rpmal_Wrap(rpmal al);
#endif

View File

@ -26,49 +26,49 @@ rpmds_Debug(rpmdsObject * s, PyObject * args)
static PyObject *
rpmds_Count(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":Count")) return NULL;
return Py_BuildValue("i", rpmdsCount(s->ds));
}
static PyObject *
rpmds_Ix(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":Ix")) return NULL;
return Py_BuildValue("i", rpmdsIx(s->ds));
}
static PyObject *
rpmds_DNEVR(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":DNEVR")) return NULL;
return Py_BuildValue("s", rpmdsDNEVR(s->ds));
}
static PyObject *
rpmds_N(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":N")) return NULL;
return Py_BuildValue("s", rpmdsN(s->ds));
}
static PyObject *
rpmds_EVR(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":EVR")) return NULL;
return Py_BuildValue("s", rpmdsEVR(s->ds));
}
static PyObject *
rpmds_Flags(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":Flags")) return NULL;
return Py_BuildValue("i", rpmdsFlags(s->ds));
}
static PyObject *
rpmds_TagN(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":TagN")) return NULL;
return Py_BuildValue("i", rpmdsTagN(s->ds));
}
@ -118,7 +118,7 @@ rpmds_Iter(rpmdsObject * s)
static PyObject *
rpmds_Notify(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, ":Notify"))
return NULL;
Py_INCREF(Py_None);
return Py_None;
@ -127,7 +127,7 @@ rpmds_Notify(rpmdsObject * s, PyObject * args)
static PyObject *
rpmds_Problem(rpmdsObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, ":Problem"))
return NULL;
Py_INCREF(Py_None);
return Py_None;
@ -135,21 +135,33 @@ rpmds_Problem(rpmdsObject * s, PyObject * args)
#endif
static struct PyMethodDef rpmds_methods[] = {
{"Debug", (PyCFunction)rpmds_Debug, METH_VARARGS, NULL},
{"Count", (PyCFunction)rpmds_Count, METH_VARARGS, NULL},
{"Ix", (PyCFunction)rpmds_Ix, METH_VARARGS, NULL},
{"DNEVR", (PyCFunction)rpmds_DNEVR, METH_VARARGS, NULL},
{"N", (PyCFunction)rpmds_N, METH_VARARGS, NULL},
{"EVR", (PyCFunction)rpmds_EVR, METH_VARARGS, NULL},
{"Flags", (PyCFunction)rpmds_Flags, METH_VARARGS, NULL},
{"TagN", (PyCFunction)rpmds_TagN, METH_VARARGS, NULL},
{"Debug", (PyCFunction)rpmds_Debug, METH_VARARGS,
NULL},
{"Count", (PyCFunction)rpmds_Count, METH_VARARGS,
"ds.Count -> Count - Return no. of elements.\n" },
{"Ix", (PyCFunction)rpmds_Ix, METH_VARARGS,
"ds.Ix -> Ix - Return current element index.\n" },
{"DNEVR", (PyCFunction)rpmds_DNEVR, METH_VARARGS,
"ds.DNEVR -> DNEVR - Return current DNEVR.\n" },
{"N", (PyCFunction)rpmds_N, METH_VARARGS,
"ds.N -> N - Return current N.\n" },
{"EVR", (PyCFunction)rpmds_EVR, METH_VARARGS,
"ds.EVR -> EVR - Return current EVR.\n" },
{"Flags", (PyCFunction)rpmds_Flags, METH_VARARGS,
"ds.Flags -> Flags - Return current Flags.\n" },
{"TagN", (PyCFunction)rpmds_TagN, METH_VARARGS,
"ds.TagN -> TagN - Return current TagN.\n" },
#if Py_TPFLAGS_HAVE_ITER
{"next", (PyCFunction)rpmds_Next, METH_VARARGS, NULL},
{"iter", (PyCFunction)rpmds_Iter, METH_VARARGS, NULL},
{"next", (PyCFunction)rpmds_Next, METH_VARARGS,
NULL},
{"iter", (PyCFunction)rpmds_Iter, METH_VARARGS,
NULL},
#endif
#ifdef NOTYET
{"Notify", (PyCFunction)rpmds_Notify, METH_VARARGS, NULL},
{"Problem", (PyCFunction)rpmds_Problem, METH_VARARGS, NULL},
{"Notify", (PyCFunction)rpmds_Notify, METH_VARARGS,
NULL},
{"Problem", (PyCFunction)rpmds_Problem, METH_VARARGS,
NULL},
#endif
{NULL, NULL} /* sentinel */
};
@ -210,10 +222,15 @@ static PyMappingMethods rpmds_as_mapping = {
(objobjargproc)0, /* mp_ass_subscript */
};
/**
*/
static char rpmds_doc[] =
"";
PyTypeObject rpmds_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
"rpmds", /* tp_name */
"rpm.ds", /* tp_name */
sizeof(rpmdsObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@ -233,7 +250,7 @@ PyTypeObject rpmds_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* tp_doc */
rpmds_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
@ -241,7 +258,7 @@ PyTypeObject rpmds_Type = {
0, /* tp_weaklistoffset */
(getiterfunc)rpmds_Iter, /* tp_iter */
(iternextfunc)rpmds_Next, /* tp_iternext */
0, /* tp_methods */
rpmds_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@ -282,7 +299,7 @@ rpmds_Single(PyObject * s, PyObject * args)
const char * EVR = NULL;
int Flags = 0;
if (!PyArg_ParseTuple(args, "is|si", &tagN, &N, &EVR, &Flags))
if (!PyArg_ParseTuple(args, "is|si:Single", &tagN, &N, &EVR, &Flags))
return NULL;
return rpmds_Wrap( rpmdsSingle(tagN, N, EVR, Flags) );
}
@ -294,7 +311,7 @@ hdr_dsFromHeader(PyObject * s, PyObject * args)
int tagN = RPMTAG_REQUIRENAME;
int scareMem = 0;
if (!PyArg_ParseTuple(args, "O!|i", &hdr_Type, &ho, &tagN))
if (!PyArg_ParseTuple(args, "O!|i:dsFromHeader", &hdr_Type, &ho, &tagN))
return NULL;
return rpmds_Wrap( rpmdsNew(hdrGetHeader(ho), tagN, scareMem) );
}
@ -306,7 +323,7 @@ hdr_dsOfHeader(PyObject * s, PyObject * args)
int tagN = RPMTAG_PROVIDENAME;
int Flags = RPMSENSE_EQUAL;
if (!PyArg_ParseTuple(args, "O!", &hdr_Type, &ho))
if (!PyArg_ParseTuple(args, "O!:dsOfHeader", &hdr_Type, &ho))
return NULL;
return rpmds_Wrap( rpmdsThis(hdrGetHeader(ho), tagN, Flags) );
}

View File

@ -5,21 +5,35 @@
* \file python/rpmds-py.h
*/
/**
*/
typedef struct rpmdsObject_s {
PyObject_HEAD
rpmds ds;
} rpmdsObject;
/**
*/
extern PyTypeObject rpmds_Type;
/**
*/
rpmds dsFromDs(rpmdsObject * ds);
/**
*/
rpmdsObject * rpmds_Wrap(rpmds ds);
/**
*/
rpmdsObject * rpmds_Single(PyObject * s, PyObject * args);
/**
*/
rpmdsObject * hdr_dsFromHeader(PyObject * s, PyObject * args);
/**
*/
rpmdsObject * hdr_dsOfHeader(PyObject * s, PyObject * args);
#endif

View File

@ -25,77 +25,77 @@ rpmfi_Debug(rpmfiObject * s, PyObject * args)
static PyObject *
rpmfi_FC(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FC")) return NULL;
return Py_BuildValue("i", rpmfiFC(s->fi));
}
static PyObject *
rpmfi_FX(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FX")) return NULL;
return Py_BuildValue("i", rpmfiFX(s->fi));
}
static PyObject *
rpmfi_DC(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":DC")) return NULL;
return Py_BuildValue("i", rpmfiDC(s->fi));
}
static PyObject *
rpmfi_DX(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":DX")) return NULL;
return Py_BuildValue("i", rpmfiDX(s->fi));
}
static PyObject *
rpmfi_BN(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":BN")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiBN(s->fi)));
}
static PyObject *
rpmfi_DN(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":DN")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiDN(s->fi)));
}
static PyObject *
rpmfi_FN(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FN")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiFN(s->fi)));
}
static PyObject *
rpmfi_FFlags(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FFlags")) return NULL;
return Py_BuildValue("i", rpmfiFFlags(s->fi));
}
static PyObject *
rpmfi_VFlags(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":VFlags")) return NULL;
return Py_BuildValue("i", rpmfiVFlags(s->fi));
}
static PyObject *
rpmfi_FMode(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FMode")) return NULL;
return Py_BuildValue("i", rpmfiFMode(s->fi));
}
static PyObject *
rpmfi_FState(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FState")) return NULL;
return Py_BuildValue("i", rpmfiFState(s->fi));
}
@ -108,7 +108,7 @@ rpmfi_MD5(rpmfiObject * s, PyObject * args)
char * t;
int i;
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":MD5")) return NULL;
md5 = rpmfiMD5(s->fi);
for (i = 0, t = fmd5; i < 16; i++, t += 2)
sprintf(t, "%02x", md5[i]);
@ -119,42 +119,42 @@ rpmfi_MD5(rpmfiObject * s, PyObject * args)
static PyObject *
rpmfi_FLink(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FLink")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiFLink(s->fi)));
}
static PyObject *
rpmfi_FSize(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FSize")) return NULL;
return Py_BuildValue("i", rpmfiFSize(s->fi));
}
static PyObject *
rpmfi_FRdev(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FRdev")) return NULL;
return Py_BuildValue("i", rpmfiFRdev(s->fi));
}
static PyObject *
rpmfi_FMtime(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FMtime")) return NULL;
return Py_BuildValue("i", rpmfiFMtime(s->fi));
}
static PyObject *
rpmfi_FUser(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FUser")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiFUser(s->fi)));
}
static PyObject *
rpmfi_FGroup(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":FGroup")) return NULL;
return Py_BuildValue("s", xstrdup(rpmfiFGroup(s->fi)));
}
@ -196,7 +196,7 @@ rpmfi_Iter(rpmfiObject * s, PyObject * args)
static PyObject *
rpmfi_NextD(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, ":NextD"))
return NULL;
Py_INCREF(Py_None);
return Py_None;
@ -205,7 +205,7 @@ rpmfi_NextD(rpmfiObject * s, PyObject * args)
static PyObject *
rpmfi_InitD(rpmfiObject * s, PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, ":InitD"))
return NULL;
Py_INCREF(Py_None);
return Py_None;
@ -213,32 +213,55 @@ rpmfi_InitD(rpmfiObject * s, PyObject * args)
#endif
static struct PyMethodDef rpmfi_methods[] = {
{"Debug", (PyCFunction)rpmfi_Debug, METH_VARARGS, NULL},
{"FC", (PyCFunction)rpmfi_FC, METH_VARARGS, NULL},
{"FX", (PyCFunction)rpmfi_FX, METH_VARARGS, NULL},
{"DC", (PyCFunction)rpmfi_DC, METH_VARARGS, NULL},
{"DX", (PyCFunction)rpmfi_DX, METH_VARARGS, NULL},
{"BN", (PyCFunction)rpmfi_BN, METH_VARARGS, NULL},
{"DN", (PyCFunction)rpmfi_DN, METH_VARARGS, NULL},
{"FN", (PyCFunction)rpmfi_FN, METH_VARARGS, NULL},
{"FFlags", (PyCFunction)rpmfi_FFlags, METH_VARARGS, NULL},
{"VFlags", (PyCFunction)rpmfi_VFlags, METH_VARARGS, NULL},
{"FMode", (PyCFunction)rpmfi_FMode, METH_VARARGS, NULL},
{"FState", (PyCFunction)rpmfi_FState, METH_VARARGS, NULL},
{"MD5", (PyCFunction)rpmfi_MD5, METH_VARARGS, NULL},
{"FLink", (PyCFunction)rpmfi_FLink, METH_VARARGS, NULL},
{"FSize", (PyCFunction)rpmfi_FSize, METH_VARARGS, NULL},
{"FRdev", (PyCFunction)rpmfi_FRdev, METH_VARARGS, NULL},
{"FMtime", (PyCFunction)rpmfi_FMtime, METH_VARARGS, NULL},
{"FUser", (PyCFunction)rpmfi_FUser, METH_VARARGS, NULL},
{"FGroup", (PyCFunction)rpmfi_FGroup, METH_VARARGS, NULL},
{"Debug", (PyCFunction)rpmfi_Debug, METH_VARARGS,
NULL},
{"FC", (PyCFunction)rpmfi_FC, METH_VARARGS,
NULL},
{"FX", (PyCFunction)rpmfi_FX, METH_VARARGS,
NULL},
{"DC", (PyCFunction)rpmfi_DC, METH_VARARGS,
NULL},
{"DX", (PyCFunction)rpmfi_DX, METH_VARARGS,
NULL},
{"BN", (PyCFunction)rpmfi_BN, METH_VARARGS,
NULL},
{"DN", (PyCFunction)rpmfi_DN, METH_VARARGS,
NULL},
{"FN", (PyCFunction)rpmfi_FN, METH_VARARGS,
NULL},
{"FFlags", (PyCFunction)rpmfi_FFlags, METH_VARARGS,
NULL},
{"VFlags", (PyCFunction)rpmfi_VFlags, METH_VARARGS,
NULL},
{"FMode", (PyCFunction)rpmfi_FMode, METH_VARARGS,
NULL},
{"FState", (PyCFunction)rpmfi_FState, METH_VARARGS,
NULL},
{"MD5", (PyCFunction)rpmfi_MD5, METH_VARARGS,
NULL},
{"FLink", (PyCFunction)rpmfi_FLink, METH_VARARGS,
NULL},
{"FSize", (PyCFunction)rpmfi_FSize, METH_VARARGS,
NULL},
{"FRdev", (PyCFunction)rpmfi_FRdev, METH_VARARGS,
NULL},
{"FMtime", (PyCFunction)rpmfi_FMtime, METH_VARARGS,
NULL},
{"FUser", (PyCFunction)rpmfi_FUser, METH_VARARGS,
NULL},
{"FGroup", (PyCFunction)rpmfi_FGroup, METH_VARARGS,
NULL},
#if Py_TPFLAGS_HAVE_ITER
{"next", (PyCFunction)rpmfi_Next, METH_VARARGS, NULL},
{"iter", (PyCFunction)rpmfi_Iter, METH_VARARGS, NULL},
{"next", (PyCFunction)rpmfi_Next, METH_VARARGS,
NULL},
{"iter", (PyCFunction)rpmfi_Iter, METH_VARARGS,
NULL},
#endif
#ifdef NOTYET
{"NextD", (PyCFunction)rpmfi_NextD, METH_VARARGS, NULL},
{"InitD", (PyCFunction)rpmfi_InitD, METH_VARARGS, NULL},
{"NextD", (PyCFunction)rpmfi_NextD, METH_VARARGS,
NULL},
{"InitD", (PyCFunction)rpmfi_InitD, METH_VARARGS,
NULL},
#endif
{NULL, NULL} /* sentinel */
};
@ -299,10 +322,15 @@ static PyMappingMethods rpmfi_as_mapping = {
(objobjargproc)0, /* mp_ass_subscript */
};
/**
*/
static char rpmfi_doc[] =
"";
PyTypeObject rpmfi_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
"rpmfi", /* tp_name */
"rpm.fi", /* tp_name */
sizeof(rpmfiObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@ -322,7 +350,7 @@ PyTypeObject rpmfi_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* tp_doc */
rpmfi_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
@ -330,7 +358,7 @@ PyTypeObject rpmfi_Type = {
0, /* tp_weaklistoffset */
(getiterfunc)rpmfi_Iter, /* tp_iter */
(iternextfunc)rpmfi_Next, /* tp_iternext */
0, /* tp_methods */
rpmfi_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@ -368,7 +396,7 @@ hdr_fiFromHeader(PyObject * s, PyObject * args)
{
hdrObject * ho;
if (!PyArg_ParseTuple(args, "O!", &hdr_Type, &ho))
if (!PyArg_ParseTuple(args, "O!:fiFromHeader", &hdr_Type, &ho))
return NULL;
return rpmfi_Wrap( rpmfiNew(NULL, NULL, hdrGetHeader(ho), RPMTAG_BASENAMES, 0) );
}

View File

@ -33,6 +33,7 @@
#include "db-py.h"
#include "header-py.h"
#include "rpmal-py.h"
#include "rpmds-py.h"
#include "rpmfi-py.h"
#include "rpmts-py.h"
@ -46,9 +47,6 @@ extern int _rpmio_debug;
#define PyObject_HEAD int _PyObjectHead
#endif
/* from lib/misc.c */
int rpmvercmp(const char * one, const char * two);
/** \ingroup python
* \name Module: rpm
*/
@ -56,7 +54,8 @@ int rpmvercmp(const char * one, const char * two);
/**
*/
static PyObject * doAddMacro(PyObject * self, PyObject * args) {
static PyObject * doAddMacro(PyObject * self, PyObject * args)
{
char * name, * val;
if (!PyArg_ParseTuple(args, "ss", &name, &val))
@ -70,7 +69,8 @@ static PyObject * doAddMacro(PyObject * self, PyObject * args) {
/**
*/
static PyObject * doDelMacro(PyObject * self, PyObject * args) {
static PyObject * doDelMacro(PyObject * self, PyObject * args)
{
char * name;
if (!PyArg_ParseTuple(args, "s", &name))
@ -84,7 +84,8 @@ static PyObject * doDelMacro(PyObject * self, PyObject * args) {
/**
*/
static PyObject * archScore(PyObject * self, PyObject * args) {
static PyObject * archScore(PyObject * self, PyObject * args)
{
char * arch;
int score;
@ -98,7 +99,8 @@ static PyObject * archScore(PyObject * self, PyObject * args) {
/**
*/
static int psGetArchScore(Header h) {
static int psGetArchScore(Header h)
{
void * pkgArch;
int type, count;
@ -111,7 +113,8 @@ static int psGetArchScore(Header h) {
/**
*/
static int pkgCompareVer(void * first, void * second) {
static int pkgCompareVer(void * first, void * second)
{
struct packageInfo ** a = first;
struct packageInfo ** b = second;
int ret, score1, score2;
@ -133,7 +136,8 @@ static int pkgCompareVer(void * first, void * second) {
/**
*/
static void pkgSort(struct pkgSet * psp) {
static void pkgSort(struct pkgSet * psp)
{
int i;
char *name;
@ -166,7 +170,8 @@ static void pkgSort(struct pkgSet * psp) {
/**
*/
static PyObject * findUpgradeSet(PyObject * self, PyObject * args) {
static PyObject * findUpgradeSet(PyObject * self, PyObject * args)
{
PyObject * hdrList, * result;
char * root = "/";
int i;
@ -217,7 +222,8 @@ static PyObject * findUpgradeSet(PyObject * self, PyObject * args) {
/**
*/
static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
static PyObject * rpmInitDB(PyObject * self, PyObject * args)
{
char *root;
int forWrite = 0;
@ -241,7 +247,8 @@ static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
/**
*/
static PyObject * errorCB = NULL, * errorData = NULL;
static PyObject * errorCB = NULL;
static PyObject * errorData = NULL;
/**
*/
@ -264,7 +271,8 @@ static void errorcb (void)
/**
*/
static PyObject * errorSetCallback (PyObject * self, PyObject * args) {
static PyObject * errorSetCallback (PyObject * self, PyObject * args)
{
PyObject *newCB = NULL, *newData = NULL;
if (!PyArg_ParseTuple(args, "O|O", &newCB, &newData)) return NULL;
@ -304,13 +312,15 @@ static PyObject * errorSetCallback (PyObject * self, PyObject * args) {
/**
*/
static PyObject * errorString (PyObject * self, PyObject * args) {
static PyObject * errorString (PyObject * self, PyObject * args)
{
return PyString_FromString(rpmErrorString ());
}
/**
*/
static PyObject * checkSig (PyObject * self, PyObject * args) {
static PyObject * checkSig (PyObject * self, PyObject * args)
{
char * filename;
int flags;
int rc = 255;
@ -333,7 +343,10 @@ static PyObject * checkSig (PyObject * self, PyObject * args) {
return Py_BuildValue("i", rc);
}
static PyObject * setVerbosity (PyObject * self, PyObject * args) {
/**
*/
static PyObject * setVerbosity (PyObject * self, PyObject * args)
{
int level;
if (!PyArg_ParseTuple(args, "i", &level))
@ -368,7 +381,8 @@ static FDlist *fdtail = NULL;
/**
*/
static int closeCallback(FILE * f) {
static int closeCallback(FILE * f)
{
FDlist *node, *last;
printf ("close callback on %p\n", f);
@ -399,7 +413,8 @@ static int closeCallback(FILE * f) {
/**
*/
static PyObject * doFopen(PyObject * self, PyObject * args) {
static PyObject * doFopen(PyObject * self, PyObject * args)
{
char * path, * mode;
FDlist *node;
@ -450,50 +465,67 @@ static PyObject * doFopen(PyObject * self, PyObject * args) {
/**
*/
static PyMethodDef rpmModuleMethods[] = {
{ "TransactionSet", (PyCFunction) rpmts_Create, METH_VARARGS, NULL },
{ "addMacro", (PyCFunction) doAddMacro, METH_VARARGS, NULL },
{ "delMacro", (PyCFunction) doDelMacro, METH_VARARGS, NULL },
{ "archscore", (PyCFunction) archScore, METH_VARARGS, NULL },
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, NULL },
{ "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL },
{ "rebuilddb", (PyCFunction) rebuildDB, METH_VARARGS, NULL },
{ "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS, NULL },
{ "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS, NULL },
{ "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS, NULL },
{ "errorSetCallback", (PyCFunction) errorSetCallback, METH_VARARGS, NULL },
{ "errorString", (PyCFunction) errorString, METH_VARARGS, NULL },
{ "versionCompare", (PyCFunction) versionCompare, METH_VARARGS, NULL },
{ "labelCompare", (PyCFunction) labelCompare, METH_VARARGS, NULL },
{ "checksig", (PyCFunction) checkSig, METH_VARARGS, NULL },
{ "Fopen", (PyCFunction) doFopen, METH_VARARGS, NULL },
{ "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS, NULL },
{ "rpmdsSingle", (PyCFunction) rpmds_Single, METH_VARARGS, NULL },
{ "TransactionSet", (PyCFunction) rpmts_Create, METH_VARARGS,
"rpm.TransactionSet([rootDir, [db]]) -> ts\n\
- Create a transaction set.\n" },
{ "addMacro", (PyCFunction) doAddMacro, METH_VARARGS,
NULL },
{ "delMacro", (PyCFunction) doDelMacro, METH_VARARGS,
NULL },
{ "archscore", (PyCFunction) archScore, METH_VARARGS,
NULL },
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS,
NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS,
NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS,
NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS,
NULL },
{ "initdb", (PyCFunction) rpmInitDB, METH_VARARGS,
NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS,
NULL },
{ "rebuilddb", (PyCFunction) rebuildDB, METH_VARARGS,
NULL },
{ "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS,
NULL },
{ "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS,
NULL },
{ "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS,
NULL },
{ "errorSetCallback", (PyCFunction) errorSetCallback, METH_VARARGS,
NULL },
{ "errorString", (PyCFunction) errorString, METH_VARARGS,
NULL },
{ "versionCompare", (PyCFunction) versionCompare, METH_VARARGS,
NULL },
{ "labelCompare", (PyCFunction) labelCompare, METH_VARARGS,
NULL },
{ "checksig", (PyCFunction) checkSig, METH_VARARGS,
NULL },
{ "Fopen", (PyCFunction) doFopen, METH_VARARGS,
NULL },
{ "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS,
NULL },
{ "dsSingle", (PyCFunction) rpmds_Single, METH_VARARGS,
"rpm.dsSingle(TagN, N, [EVR, [Flags]] -> ds\n\
- Create a single element dependency set.\n" },
{ NULL }
} ;
void initrpm(void); /* XXX eliminate gcc warning */
/**
*/
void initrpm(void) {
void initrpm(void)
{
PyObject * d, *o, * tag = NULL, * dict;
int i;
const struct headerSprintfExtension_s * extensions = rpmHeaderFormats;
struct headerSprintfExtension_s * ext;
PyObject * m = Py_InitModule("rpm", rpmModuleMethods);
hdr_Type.ob_type = &PyType_Type;
rpmds_Type.ob_type = &PyType_Type;
rpmfi_Type.ob_type = &PyType_Type;
rpmdbMIType.ob_type = &PyType_Type;
rpmdbType.ob_type = &PyType_Type;
rpmts_Type.ob_type = &PyType_Type;
PyObject * m;
m = Py_InitModule("rpm", rpmModuleMethods);
if (m == NULL)
return;
@ -501,9 +533,43 @@ void initrpm(void) {
d = PyModule_GetDict(m);
#ifdef HACK
pyrpmError = PyString_FromString("rpm.error");
PyDict_SetItemString(d, "error", pyrpmError);
Py_DECREF(pyrpmError);
#else
pyrpmError = PyErr_NewException("rpm.error", NULL, NULL);
if (pyrpmError != NULL)
PyDict_SetItemString(d, "error", pyrpmError);
#endif
rpmal_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmal_Type);
PyModule_AddObject(m, "al", (PyObject *) &rpmal_Type);
rpmdb_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmdb_Type);
PyModule_AddObject(m, "db", (PyObject *) &rpmdb_Type);
rpmds_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmds_Type);
PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
rpmfi_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmfi_Type);
PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type);
hdr_Type.ob_type = &PyType_Type;
Py_INCREF(&hdr_Type);
PyModule_AddObject(m, "hdr", (PyObject *) &hdr_Type);
rpmmi_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmmi_Type);
PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type);
rpmts_Type.ob_type = &PyType_Type;
Py_INCREF(&rpmts_Type);
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
dict = PyDict_New();

View File

@ -19,19 +19,19 @@
#include "debug.h"
/** \ingroup python
* \name Class: rpmtrans
* \class rpmtrans
* \brief A python rpmtrans object represents an RPM transaction set.
* \name Class: rpm.ts
* \class rpm.ts
* \brief A python rpm.ts object represents an RPM transaction set.
*
* The transaction set is the workhorse of RPM. It performs the
* installation and upgrade of packages. The rpmtrans object is
* installation and upgrade of packages. The rpm.ts object is
* instantiated by the TransactionSet function in the rpm module.
*
* The TransactionSet function takes two optional arguments. The first
* argument is the root path, the second is an open database to perform
* the transaction set upon.
*
* A rpmtrans object has the following methods:
* A rpm.ts object has the following methods:
*
* - add(header,data,mode) Add a binary package to a transaction set.
* @param header the header to be added
@ -125,15 +125,18 @@ rpmts_Add(rpmtsObject * s, PyObject * args)
PyObject * key;
char * how = NULL;
int isUpgrade = 0;
PyObject * hObj;
if (!PyArg_ParseTuple(args, "OO|s", &h, &key, &how)) return NULL;
hObj = (PyObject *) h;
if (hObj->ob_type != &hdr_Type) {
PyErr_SetString(PyExc_TypeError, "bad type for header argument");
if (!PyArg_ParseTuple(args, "O!O|s:Add", &hdr_Type, &h, &key, &how))
return NULL;
#ifdef DYING
{ PyObject * hObj = (PyObject *) h;
if (hObj->ob_type != &hdr_Type) {
PyErr_SetString(PyExc_TypeError, "bad type for header argument");
return NULL;
}
}
#endif
if (how && strcmp(how, "a") && strcmp(how, "u") && strcmp(how, "i")) {
PyErr_SetString(PyExc_TypeError, "how argument must be \"u\", \"a\", or \"i\"");
@ -164,7 +167,7 @@ rpmts_Remove(rpmtsObject * s, PyObject * args)
int count;
rpmdbMatchIterator mi;
if (!PyArg_ParseTuple(args, "s", &name))
if (!PyArg_ParseTuple(args, "s:Remove", &name))
return NULL;
/* XXX: Copied hack from ../lib/rpminstall.c, rpmErase() */
@ -200,7 +203,7 @@ rpmts_Check(rpmtsObject * s, PyObject * args)
int allSuggestions = 0;
int xx;
if (!PyArg_ParseTuple(args, "|i", &allSuggestions)) return NULL;
if (!PyArg_ParseTuple(args, "|i:Check", &allSuggestions)) return NULL;
xx = rpmtsCheck(s->ts);
ps = rpmtsGetProblems(s->ts);
@ -280,7 +283,7 @@ rpmts_Order(rpmtsObject * s, PyObject * args)
{
int xx;
if (!PyArg_ParseTuple(args, "")) return NULL;
if (!PyArg_ParseTuple(args, ":Order")) return NULL;
xx = rpmtsOrder(s->ts);
@ -297,6 +300,8 @@ rpmts_GetKeys(rpmtsObject * s, PyObject * args)
int num, i;
PyObject *tuple;
if (!PyArg_ParseTuple(args, ":GetKeys")) return NULL;
rpmtsGetKeys(s->ts, &data, &num);
if (data == NULL) {
Py_INCREF(Py_None);
@ -380,7 +385,7 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args)
rpmps ps;
struct rpmtsCallbackType_s cbInfo;
if (!PyArg_ParseTuple(args, "iiOO", &flags, &ignoreSet, &cbInfo.cb,
if (!PyArg_ParseTuple(args, "iiOO:Run", &flags, &ignoreSet, &cbInfo.cb,
&cbInfo.data))
return NULL;
@ -423,25 +428,26 @@ static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args)
/** \ingroup python
*/
static struct PyMethodDef rpmtsMethods[] = {
{"add", (PyCFunction) rpmts_Add, 1 },
{"remove", (PyCFunction) rpmts_Remove, 1 },
{"depcheck", (PyCFunction) rpmts_Check, 1 },
{"order", (PyCFunction) rpmts_Order, 1 },
{"getKeys", (PyCFunction) rpmts_GetKeys, 1 },
{"run", (PyCFunction) rpmts_Run, 1 },
static struct PyMethodDef rpmts_methods[] = {
{"add", (PyCFunction) rpmts_Add, METH_VARARGS,
NULL },
{"remove", (PyCFunction) rpmts_Remove, METH_VARARGS,
NULL },
{"depcheck", (PyCFunction) rpmts_Check, METH_VARARGS,
NULL },
{"order", (PyCFunction) rpmts_Order, METH_VARARGS,
NULL },
{"getKeys", (PyCFunction) rpmts_GetKeys, METH_VARARGS,
NULL },
{"run", (PyCFunction) rpmts_Run, METH_VARARGS,
NULL },
{NULL, NULL} /* sentinel */
};
/** \ingroup python
*/
static PyObject * rpmts_getattr(rpmtsObject * o, char * name) {
return Py_FindMethod(rpmtsMethods, (PyObject *) o, name);
}
/** \ingroup python
*/
static void rpmts_dealloc(PyObject * o) {
static void rpmts_dealloc(PyObject * o)
{
rpmtsObject * trans = (void *) o;
trans->ts->rdb = NULL; /* XXX HACK: avoid rpmdb close/free */
@ -458,8 +464,15 @@ static void rpmts_dealloc(PyObject * o) {
/** \ingroup python
*/
static int rpmts_setattr(rpmtsObject * o, char * name,
PyObject * val) {
static PyObject * rpmts_getattr(rpmtsObject * o, char * name)
{
return Py_FindMethod(rpmts_methods, (PyObject *) o, name);
}
/** \ingroup python
*/
static int rpmts_setattr(rpmtsObject * o, char * name, PyObject * val)
{
int i;
if (!strcmp(name, "scriptFd")) {
@ -479,6 +492,11 @@ static int rpmts_setattr(rpmtsObject * o, char * name,
return 0;
}
/**
*/
static char rpmts_doc[] =
"";
/** \ingroup python
*/
PyTypeObject rpmts_Type = {
@ -503,14 +521,15 @@ PyTypeObject rpmts_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
0, /* tp_doc */
rpmts_doc, /* tp_doc */
#if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
rpmts_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@ -523,6 +542,7 @@ PyTypeObject rpmts_Type = {
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
#endif
};
/**
@ -534,11 +554,14 @@ rpmts_Create(PyObject * self, PyObject * args)
rpmdbObject * db = NULL;
char * rootDir = "/";
if (!PyArg_ParseTuple(args, "|sO", &rootDir, &db)) return NULL;
if (db && ((PyObject *) db)->ob_type != &rpmdbType) {
if (!PyArg_ParseTuple(args, "|sO!:Create", &rootDir, &rpmdb_Type, &db))
return NULL;
#ifdef DYING
if (db && ((PyObject *) db)->ob_type != &rpmdb_Type) {
PyErr_SetString(PyExc_TypeError, "bad type for database argument");
return NULL;
}
#endif
o = (void *) PyObject_NEW(rpmtsObject, &rpmts_Type);