diff options
author | jbj <devnull@localhost> | 1999-09-17 20:11:44 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 1999-09-17 20:11:44 +0000 |
commit | 315eb02ffa5324d5ea71750b003738ff73c66a73 (patch) | |
tree | 550a52135a262549fa7702efaec19e4b5e52965b /python | |
parent | 89a17f4cfab00c46170f07a2f68f91c3e8ca26df (diff) | |
download | rpm-315eb02ffa5324d5ea71750b003738ff73c66a73.tar.gz rpm-315eb02ffa5324d5ea71750b003738ff73c66a73.tar.bz2 rpm-315eb02ffa5324d5ea71750b003738ff73c66a73.zip |
Update from anaconda.
CVS patchset: 3285
CVS date: 1999/09/17 20:11:44
Diffstat (limited to 'python')
-rw-r--r-- | python/rpmmodule.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 6138a4ae4..640b72eb3 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -7,6 +7,7 @@ #include "Python.h" #include "rpmlib.h" +#include "rpmmacro.h" #include "upgrade.h" /* from lib/misc.c */ @@ -38,6 +39,7 @@ static PyObject * hdrUnload(hdrObject * s, PyObject * args); static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args); void initrpm(void); +static PyObject * doAddMacro(PyObject * self, PyObject * args); static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args); static PyObject * hdrLoad(PyObject * self, PyObject * args); static PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args); @@ -65,6 +67,7 @@ static int rpmtransSetAttr(rpmtransObject * o, char * name, static PyMethodDef rpmModuleMethods[] = { { "TransactionSet", (PyCFunction) rpmtransCreate, METH_VARARGS, NULL }, + { "addMacro", (PyCFunction) doAddMacro, METH_VARARGS, NULL }, { "archscore", (PyCFunction) archScore, METH_VARARGS, NULL }, { "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL }, { "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL }, @@ -415,6 +418,8 @@ static PyObject * findUpgradeSet(PyObject * self, PyObject * args) { return result; } + + static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) { rpmdbObject * o; char * root = ""; @@ -424,9 +429,18 @@ static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) { o = PyObject_NEW(rpmdbObject, &rpmdbType); o->db = NULL; + if (rpmdbOpen(root, &o->db, forWrite ? O_RDWR | O_CREAT: O_RDONLY, 0)) { + char * errmsg = "cannot open database in %s"; + char * errstr = NULL; + int errsize; + Py_DECREF(o); - PyErr_SetString(pyrpmError, "cannot open database in /var/lib/rpm"); + /* PyErr_SetString should take varargs... */ + errsize = strlen(errmsg) + *root == '\0' ? 15 /* "/var/lib/rpm" */ : strlen(root); + errstr = alloca(errsize); + snprintf(errstr, errsize, errmsg, *root == '\0' ? "/var/lib/rpm" : root); + PyErr_SetString(pyrpmError, errstr); return NULL; } @@ -1379,7 +1393,10 @@ static PyObject * rpmtransRun(rpmtransObject * s, PyObject * args) { list = PyList_New(0); for (i = 0; i < probs->numProblems; i++) { - prob = Py_BuildValue("s", rpmProblemString(probs->probs[i])); + prob = Py_BuildValue("s(isi)", rpmProblemString(probs->probs[i]), + probs->probs[i].type, + probs->probs[i].str1, + probs->probs[i].ulong1); PyList_Append(list, prob); Py_DECREF(prob); } @@ -1400,3 +1417,15 @@ static PyObject * archScore(PyObject * self, PyObject * args) { return Py_BuildValue("i", score); } + +static PyObject * doAddMacro(PyObject * self, PyObject * args) { + char * name, * val; + + if (!PyArg_ParseTuple(args, "ss", &name, &val)) + return NULL; + + addMacro(NULL, name, NULL, val, RMIL_DEFAULT); + + Py_INCREF(Py_None); + return Py_None; +} |