[Yum] Trouble resolving dependencies/conflicts using YUM’s python API
Dan Muey
dan at cpanel.net
Wed Jun 24 23:24:37 UTC 2015
Greetings Yum folks!
Thanks in advance for any info, I really appreciate it!
We are trying to have yum resolve dependencies using the yum python API given the current state of the repo and a list of packages we want installed, updated, and removed.
I have been trying to use http://yum.baseurl.org/api/yum/yum/depsolve.html <http://yum.baseurl.org/api/yum/yum/depsolve.html> and while my simple test does return conflicts (in the form of error strings, ick) it is not finding dependencies:
import yum
import sys
yb = yum.YumBase()
yb.conf.cache = True
resolution_data = []
for package_name in sys.argv[1:]:
yb.install(name=package_name)
res = yb.resolveDeps()
(result, resultmsgs) = yb.buildTransaction()
print "Result:"
print result
print "Result MSGs:"
print resultmsgs
if (res[0] == 1):
for item in res[1]:
if item not in resolution_data:
resolution_data.append(item)
print "Res Data:"
print resolution_data
example output:
Loaded plugins: fastestmirror, post-transaction-actions, presto, refresh-
: packagekit
Result:
1
Result MSGs:
['XYZ conflicts with ABC', 'ABC conflicts with XYZ']
Res Data:
['XYZ conflicts with ABC', 'ABC conflicts with XYZ']
So my questions are:
Is http://yum.baseurl.org/api/yum/yum/depsolve.html <http://yum.baseurl.org/api/yum/yum/depsolve.html> the right thing to use for this?
Is there a way to have it return conflicts as a data structure instead of a string?
Is there a way to have it also do dependencies that would need installed and updated?
Will it calculate the dependencies when I add in some yb.remove() and yb.upgrade() calls before the yb.resolveDeps() call?
The examples I can find all call yb.buildTransaction() which would actually do the install/etc correct? If so is there a way to make it a dry run (i.e. on;y do the derp resolution)?
This Given/When/Then may illustrate the goal also.
GIVEN the current state of my RPMs
foo : installed
bar : not_installed
baz : updatable
WHEN I want to explicitly install, update, or uninstall packages
install : [bar,ler]
uninstall : [foo]
upgrade : [baz]
THEN I want to be able know [what would need/will be] implicitly installed, updated, or uninstalled (recursively)
resolved : {
install : [baz] # because bar depends on it
uninstall : [wop,jib] # because wop conflicts with bar && jib conflicts with ler
upgrade : [zig] # because newer baz requires a newer version of zig
}
Then we can highlight/deal with the case where a package exists in more than one install/uninstall/upgrade slot :)
Thanks in advance!
--
Dan Muey - cPanel Developer
dan at cpanel.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum/attachments/20150624/4b2f153d/attachment.html>
More information about the Yum
mailing list