diff options
author | Matt Wilson <msw@redhat.com> | 1999-08-26 00:21:30 +0000 |
---|---|---|
committer | Matt Wilson <msw@redhat.com> | 1999-08-26 00:21:30 +0000 |
commit | 9f7d47ce097271ebc86a06e6dd2da888fb0e163d (patch) | |
tree | 02cf1fdbf108e691c645048500eecde35a95a073 /rpmmodule | |
parent | ec5eda29cc3fd6899c9e60006e9cb83de5102675 (diff) | |
download | anaconda-9f7d47ce097271ebc86a06e6dd2da888fb0e163d.tar.gz anaconda-9f7d47ce097271ebc86a06e6dd2da888fb0e163d.tar.xz anaconda-9f7d47ce097271ebc86a06e6dd2da888fb0e163d.zip |
FindPackage
Diffstat (limited to 'rpmmodule')
-rw-r--r-- | rpmmodule/rpmmodule.c | 16 | ||||
-rwxr-xr-x | rpmmodule/testit | 63 |
2 files changed, 29 insertions, 50 deletions
diff --git a/rpmmodule/rpmmodule.c b/rpmmodule/rpmmodule.c index 10dc7b5f6..2d912857f 100644 --- a/rpmmodule/rpmmodule.c +++ b/rpmmodule/rpmmodule.c @@ -9,6 +9,9 @@ #include "rpmlib.h" #include "upgrade.h" +/* from lib/misc.c */ +int rpmvercmp(const char * one, const char * two); + /* Forward types */ typedef struct rpmdbObject_s rpmdbObject; @@ -24,6 +27,7 @@ static PyObject * rpmdbNext(rpmdbObject * s, PyObject * args); static PyObject * rpmdbByName(rpmdbObject * s, PyObject * args); static PyObject * rpmdbByProvides(rpmdbObject * s, PyObject * args); static PyObject * rpmdbByFile(rpmdbObject * s, PyObject * args); +static PyObject * dbFindPackage(rpmdbObject * s, PyObject * args); static int rpmdbLength(rpmdbObject * s); static hdrObject * rpmdbSubscript(rpmdbObject * s, PyObject * key); @@ -176,6 +180,7 @@ static struct PyMethodDef rpmdbMethods[] = { {"findbyfile", (PyCFunction) rpmdbByFile, 1 }, {"findbyname", (PyCFunction) rpmdbByName, 1 }, {"findbyprovides", (PyCFunction) rpmdbByProvides, 1 }, + {"findpackage", (PyCFunction) dbFindPackage, 1 }, {NULL, NULL} /* sentinel */ }; @@ -750,6 +755,17 @@ static PyObject * rpmdbByProvides(rpmdbObject * s, PyObject * args) { return handleDbResult(rc, matches); } +static PyObject * dbFindPackage(rpmdbObject * s, PyObject * args) { + char * str; + dbiIndexSet matches; + int rc; + + if (!PyArg_ParseTuple(args, "s", &str)) return NULL; + + rc = rpmdbFindPackage(s->db, str, &matches); + return handleDbResult(rc, matches); +} + static int rpmdbLength(rpmdbObject * s) { int first; int count = 0; diff --git a/rpmmodule/testit b/rpmmodule/testit index db3752d56..fc5e78792 100755 --- a/rpmmodule/testit +++ b/rpmmodule/testit @@ -2,58 +2,21 @@ import rpm import os -import time -def cb(what, amount, total, key, data): - if (what == rpm.RPMCALLBACK_INST_OPEN_FILE): - d = os.open(key, os.O_RDONLY) - return d +## fd = os.open('/mnt/redhat/comps/dist/6.0/i386/util-linux-2.9o-13.i386.rpm', 0) +## (hdr1, foo) = rpm.headerFromPackage (fd) +## os.close (fd) +## fd = os.open ('/mnt/redhat/comps/dist/6.1/i386/util-linux-2.9v-20.i386.rpm', 0) +## (hdr2, foo) = rpm.headerFromPackage (fd) +## os.close (fd) -## fd = os.open('foo', os.O_RDONLY); -## (h, isSource) = rpm.headerFromPackage(fd) -## print "from foo:", h[rpm.RPMTAG_NAME] -## os.close(fd) +## print rpm.versionCompare (hdr1, hdr1) -from urllib import * +## print rpm.labelCompare ((None, "2.9j", "14"), (None, "2.9j", "15")) -#url = urlopen ("http://porkchop.redhat.com/msw/i386/RedHat/base/hdlist") -#url = urlretrieve ("http://porkchop.redhat.com/msw/i386/RedHat/base/hdlist", "/tmp/hdlist") -#url = urlopen ("/mnt/test/msw/i386/RedHat/base/hdlist") -#print os.read (url.fileno (), 1) - -import httplib -h = httplib.HTTP('porkchop.redhat.com') -h.putrequest('GET', '/msw/i386/RedHat/base/hdlist') -h.endheaders() -#errcode, errmsg, headers = h.getreply() -h.getreply() -#print errcode # Should be 200 -f = h.getfile() - -print f.fileno () -print os.read (f.fileno (), 5) -list = rpm.readHeaderListFromFD(f.fileno ()) -f.close() -#list = rpm.readHeaderListFromFD('/mnt/test/msw/i386/RedHat/base/hdlist') -#list = rpm.readHeaderListFromFile('/tmp/hdlist') -print "got", len(list), "items" - -print "finding upgrade set..." -ugset = rpm.findUpgradeSet (list) -for header in ugset: - print header[rpm.RPMTAG_NAME] - -#d = rpm.opendb(0) - -#ts = rpm.TransactionSet() - -#for h in list: -# ts.add(h, "foo", "a") - -#ts.add(list[0], "foo") -#rc = ts.depcheck() -#print rc - -#ts.order() -#print "run", ts.run(rpm.RPMTRANS_FLAG_TEST, 0, cb, "arg") +db = rpm.opendb () +rc = db.findpackage ("Xconfigurator") +for rec in rc: + print db[rec] + print db[rec]['name'] |