[Yum] specifying a version range to yum

Jay Buffington me at jaybuff.com
Tue Feb 5 18:14:05 UTC 2013


On Tue, Feb 5, 2013 at 9:53 AM, James Antill <james-yum at and.org> wrote:
>  There is no command that would accept that atm. ... in theory you
> could write one as a plugin, however this will almost certainly do the
> same thing:
>
> sudo yum install 'foo <= 0.7.9'

Thanks for your response.  If foo-0.6.0 is installed this command takes no
action.  I think it would work if you first did install, then update like this:

sudo yum install 'foo <= 0.7.9'
sudo yum update 'foo <= 0.7.9'

But if only 0.6.0 was available in your repos this would succeed even though
it shouldn't have :(

If you can guarantee your repo will have a package that will satisfy
the minimum
dependency this is a good, simple, solution.

>  With the python API you can pretty much do anything, as at worst you
> can get a list of all the packages with a given name and then filter
> them yourself and ask yum "install this package".

I came up with this:

    import yum

    yb = yum.YumBase()
    a = yb.returnPackagesByDep('foo >= 0.7.8')
    b = yb.returnPackagesByDep('foo <= 0.7.9')
    pkgs = list(set(a) & set(b))
    print(yb.bestPackagesFromList(pkgs))

Other than the annoyance that I have to run it as root (I get
IOError: [Errno 13] Permission denied:
'/var/cache/yum/x86_64/6Server/csi/repomd.xml.old.tmp'
when I don't) it works ok.

Thanks!
Jay


More information about the Yum mailing list