On Wed, 25 Feb 2004, seth vidal wrote: > On Tue, 2004-02-24 at 23:05 -0600, David Farning wrote: > > > Is there a way to determine the total number of packages in the rpmdb? > > I've been trying variations on the following with no luck. > > > > num =rpmdbCountPackages(db, NULL); > > > > It's easy to-- > > > > mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0); > > if (mi) { > > while ((h = rpmdbNextIterator(mi)) != NULL) > > num++; > > } > > in the python modules there is an count() method to an mi instance but > from my tests it doesn't appear to return anything useful - but I > thought it was supposed to return the number of match iterators counted. > You might want to check out that code in the python modules. FWIW the above manual counting is what apt-rpm does as well, and note the comment: // iSize = rpmdbGetIteratorCount(RpmIter); // This doesn't seem to work right now. Code in rpm (4.0.4, at least) // returns a 0 from rpmdbGetIteratorCount() if rpmxxInitIterator() is // called with RPMDBI_PACKAGES or with keyp == NULL. The algorithm // below will be used until there's support for it. iSize = 0; rpmdbMatchIterator countIt; countIt = rpmxxInitIterator(Handler, RPMDBI_PACKAGES, NULL, 0); while(rpmdbNextIterator(countIt) != NULL) iSize++; rpmdbFreeIterator(countIt); - Panu - _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list