summaryrefslogtreecommitdiffstats
path: root/rpmmodule
diff options
context:
space:
mode:
authorCristian Gafton <gafton@redhat.com>1999-09-16 21:15:42 +0000
committerCristian Gafton <gafton@redhat.com>1999-09-16 21:15:42 +0000
commitdb906dee39b83ffc6db249753cc9eda76c0b3f79 (patch)
tree81a46f33ad0c51cb8ed4959f9a419ec2d2379520 /rpmmodule
parenta62f79c7438bb13d398696898ad4a66d63892b5a (diff)
downloadanaconda-db906dee39b83ffc6db249753cc9eda76c0b3f79.tar.gz
anaconda-db906dee39b83ffc6db249753cc9eda76c0b3f79.tar.xz
anaconda-db906dee39b83ffc6db249753cc9eda76c0b3f79.zip
more meningfull error messgaes
Diffstat (limited to 'rpmmodule')
-rw-r--r--rpmmodule/rpmmodule.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/rpmmodule/rpmmodule.c b/rpmmodule/rpmmodule.c
index 6138a4ae4..53022dd2a 100644
--- a/rpmmodule/rpmmodule.c
+++ b/rpmmodule/rpmmodule.c
@@ -424,9 +424,25 @@ static rpmdbObject * rpmOpenDB(PyObject * self, PyObject * args) {
o = PyObject_NEW(rpmdbObject, &rpmdbType);
o->db = NULL;
+
+ /* XXX --gafton
+ * I would like this root argument to behave like the --dbpath in the plain
+ * rpm command line. What it does now it re-roots the /var/lib/rpm to whatever
+ * I am passing on, so if I pass in /ftp/updates/rpmdb/i386 it will end up looking
+ * for the rpm database in /ftp/updates/rpmdb/i386/var/lib/rpm.
+ * I'm stuck.
+ */
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;
}