[CentOS] RPM python subroutine for (epoch, version, release) comparation?

Robinson Tiemuqinke

hahaha_30k at yahoo.com
Fri Jun 26 00:49:00 UTC 2009


Hi, all,
 
 On Centos 5 I am programming RPM with python recently.  When I read the online RPM python programming guide at http://docs.fedoraproject.org/drafts/rpm-guide-en/ch16s05.html, I got confused at the EVR() function as the function returns the (epoch, version, release) as a string “%epoch-%version-%release”, and so the RPM  comparing process is simplified as string comparing – which doesn’t look correct, am I wrong? See the code from the page:
 
--------------------------------------------------------------------------------------
file_h = ts.hdrFromFdno(fd) 
file_ds = file_h.dsOfHeader() 
inst_ds = inst_h.dsOfHeader() 
if file_ds.EVR() >= inst_ds.EVR(): 
print "Package file is same or newer, OK to upgrade." 
else: 
print "Package file is older than installed version."
--------------------------------------------------------------------------------------
 
I’ve see another function in rpm object: rpm.versionCompare(h1,h2) which compare two rpm headers, Am I supposed to use this function or the EVR as documented? The former one is not well documented, though.
 
Thanks.
 
-- Robinson


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20090625/16a5d52b/attachment.html>


More information about the CentOS mailing list