summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-08-05 21:46:50 +0000
committerjbj <devnull@localhost>2002-08-05 21:46:50 +0000
commit5211039a20762b4a50c006ccf79666bff34967c2 (patch)
tree2e001628b1b88572c14d0b5975535985ef1b01ff
parentbd5ee7affaa5f350c03fba20952b7a16e1311c4e (diff)
downloadrpm-5211039a20762b4a50c006ccf79666bff34967c2.tar.gz
rpm-5211039a20762b4a50c006ccf79666bff34967c2.tar.bz2
rpm-5211039a20762b4a50c006ccf79666bff34967c2.zip
- python: the death of rpmdb-py.[ch], use ts.fooDB() methods instead.
- python: the death of rpm.headerFromPackage(), use ts.hdrFromFdno(). - python: permit direct ts.dbMatch() python iterations. - python: the death of rpm.checksig(), use ts.hdrFromFdno() instead. CVS patchset: 5603 CVS date: 2002/08/05 21:46:50
-rw-r--r--CHANGES6
-rw-r--r--python/Makefile.am2
-rw-r--r--python/header-py.c60
-rw-r--r--python/header-py.h2
-rw-r--r--python/rpmmi-py.c72
-rw-r--r--python/rpmmodule.c74
-rw-r--r--python/rpmrc-py.c2
-rw-r--r--python/rpmts-py.c12
-rw-r--r--rpm.spec.in6
9 files changed, 52 insertions, 184 deletions
diff --git a/CHANGES b/CHANGES
index a246f2010..77458f69b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -217,9 +217,13 @@
- python: bare bones rollback bindings.
- python: enable threads on callbacks and longish rpmlib calls.
- python: expose RPMTAG_SOURCEPACKAGE to identify source headers.
- - python: eliminate headerFromPackage() tuple return, deprecated.
+ - python: eliminate rpm.headerFromPackage() tuple return, deprecated.
- python: add ts.hdrFromFdno(fdno) method.
- fix: check for lead magic, better error message on failure (#69751).
+ - python: the death of rpmdb-py.[ch], use ts.fooDB() methods instead.
+ - python: the death of rpm.headerFromPackage(), use ts.hdrFromFdno().
+ - python: permit direct ts.dbMatch() python iterations.
+ - python: the death of rpm.checksig(), use ts.hdrFromFdno() instead.
4.0.3 -> 4.0.4:
- solaris: translate i86pc to i386 (#57182).
diff --git a/python/Makefile.am b/python/Makefile.am
index ac12b90c6..22a79ca4c 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -66,7 +66,7 @@ poptmodule.so$(EXEEXT): $(poptmodule_so_OBJECTS)
# rpmrc-py.c rpmte-py.c rpmts-py.c
# rpmmodule.c header-py.c
splint_srcs = hash.c upgrade.c \
- rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfi-py.c rpmmi-py.c \
+ rpmal-py.c rpmds-py.c rpmfd-py.c rpmfi-py.c rpmmi-py.c \
rpmrc-py.c rpmte-py.c rpmts-py.c
.PHONY: lclint
diff --git a/python/header-py.c b/python/header-py.c
index 978fbc1a8..422bc36e7 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -33,16 +33,21 @@
* Header objects can be returned by database queries or loaded from a
* binary package on disk.
*
- * The headerFromPackage function returns the package header from a
- * package on disk.
+ * The ts.hdrFromFdno() function returns the package header from a
+ * package on disk, verifying package signatures and digests of the
+ * package while reading.
+ *
+ * Note: The older method rpm.headerFromPackage() which has been replaced
+ * by ts.hdrFromFdno() used to return a (hdr, isSource) tuple.
*
- * Note: rpm.headerFromPackage() used to return a (hdr, isSource) tuple.
* If you need to distinguish source/binary headers, do:
* \code
* import os, rpm
*
- * fd = os.open("/tmp/foo-1.0-1.i386.rpm", os.O_RDONLY)
- * hdr = rpm.headerFromPackage(fd)
+ * ts = rpm.TranssactionSet()
+ * fdno = os.open("/tmp/foo-1.0-1.i386.rpm", os.O_RDONLY)
+ * hdr = ts.hdrFromFdno(fdno)
+ * os.close(fdno)
* if hdr[rpm.RPMTAG_SOURCEPACKAGE]:
* print "header is from a source package"
* else:
@@ -72,7 +77,7 @@
* print hdr['release']
* \endcode
*
- * This method of access is a bit slower because the name must be
+ * This method of access is a teensy bit slower because the name must be
* translated into the tag number dynamically. You also must make sure
* the strings in header lookups don't get translated, or the lookups
* will fail.
@@ -866,49 +871,6 @@ Header hdrGetHeader(hdrObject * s)
}
/**
- * @deprecated Use ts.hdrFromFdno() instead.
- */
-PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args)
-{
- hdrObject * hdr;
- Header h;
- FD_t fd;
- int rawFd;
- rpmRC rc;
-
- if (!PyArg_ParseTuple(args, "i", &rawFd)) return NULL;
-
- fd = fdDup(rawFd);
- { rpmts ts;
- ts = rpmtsCreate();
- rc = rpmReadPackageFile(ts, fd, "rpmHeaderFromPackage", &h);
- rpmtsFree(ts);
- }
- Fclose(fd);
-
- switch (rc) {
- case RPMRC_BADSIZE:
- case RPMRC_OK:
- hdr = hdr_Wrap(h);
- h = headerFree(h); /* XXX ref held by hdr */
- break;
-
- case RPMRC_NOTFOUND:
- Py_INCREF(Py_None);
- hdr = (hdrObject *) Py_None;
- break;
-
- case RPMRC_FAIL:
- case RPMRC_SHORTREAD:
- default:
- PyErr_SetString(pyrpmError, "error reading package");
- return NULL;
- }
-
- return Py_BuildValue("N", hdr);
-}
-
-/**
*/
PyObject * hdrLoad(PyObject * self, PyObject * args)
{
diff --git a/python/header-py.h b/python/header-py.h
index d2c138f94..1bdaf9b83 100644
--- a/python/header-py.h
+++ b/python/header-py.h
@@ -43,7 +43,5 @@ PyObject * rhnLoad(PyObject * self, PyObject * args)
/*@*/;
PyObject * hdrLoad(PyObject * self, PyObject * args)
/*@*/;
-PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args)
- /*@*/;
#endif
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c
index 93f99ed81..17ee71a09 100644
--- a/python/rpmmi-py.c
+++ b/python/rpmmi-py.c
@@ -11,8 +11,8 @@
#endif
#include <rpmlib.h>
+#include <rpmdb.h>
-#include "rpmdb-py.h"
#include "rpmmi-py.h"
#include "header-py.h"
@@ -40,11 +40,7 @@
* \code
* import rpm
* ts = rpm.TransactionSet()
- * mi = ts.dbMatch()
- * while mi:
- * h = mi.next()
- * if not h:
- * break
+ * for h in ts.dbMatch():
* print h['name']
* \endcode
*
@@ -54,10 +50,7 @@
* import rpm
* ts = rpm.TransactionSet()
* mi = ts.dbMatch('name', "kernel")
- * while mi:
- * h = mi.next()
- * if not h:
- * break;
+ * for h in mi:
* print "%s-%s-%s" % (h['name'], h['version'], h['release'])
* \endcode
*
@@ -68,10 +61,7 @@
* ts = rpm.TransactionSet()
* mi = ts.dbMatch()
* mi.pattern('name', rpm.RPMMIRE_GLOB, "XFree*")
- * while mi:
- * h = mi.next{}
- * if not h:
- * break;
+ * for h in mi:
* print "%s-%s-%s" % (h['name'], h['version'], h['release'])
* \endcode
*
@@ -85,27 +75,6 @@
/**
*/
static PyObject *
-rpmmi_Next(rpmmiObject * s, PyObject *args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies s, _Py_NoneStruct @*/
-{
- Header h;
-
- if (!PyArg_ParseTuple(args, ":Next"))
- return NULL;
-
- if (s->mi == NULL || (h = rpmdbNextIterator(s->mi)) == NULL) {
- if (s->mi) s->mi = rpmdbFreeIterator(s->mi);
- Py_INCREF(Py_None);
- return Py_None;
- }
- return (PyObject *) hdr_Wrap(h);
-}
-
-#if Py_TPFLAGS_HAVE_ITER
-/**
- */
-static PyObject *
rpmmi_iter(rpmmiObject * s)
/*@*/
{
@@ -128,7 +97,27 @@ rpmmi_iternext(rpmmiObject * s)
}
return (PyObject *) hdr_Wrap(h);
}
-#endif
+
+/**
+ */
+static PyObject *
+rpmmi_Next(rpmmiObject * s, PyObject *args)
+ /*@globals _Py_NoneStruct @*/
+ /*@modifies s, _Py_NoneStruct @*/
+{
+ PyObject * result;
+
+ if (!PyArg_ParseTuple(args, ":Next"))
+ return NULL;
+
+ result = rpmmi_iternext(s);
+
+ if (result == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ return result;
+}
/**
*/
@@ -164,7 +153,7 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args)
static struct PyMethodDef rpmmi_methods[] = {
{"next", (PyCFunction) rpmmi_Next, METH_VARARGS,
"mi.next() -> hdr\n\
-- Retrieve next header that matches.\n" },
+- Retrieve next header that matches. Iterate directly in python if possible.\n" },
{"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS,
"mi.pattern(TagN, mire_type, pattern)\n\
- Set a secondary match pattern on tags from retrieved header.\n" },
@@ -185,7 +174,7 @@ static void rpmmi_dealloc(/*@only@*/ /*@null@*/ rpmmiObject * s)
/** \ingroup python
*/
-static PyObject * rpmmi_getattr (rpmdbObject *s, char *name)
+static PyObject * rpmmi_getattr (rpmmiObject *s, char *name)
/*@*/
{
return Py_FindMethod (rpmmi_methods, (PyObject *) s, name);
@@ -249,13 +238,8 @@ PyTypeObject rpmmi_Type = {
rpmmiObject * rpmmi_Wrap(rpmdbMatchIterator mi)
{
- rpmmiObject * mio;
+ rpmmiObject * mio = (rpmmiObject *) PyObject_NEW(rpmmiObject, &rpmmi_Type);
- if (mi == NULL) {
- Py_INCREF(Py_None);
- return (rpmmiObject *) Py_None;
- }
- mio = (rpmmiObject *) PyObject_NEW(rpmmiObject, &rpmmi_Type);
if (mio == NULL) {
PyErr_SetString(pyrpmError, "out of memory creating rpmmiObject");
return NULL;
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 54d38fbff..2ba2b484a 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -10,7 +10,8 @@
#define PyObject_HEAD int _PyObjectHead;
#endif
-#include "rpmcli.h" /* XXX for rpmCheckSig */
+#include <rpmcli.h> /* XXX for rpmCheckSig */
+#include <rpmdb.h>
#include "legacy.h"
#include "misc.h"
@@ -19,7 +20,6 @@
#include "header-py.h"
#include "rpmal-py.h"
-#include "rpmdb-py.h"
#include "rpmds-py.h"
#include "rpmfd-py.h"
#include "rpmfi-py.h"
@@ -178,33 +178,6 @@ static PyObject * findUpgradeSet(PyObject * self, PyObject * args)
return result;
}
-#ifdef _LEGACY_BINDINGS_TOO
-/**
- */
-static PyObject * rpmInitDB(PyObject * self, PyObject * args)
-{
- char *root;
- int forWrite = 0;
-
- if (!PyArg_ParseTuple(args, "i|s", &forWrite, &root)) return NULL;
-
- if (rpmdbInit(root, forWrite ? O_RDWR | O_CREAT: O_RDONLY)) {
- char * errmsg = "cannot initialize database in %s";
- char * errstr = NULL;
- int errsize;
-
- errsize = strlen(errmsg) + strlen(root);
- errstr = alloca(errsize);
- snprintf(errstr, errsize, errmsg, root);
- PyErr_SetString(pyrpmError, errstr);
- return NULL;
- }
-
- Py_INCREF(Py_None);
- return(Py_None);
-}
-#endif
-
/**
*/
static PyObject * errorCB = NULL;
@@ -279,32 +252,6 @@ static PyObject * errorString (PyObject * self, PyObject * args)
/**
*/
-static PyObject * checkSig (PyObject * self, PyObject * args)
-{
- char * filename;
- int flags;
- int rc = 255;
-
- if (PyArg_ParseTuple(args, "si", &filename, &flags)) {
- rpmts ts;
- const char * av[2];
- QVA_t ka = memset(alloca(sizeof(*ka)), 0, sizeof(*ka));
-
- av[0] = filename;
- av[1] = NULL;
- ka->qva_mode = 'K';
- ka->qva_flags = (VERIFY_DIGEST|VERIFY_SIGNATURE);
- ka->sign = 0;
- ka->passPhrase = NULL;
- ts = rpmtsCreate();
- rc = rpmcliSign(ts, ka, av);
- rpmtsFree(ts);
- }
- return Py_BuildValue("i", rc);
-}
-
-/**
- */
static PyObject * setVerbosity (PyObject * self, PyObject * args)
{
int level;
@@ -348,20 +295,10 @@ static PyMethodDef rpmModuleMethods[] = {
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 },
-#ifdef _LEGACY_BINDINGS_TOO
- { "initdb", (PyCFunction) rpmInitDB, METH_VARARGS,
- NULL },
- { "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS,
- NULL },
- { "rebuilddb", (PyCFunction) rebuildDB, METH_VARARGS,
- NULL },
-#endif
{ "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS,
NULL },
{ "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS,
@@ -376,8 +313,6 @@ static PyMethodDef rpmModuleMethods[] = {
NULL },
{ "labelCompare", (PyCFunction) labelCompare, METH_VARARGS,
NULL },
- { "checksig", (PyCFunction) checkSig, METH_VARARGS,
- NULL },
{ "setVerbosity", (PyCFunction) setVerbosity, METH_VARARGS,
NULL },
{ "setEpochPromote", (PyCFunction) setEpochPromote, METH_VARARGS,
@@ -407,7 +342,6 @@ void initrpm(void)
#if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */
if (PyType_Ready(&hdr_Type) < 0) return;
if (PyType_Ready(&rpmal_Type) < 0) return;
- if (PyType_Ready(&rpmdb_Type) < 0) return;
if (PyType_Ready(&rpmds_Type) < 0) return;
if (PyType_Ready(&rpmfd_Type) < 0) return;
if (PyType_Ready(&rpmfi_Type) < 0) return;
@@ -445,9 +379,6 @@ void initrpm(void)
Py_INCREF(&rpmal_Type);
PyModule_AddObject(m, "al", (PyObject *) &rpmal_Type);
- Py_INCREF(&rpmdb_Type);
- PyModule_AddObject(m, "db", (PyObject *) &rpmdb_Type);
-
Py_INCREF(&rpmds_Type);
PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
@@ -471,7 +402,6 @@ void initrpm(void)
#else
hdr_Type.ob_type = &PyType_Type;
rpmal_Type.ob_type = &PyType_Type;
- rpmdb_Type.ob_type = &PyType_Type;
rpmds_Type.ob_type = &PyType_Type;
rpmfd_Type.ob_type = &PyType_Type;
rpmfi_Type.ob_type = &PyType_Type;
diff --git a/python/rpmrc-py.c b/python/rpmrc-py.c
index 729e1d366..285acad82 100644
--- a/python/rpmrc-py.c
+++ b/python/rpmrc-py.c
@@ -22,7 +22,6 @@ extern PyTypeObject PyDictIter_Type;
#if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */
#include "header-py.h" /* XXX debug only */
#include "rpmal-py.h" /* XXX debug only */
-#include "rpmdb-py.h" /* XXX debug only */
#include "rpmds-py.h" /* XXX debug only */
#include "rpmfd-py.h" /* XXX debug only */
#include "rpmfi-py.h" /* XXX debug only */
@@ -110,7 +109,6 @@ static const char * lbl(void * s)
if (o->ob_type == &hdr_Type) return "hdr";
if (o->ob_type == &rpmal_Type) return "rpmal";
- if (o->ob_type == &rpmdb_Type) return "rpmdb";
if (o->ob_type == &rpmds_Type) return "rpmds";
if (o->ob_type == &rpmfd_Type) return "rpmfd";
if (o->ob_type == &rpmfi_Type) return "rpmfi";
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 4d7743240..686d3ab51 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -1008,22 +1008,10 @@ static struct PyMethodDef rpmts_methods[] = {
{"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS,
NULL },
-#ifdef _LEGACY_BINDINGS_TOO
- {"add", (PyCFunction) rpmts_AddInstall, METH_VARARGS,
- NULL },
-#endif
{"addErase", (PyCFunction) rpmts_AddErase, METH_VARARGS,
NULL },
-#ifdef _LEGACY_BINDINGS_TOO
- {"remove", (PyCFunction) rpmts_AddErase, METH_VARARGS,
- NULL },
-#endif
{"check", (PyCFunction) rpmts_Check, METH_VARARGS,
NULL },
-#ifdef _LEGACY_BINDINGS_TOO
- {"depcheck", (PyCFunction) rpmts_Check, METH_VARARGS,
- NULL },
-#endif
{"order", (PyCFunction) rpmts_Order, METH_VARARGS,
NULL },
{"run", (PyCFunction) rpmts_Run, METH_VARARGS,
diff --git a/rpm.spec.in b/rpm.spec.in
index 77deea942..8b48dc09c 100644
--- a/rpm.spec.in
+++ b/rpm.spec.in
@@ -521,9 +521,13 @@ fi
- python: bare bones rollback bindings.
- python: enable threads on callbacks and longish rpmlib calls.
- python: expose RPMTAG_SOURCEPACKAGE to identify source headers.
-- python: eliminate headerFromPackage() tuple return, deprecated.
+- python: eliminate rpm.headerFromPackage() tuple return, deprecated.
- python: add ts.hdrFromFdno(fdno) method.
- fix: check for lead magic, better error message on failure (#69751).
+- python: the death of rpmdb-py.[ch], use ts.fooDB() methods instead.
+- python: the death of rpm.headerFromPackage(), use ts.hdrFromFdno().
+- python: permit direct ts.dbMatch() python iterations.
+- python: the death of rpm.checksig(), use ts.hdrFromFdno() instead.
* Sun Aug 4 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.68
- resurrect --rollback.