Changes from Version 1 of YumCodeSnippet/GetReleaseVersion

Show
Ignore:
Author:
james (IP: 65.172.155.230)
Timestamp:
10/01/10 15:07:09 (7 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YumCodeSnippet/GetReleaseVersion

    v0 v1  
     1This will get you the system version information that yum knows about. 
     2 
     3{{{ 
     4 
     5# Directly... NOTE that this disregards some yum specific information: 
     6import rpmUtils 
     7 
     8ts = rpmUtils.transaction.initReadOnlyTransaction(root=installroot) 
     9ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS)) 
     10# This can throw exceptions, have fun... :) 
     11idx = ts.dbMatch('provides', distroverpkg) 
     12if idx.count() == 0: 
     13    releasever = '$releasever' 
     14else: 
     15    hdr = idx.next() 
     16    releasever = hdr['version'] 
     17print '$releasever =', releasever 
     18 
     19# Via. yum 
     20import yum 
     21yb = yum.YumBase() 
     22yb.conf 
     23print '$releasever =', yb.yumvars['releasever'] 
     24 
     25}}}