Changes between Version 5 and Version 6 of 5MinuteExamples

Show
Ignore:
Author:
james (IP: 65.172.155.230)
Timestamp:
08/18/09 22:21:14 (9 years ago)
Comment:

Change yum.conf.cache to newer yum.setCacheDir()

Legend:

Unmodified
Added
Removed
Modified
  • 5MinuteExamples

    v5 v6  
    1717This creates a yum instance, that you can work with. Then one more piece, that is very useful: 
    1818{{{ 
    19     yb.conf.cache = os.geteuid() != 0 
     19    yb.setCacheDir() 
    2020}}} 
    2121 
    22 This just tells the yum instance not to try and update any of it's data, as the caller of the script probably hasn't got the permissions to do so
     22This tells the yum instance to work as a normal user as well as root, as much as it can do (for instance it won't be able to alter data in the rpmdb, or the yumdb)
    2323 
    24 Now we have a real yum object that we can do things with, the three most useful parts to access are pkgSack, rpmdb and repos. The first two basically act the same, but rpmdb performs queries based on the installed packages on the local machine and pkgSack performs them against all the enabled (normally remote) repositories. The repos attribute is almost always used for one of three things, calling repos.enableRepo(), repos.disableRepo() and less often repos.listEnabled(). The latter for if you need to set/override some specific configuration for the repos. 
     24Now we have a real yum object that we can do things with, the three most useful parts to access are pkgSack, rpmdb and repos. The first two basically act the same, but rpmdb performs queries based on the installed packages on the local machine and pkgSack performs them against all the enabled repositories (which are normally just URLs to resources over the network). The repos attribute is almost always used for one of three things, calling repos.enableRepo(), repos.disableRepo() and less often repos.listEnabled(). The latter for if you need to set/override some specific configuration for the repos. 
    2525 
    2626The pkgSack and rpmdb attributes have a fairly large number of functions you can call, most of which return "package objects" these are the main things you work with most in yum code. Probably the most useful functions to get those package objects are: searchNevra(), returnPackages() and searchPrimaryFields(). There are also some optimized varients like, searchNames() and returnNewestByNameArch(). Some examples would be: