[Yum-devel] repoquery question [answered: Pay it forward]

Dan White ygor at comcast.net
Thu Jan 12 18:41:31 UTC 2012


The following extract from "find-repos-of-installed" gives me what I need.
I can grep from there.

#!/usr/bin/python -tt
import yum
my = yum.YumBase() 
pkgs = my.rpmdb

i=0

for ipkg in sorted(pkgs):
    apkgs = my.pkgSack.searchPkgTuple(ipkg.pkgtup)
    if len(apkgs) >= 1:
        apkg = apkgs[0]
        print '%s from repo %s' % (ipkg, apkg.repoid)
    i += 1
print str(i) + " packages"
#---- Pay it forward
#---- Share & Enjoy

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

----- James Antill <james at fedoraproject.org> wrote:
> On Thu, 2012-01-12 at 16:31 +0000, Dan White wrote:
> > Tried it.
> > Does not work.
> > 
> > RHEL5 system
> > 
> > % yum list yum
> > yum.noarch   3.2.22-37.el5  installed
> 
>  As Seth said, this only works on RHEL-6.
> 
> > # ./find-repos-of-install.py
> > Loaded plugins: product-id, rhnplugin, versionlock
> > Traceback (most recent call last):
> >   File "./find-repos-of-install.py", line 51, in ?
> >     if not my.setCacheDir(opts.tempcache):
> > AttributeError: 'YumBase' object has no attribute 'setCacheDir'
> > 
> > Is something missing ?
> 
>  RHEL-5 doesn't have that call ... there are older versions of
> find-repos-of-install that work in RHEL-5, or as a quick hack you can
> just rm those two lines.


More information about the Yum-devel mailing list