summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-08-27 18:39:17 +0000
committerjbj <devnull@localhost>2001-08-27 18:39:17 +0000
commit64a1d1afdcfce7b401f02eb19e268cd3562ef1ac (patch)
tree01186f7749a781f6e3b744fe650d2ac7ce104d98 /python
parentf847cb330c61b74a376df1f4ddb1e89251327e6f (diff)
downloadrpm-64a1d1afdcfce7b401f02eb19e268cd3562ef1ac.tar.gz
rpm-64a1d1afdcfce7b401f02eb19e268cd3562ef1ac.tar.bz2
rpm-64a1d1afdcfce7b401f02eb19e268cd3562ef1ac.zip
- fix: error message on failed package installs resurrected.
- python: memory leaks in headerLoad/headerunload bindings. - python: retrofit sha1 digest using RPMTAG_SHA1RHN. - python: change rhnUnload bindings. CVS patchset: 5032 CVS date: 2001/08/27 18:39:17
Diffstat (limited to 'python')
-rw-r--r--python/poptmodule.c6
-rw-r--r--python/rpmmodule.c114
2 files changed, 65 insertions, 55 deletions
diff --git a/python/poptmodule.c b/python/poptmodule.c
index 158743ae2..c3826887a 100644
--- a/python/poptmodule.c
+++ b/python/poptmodule.c
@@ -6,7 +6,7 @@
#define PY_POPT_VERSION "0.2"
-static const char *rcs_id = "$Id: poptmodule.c,v 1.4 2001/07/21 19:44:22 jbj Exp $";
+static const char *rcs_id = "$Id: poptmodule.c,v 1.5 2001/08/27 18:39:17 jbj Exp $";
static char *module_doc = "Python bindings for the popt library\n\
\n\
@@ -622,8 +622,8 @@ static PyObject * _strerror(PyObject *self, PyObject *args)
/* Methods for the popt module */
static struct PyMethodDef poptModuleMethods[] = {
- {"getContext", (PyCFunction)getContext},
- {"strerror", (PyCFunction)_strerror},
+ {"getContext", (PyCFunction)getContext, METH_VARARGS, NULL},
+ {"strerror", (PyCFunction)_strerror, METH_VARARGS, NULL},
{NULL, NULL}
};
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 753591ee9..3a98e8324 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -18,10 +18,16 @@
#include "rpmcli.h" /* XXX for rpmCheckSig */
#include "misc.h"
#include "rpmio_internal.h"
+#include "header_internal.h"
#include "upgrade.h"
extern int _rpmio_debug;
+/*@unused@*/ static inline Header headerAllocated(Header h) {
+ h->flags |= HEADERFLAG_ALLOCATED;
+ return 0;
+}
+
#ifdef __LCLINT__
#undef PyObject_HEAD
#define PyObject_HEAD int _PyObjectHead
@@ -439,6 +445,59 @@ static void mungeFilelist(Header h)
free((void *)fileNames);
}
+/**
+ */
+static PyObject * rhnUnload(PyObject * self, PyObject * args) {
+ int len;
+ char * uh;
+ PyObject * rc;
+ hdrObject *s;
+ Header h;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ h = headerLink(s->h);
+
+ /* Legacy headers are forced into immutable region. */
+ if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
+ Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
+ /* XXX Another unload/load cycle to "seal" the immutable region. */
+ uh = headerUnload(nh);
+ headerFree(nh);
+ h = headerLoad(uh);
+ headerAllocated(h);
+ }
+
+ /* All headers have SHA1 digest, compute and add if necessary. */
+ if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
+ int_32 uht, uhc;
+ const char * digest;
+ size_t digestlen;
+ DIGEST_CTX ctx;
+
+ headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
+
+ ctx = rpmDigestInit(RPMDIGEST_SHA1);
+ rpmDigestUpdate(ctx, uh, uhc);
+ rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
+
+ headerAddEntry(h, RPMTAG_SHA1RHN, RPM_STRING_TYPE, digest, 1);
+
+ uh = headerFreeData(uh, uht);
+ digest = _free(digest);
+ }
+
+ len = headerSizeof(h, 0);
+ uh = headerUnload(h);
+ headerFree(h);
+
+ rc = PyString_FromStringAndSize(uh, len);
+ free(uh);
+
+ return rc;
+}
+
/** \ingroup python
*/
static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
@@ -457,6 +516,7 @@ static struct PyMethodDef hdrMethods[] = {
{"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 },
{"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 },
{"fullFilelist", (PyCFunction) hdrFullFilelist, 1 },
+ {"rhnUnload", (PyCFunction) rhnUnload, 1 },
{NULL, NULL} /* sentinel */
};
@@ -1804,6 +1864,7 @@ static PyObject * hdrLoad(PyObject * self, PyObject * args) {
PyErr_SetString(pyrpmError, "bad header");
return NULL;
}
+ headerAllocated(hdr);
compressFilelist (hdr);
providePackageNVR (hdr);
@@ -1840,6 +1901,7 @@ static PyObject * rhnLoad(PyObject * self, PyObject * args) {
PyErr_SetString(pyrpmError, "bad header");
return NULL;
}
+ headerAllocated(hdr);
if (!headerIsEntry(hdr, RPMTAG_HEADERIMMUTABLE)) {
PyErr_SetString(pyrpmError, "bad header, not immutable");
@@ -1869,57 +1931,6 @@ static PyObject * rhnLoad(PyObject * self, PyObject * args) {
return (PyObject *) h;
}
-/**
- */
-static PyObject * rhnUnload(PyObject * self, PyObject * args) {
- int len;
- char * uh;
- PyObject * rc;
- hdrObject *s;
- Header h;
- if (!PyArg_ParseTuple(args, "O!", &hdrType, &s))
- return NULL;
-
- h = headerLink(s->h);
-
- /* Legacy headers are forced into immutable region. */
- if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
- Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
- /* XXX Another unload/load cycle to "seal" the immutable region. */
- uh = headerUnload(nh);
- headerFree(nh);
- h = headerLoad(uh);
- }
-
- /* All headers have SHA1 digest, compute and add if necessary. */
- if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
- int_32 uht, uhc;
- const char * digest;
- size_t digestlen;
- DIGEST_CTX ctx;
-
- headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
-
- ctx = rpmDigestInit(RPMDIGEST_SHA1);
- rpmDigestUpdate(ctx, uh, uhc);
- rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
-
- headerAddEntry(h, RPMTAG_SHA1HEADER, RPM_STRING_TYPE, digest, 1);
-
- uh = headerFreeData(uh, uht);
- digest = _free(digest);
- }
-
- len = headerSizeof(h, 0);
- uh = headerUnload(h);
- headerFree(h);
-
- rc = PyString_FromStringAndSize(uh, len);
- free(uh);
-
- return rc;
-}
-
/**
*/
static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
@@ -2415,7 +2426,6 @@ static PyMethodDef rpmModuleMethods[] = {
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL },
- { "rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS, NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, NULL },
{ "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL },