- 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
This commit is contained in:
jbj 2002-08-09 23:14:10 +00:00
parent 7937158c01
commit 644401875d
4 changed files with 89 additions and 19 deletions

View File

@ -230,6 +230,9 @@
- python: add return codes for rollbacks and fooDB methods. - python: add return codes for rollbacks and fooDB methods.
- avoid generating fingerprints for locale/zoneinfo sub-directories. - avoid generating fingerprints for locale/zoneinfo sub-directories.
- python: add (optional) ts.check() callback. - 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: 4.0.3 -> 4.0.4:
- solaris: translate i86pc to i386 (#57182). - solaris: translate i86pc to i386 (#57182).

View File

@ -119,6 +119,42 @@ rpmmi_Next(rpmmiObject * s, PyObject *args)
return result; return result;
} }
/**
*/
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 * static PyObject *
@ -154,6 +190,10 @@ static struct PyMethodDef rpmmi_methods[] = {
{"next", (PyCFunction) rpmmi_Next, METH_VARARGS, {"next", (PyCFunction) rpmmi_Next, METH_VARARGS,
"mi.next() -> hdr\n\ "mi.next() -> hdr\n\
- Retrieve next header that matches. Iterate directly in python if possible.\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, {"pattern", (PyCFunction) rpmmi_Pattern, METH_VARARGS,
"mi.pattern(TagN, mire_type, pattern)\n\ "mi.pattern(TagN, mire_type, pattern)\n\
- Set a secondary match pattern on tags from retrieved header.\n" }, - Set a secondary match pattern on tags from retrieved header.\n" },

View File

@ -246,19 +246,23 @@ rpmts_AddErase(rpmtsObject * s, PyObject * args)
/*@globals _Py_NoneStruct @*/ /*@globals _Py_NoneStruct @*/
/*@modifies s, _Py_NoneStruct @*/ /*@modifies s, _Py_NoneStruct @*/
{ {
char * name; PyObject * o;
int count; int count;
rpmdbMatchIterator mi; rpmdbMatchIterator mi;
if (_rpmts_debug) if (_rpmts_debug)
fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts); 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; return NULL;
if (PyString_Check(o)) {
char * name = PyString_AsString(o);
mi = rpmtsInitIterator(s->ts, RPMDBI_LABEL, name, 0); mi = rpmtsInitIterator(s->ts, RPMDBI_LABEL, name, 0);
count = rpmdbGetIteratorCount(mi); count = rpmdbGetIteratorCount(mi);
if (count <= 0) { if (count <= 0) {
mi = rpmdbFreeIterator(mi);
PyErr_SetString(pyrpmError, "package not installed"); PyErr_SetString(pyrpmError, "package not installed");
return NULL; return NULL;
} else { /* XXX: Note that we automatically choose to remove all matches */ } else { /* XXX: Note that we automatically choose to remove all matches */
@ -269,7 +273,27 @@ fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts);
rpmtsAddEraseElement(s->ts, h, recOffset); rpmtsAddEraseElement(s->ts, h, recOffset);
} }
} }
rpmdbFreeIterator(mi); 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);
}
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
@ -326,7 +350,7 @@ rpmts_Check(rpmtsObject * s, PyObject * args)
int i; int i;
int xx; int xx;
pemset(&cbInfo, 0, sizeof(cbInfo)); memset(&cbInfo, 0, sizeof(cbInfo));
if (!PyArg_ParseTuple(args, "|O:Check", &cbInfo.cb)) if (!PyArg_ParseTuple(args, "|O:Check", &cbInfo.cb))
return NULL; return NULL;
@ -495,7 +519,7 @@ fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts);
result = PyTuple_New(idtx->nidt); result = PyTuple_New(idtx->nidt);
for (i = 0; i < idtx->nidt; i++) { for (i = 0; i < idtx->nidt; i++) {
idt = idtx->idt + 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); 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); result = PyTuple_New(idtx->nidt);
for (i = 0; i < idtx->nidt; i++) { for (i = 0; i < idtx->nidt; i++) {
idt = idtx->idt + 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); PyTuple_SET_ITEM(result, i, tuple);
} }
} }

View File

@ -17,7 +17,7 @@ Name: rpm
%define version @VERSION@ %define version @VERSION@
Version: %{version} Version: %{version}
%{expand: %%define rpm_version %{version}} %{expand: %%define rpm_version %{version}}
Release: 0.76 Release: 0.77
Group: System Environment/Base Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz
Copyright: GPL Copyright: GPL
@ -517,10 +517,13 @@ fi
%{__prefix}/include/popt.h %{__prefix}/include/popt.h
%changelog %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. - python: add return codes for rollbacks and fooDB methods.
- avoid generating fingerprints for locale/zoneinfo sub-directories. - avoid generating fingerprints for locale/zoneinfo sub-directories.
- python: add (optional) ts.check() callback. - 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 * Wed Aug 7 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.75
- fix: src.rpm installs need fd pos at payload. - fix: src.rpm installs need fd pos at payload.