[Yum] Re: yum search behaviour change from 3.0.x to 3.2.x

James Antill james at and.org
Thu May 29 21:54:40 UTC 2008


On Tue, 27 May 2008 14:33:19 -0700, MHR wrote:

> I use a bash function to look for packages in yum that looks like 'yum
> list | grep -i' and then takes one grep argument as its "parameter" (in
> CentOS 5) - works nicely for my purposes.  YMMV.

 That's fine, if that's what you want, but you'll probably find that the
following is faster (esp. on newer versions of yum):

import yum
import sys

my = yum.YumBase()
my.conf.cache = 1

searchterms = sys.argv[1:]
searchlist = ['name']

print '::searching'
res = my.searchGenerator(searchlist, searchterms)

for (pkg,values) in res:
    ver = pkg.printVer()
    na = '%s.%s' % (pkg.name, pkg.arch)
    # Print like list
    print "%-40.40s %-22.22s %-16.16s" % (na, ver, pkg.repoid)

-- 
James Antill -- james at and.org
C String APIs use too much memory? ustr: length, ref count, size and
read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings
http://www.and.org/ustr/




More information about the Yum mailing list