Given the rpm package name, query the yum database for updates

I imagined a 3-line Python script, but the yum Python API is impenetrable. Is it possible?

Is a wrapper entry for 'yum list package-name' the only way to do this?

+6
python rpm yum
source share
2 answers

As Seth points out, you can use the update APIs to find out if anything is available as an update. For something close to yum list, you probably want to use doPackageLists (). For example.

import os, sys import yum yb = yum.YumBase() yb.conf.cache = os.geteuid() != 1 pl = yb.doPackageLists(patterns=sys.argv[1:]) if pl.installed: print "Installed Packages" for pkg in sorted(pl.installed): print pkg if pl.available: print "Available Packages" for pkg in sorted(pl.available): print pkg, pkg.repo if pl.reinstall_available: print "Re-install Available Packages" for pkg in sorted(pl.reinstall_available): print pkg, pkg.repo 
+5
source share

http://fpaste.org/paste/2453

and there are many examples of yum api and some tutorials to get started with it here:

http://yum.baseurl.org/#DeveloperDocumentationExamples

+7
source share

All Articles