[Yum-devel] yum dependencies list for the update available
malisetti rammurthy
malisettirammurthy at gmail.com
Mon Feb 11 12:20:16 UTC 2013
Hi Team,
I am trying to write a python wrapper on top of Yum python API. Presently i
am able to get the dependencies list available for a package. Here the
package i am providing is an update package that is available for
installation using yum (chkconfig-1.3.49.3-2.el6.x86_64). For this package
i am getting the following list as the dependencies
['glibc-2.12-1.80.el6_3.7', 'popt-1.13-7.el6'].
But actually, the above list is equivalent for this command "yum deplist
chkconfig-1.3.49.3-2.el6.x86_64". But this command "yum update
chkconfig-1.3.49.3-2.el6.x86_64" is giving a different output with this
package (ntsysv-1.3.49.3-2.el6) included.
Following is my code for getting the dependencies for a package provided:
********************************************************************************************
import sys, re
import yum, rpm
from yum import _
sys.path.insert(0, '/usr/share/yum-cli')
import output
class YumFrame(yum.YumBase, output.YumOutput):
def __init__(self):
try:
yum.YumBase.__init__(self)
output.YumOutput.__init__(self)
except Exception, e:
raise e
self.pattern1 =
re.compile(r'^([a-zA-Z0-9_\-\+]*)-([a-zA-Z0-9_\.]*)-([a-zA-Z0-9_\.]*)')
def compare(self, pkg1, pkg2):
Info1 = self.pattern1.search(pkg1).groups()
Info2 = self.pattern1.search(pkg2).groups()
n1, v1, r1 = Info1
n2, v2, r2 = Info2
if n1 == n2:
return rpm.labelCompare(('1', v1, r1), ('1', v2, r2))
else:
return 2
def listCompare(self, input):
latest = input[0]
refinedList = []
for index, item in enumerate(input):
result = self.compare(item, latest)
if result == 1:
latest = item
elif result == 2:
refinedList.append(item)
refinedList.append(latest)
return refinedList
def customMethod(self, package):
pkgs = []
completeList = []
ematch, match, unmatch = self.pkgSack.matchPackageNames([package])
for po in ematch + match:
pkgs.append(po)
print "Matched Object: " + str(pkgs)
results = self.findDeps(pkgs)
for value in results.itervalues():
for packageObject in value.itervalues():
actualList = []
for item in packageObject:
completeList.append(item.name + "-" + item.ver + "-" +
item.rel)
completeList = self.listCompare(completeList)
completeList = list(set(completeList))
return completeList
if __name__ == "__main__":
yumObj = YumFrame()
print yumObj.customMethod("chkconfig-1.3.49.3-2.el6")
********************************************************************************************
Can you please help me in getting the dependencies list similar to "yum
update pkg-name".
Thanks in Advance,
M Ram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20130211/6af013c3/attachment.html>
More information about the Yum-devel
mailing list