diff options
author | jbj <devnull@localhost> | 2002-08-09 23:14:10 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-08-09 23:14:10 +0000 |
commit | 644401875d02f4fad5e8e5a004aa9bd08153ba84 (patch) | |
tree | 101f1c7fb467f95f72b171c024b942afe3e238c7 | |
parent | 7937158c01c71774eb5872f742a9d9c771df5b79 (diff) | |
download | rpm-644401875d02f4fad5e8e5a004aa9bd08153ba84.tar.gz rpm-644401875d02f4fad5e8e5a004aa9bd08153ba84.tar.bz2 rpm-644401875d02f4fad5e8e5a004aa9bd08153ba84.zip |
- python: include instance in IDTXload, filename in IDTXglob, return
- python: argument to ts.addErase (if integer) deletes that instance.
- python: rpmmi methods to return this instance, and number of members.
CVS patchset: 5620
CVS date: 2002/08/09 23:14:10
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | python/rpmmi-py.c | 40 | ||||
-rw-r--r-- | python/rpmts-py.c | 58 | ||||
-rw-r--r-- | rpm.spec.in | 7 |
4 files changed, 89 insertions, 19 deletions
@@ -230,6 +230,9 @@ - python: add return codes for rollbacks and fooDB methods. - avoid generating fingerprints for locale/zoneinfo sub-directories. - python: add (optional) ts.check() callback. + - python: include instance in IDTXload, filename in IDTXglob, return + - python: argument to ts.addErase (if integer) deletes that instance. + - python: rpmmi methods to return this instance, and number of members. 4.0.3 -> 4.0.4: - solaris: translate i86pc to i386 (#57182). diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 17ee71a09..24f5d0d2a 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -122,6 +122,42 @@ rpmmi_Next(rpmmiObject * s, PyObject *args) /** */ static PyObject * +rpmmi_Instance(rpmmiObject * s, PyObject * args) + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ +{ + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Instance")) + return NULL; + + if (s->mi) + rc = rpmdbGetIteratorOffset(s->mi); + + return Py_BuildValue("i", rc); +} + +/** + */ +static PyObject * +rpmmi_Count(rpmmiObject * s, PyObject * args) + /*@globals _Py_NoneStruct @*/ + /*@modifies s, _Py_NoneStruct @*/ +{ + int rc = 0; + + if (!PyArg_ParseTuple(args, ":Instance")) + return NULL; + + if (s->mi) + rc = rpmdbGetIteratorCount(s->mi); + + return Py_BuildValue("i", rc); +} + +/** + */ +static PyObject * rpmmi_Pattern(rpmmiObject * s, PyObject * args) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ @@ -154,6 +190,10 @@ static struct PyMethodDef rpmmi_methods[] = { {"next", (PyCFunction) rpmmi_Next, METH_VARARGS, "mi.next() -> hdr\n\ - Retrieve next header that matches. Iterate directly in python if possible.\n" }, + {"instance", (PyCFunction) rpmmi_Instance, METH_VARARGS, + NULL }, + {"count", (PyCFunction) rpmmi_Count, METH_VARARGS, + NULL }, {"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS, "mi.pattern(TagN, mire_type, pattern)\n\ - Set a secondary match pattern on tags from retrieved header.\n" }, diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 9864279e3..14e2e1902 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -246,30 +246,54 @@ rpmts_AddErase(rpmtsObject * s, PyObject * args) /*@globals _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/ { - char * name; + PyObject * o; int count; rpmdbMatchIterator mi; if (_rpmts_debug) fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts); - if (!PyArg_ParseTuple(args, "s:AddErase", &name)) + if (!PyArg_ParseTuple(args, "O:AddErase", &o)) return NULL; - mi = rpmtsInitIterator(s->ts, RPMDBI_LABEL, name, 0); - count = rpmdbGetIteratorCount(mi); - if (count <= 0) { - PyErr_SetString(pyrpmError, "package not installed"); - return NULL; - } else { /* XXX: Note that we automatically choose to remove all matches */ - Header h; - while ((h = rpmdbNextIterator(mi)) != NULL) { - unsigned int recOffset = rpmdbGetIteratorOffset(mi); - if (recOffset) - rpmtsAddEraseElement(s->ts, h, recOffset); + if (PyString_Check(o)) { + char * name = PyString_AsString(o); + + mi = rpmtsInitIterator(s->ts, RPMDBI_LABEL, name, 0); + count = rpmdbGetIteratorCount(mi); + if (count <= 0) { + mi = rpmdbFreeIterator(mi); + PyErr_SetString(pyrpmError, "package not installed"); + return NULL; + } else { /* XXX: Note that we automatically choose to remove all matches */ + Header h; + while ((h = rpmdbNextIterator(mi)) != NULL) { + unsigned int recOffset = rpmdbGetIteratorOffset(mi); + if (recOffset) + rpmtsAddEraseElement(s->ts, h, recOffset); + } + } + mi = rpmdbFreeIterator(mi); + } else + if (PyInt_Check(o)) { + uint_32 instance = PyInt_AsLong(o); + + mi = rpmtsInitIterator(s->ts, RPMDBI_PACKAGES, &instance, sizeof(instance)); + if (instance <= 0 || mi == NULL) { + mi = rpmdbFreeIterator(mi); + PyErr_SetString(pyrpmError, "package not installed"); + return NULL; + } else { + Header h; + while ((h = rpmdbNextIterator(mi)) != NULL) { + uint_32 recOffset = rpmdbGetIteratorOffset(mi); + if (recOffset) + rpmtsAddEraseElement(s->ts, h, recOffset); + break; + } } + mi = rpmdbFreeIterator(mi); } - rpmdbFreeIterator(mi); Py_INCREF(Py_None); return Py_None; @@ -326,7 +350,7 @@ rpmts_Check(rpmtsObject * s, PyObject * args) int i; int xx; - pemset(&cbInfo, 0, sizeof(cbInfo)); + memset(&cbInfo, 0, sizeof(cbInfo)); if (!PyArg_ParseTuple(args, "|O:Check", &cbInfo.cb)) return NULL; @@ -495,7 +519,7 @@ fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts); result = PyTuple_New(idtx->nidt); for (i = 0; i < idtx->nidt; i++) { idt = idtx->idt + i; - tuple = Py_BuildValue("(iO)", idt->val.u32, hdr_Wrap(idt->h)); + tuple = Py_BuildValue("(iOi)", idt->val.u32, hdr_Wrap(idt->h), idt->instance); PyTuple_SET_ITEM(result, i, tuple); } } @@ -539,7 +563,7 @@ fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts); result = PyTuple_New(idtx->nidt); for (i = 0; i < idtx->nidt; i++) { idt = idtx->idt + i; - tuple = Py_BuildValue("(iO)", idt->val.u32, hdr_Wrap(idt->h)); + tuple = Py_BuildValue("(iOs)", idt->val.u32, hdr_Wrap(idt->h), idt->key); PyTuple_SET_ITEM(result, i, tuple); } } diff --git a/rpm.spec.in b/rpm.spec.in index 59309f809..fce012c79 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -17,7 +17,7 @@ Name: rpm %define version @VERSION@ Version: %{version} %{expand: %%define rpm_version %{version}} -Release: 0.76 +Release: 0.77 Group: System Environment/Base Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz Copyright: GPL @@ -517,10 +517,13 @@ fi %{__prefix}/include/popt.h %changelog -* Fri Aug 9 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.76 +* Fri Aug 9 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.77 - python: add return codes for rollbacks and fooDB methods. - avoid generating fingerprints for locale/zoneinfo sub-directories. - python: add (optional) ts.check() callback. +- python: include instance in IDTXload, filename in IDTXglob, return +- python: argument to ts.addErase (if integer) deletes that instance. +- python: rpmmi methods to return this instance, and number of members. * Wed Aug 7 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.75 - fix: src.rpm installs need fd pos at payload. |