[Yum] Re: repoquery/yum latest_and_not_obsoleted?

Axel Thimm Axel.Thimm at ATrpms.net
Tue Jul 15 01:46:32 UTC 2008


Hi,

On Mon, Jul 14, 2008 at 12:22:08PM -0400, seth vidal wrote:
> On Sun, 2008-07-13 at 09:51 +0300, Axel Thimm wrote:
> > for running bcfg2 or also maybe other configuration engines checking
> > the package install status one needs a list of valid packages for that
> > repo. Ideally there would be a command to query all packages in the
> > repos like yum does, but only show the latest and the ones not
> > obsoleted by other packages, e.g. what yum uses in its final rounds.

[After playing a bit with the screen scraping method: One would
 skip-broken for a yum install '*' into a chroot as there are always
 some black sheeps ruining the repo consistency.]

> 
> yum list available pkgname-ver-rel.arch should do that - but if you want
> to make it more precise a very short python script should do it.
> 
> import yum
> my = yum.YumBase()
> my.conf.cache=1 # to avoid updating the metadata
> newestpkgs = my.pkgSack.returnNewestByNameArch()
> 
> then you can iterate that list if you so choose.

Wow, that sounds too easy! :)
Does returnNewestByNameArch() also take Obsoletes:/Conflicts: into
account?

> Tell me a bit more about what you need to query on and I think we can
> hack something up that's simple.

The idea is to have a pool of allowed packages for bcfg2 to verify
against. There are two scripts that try to do that:

https://trac.mcs.anl.gov/projects/bcfg2/wiki/RPMng#AutomatedGenerationofPkgmgrConfigurationFiles

but they don't use any dependency resolving engine (e.g. obsoletes for
example) to cater for package renames/splits like Fedora updates may
introduce. Also any further yum details like priorities/enabled/
disabled/excludes etc would be missed (actually I don't like
priorities, but a correct implementation of a package pool would need
to cater for every user detail). Therefore a tool using yum's engine
is needed to make sure all current and future yum processing details
are taken care of instead of trying to model them.

The resulting output looks like (or should look like) [the package
ordering doesn't really matter, and the verify_flags can be ignored
for the sake of this context]:

<PackageList priority='0' type='yum'>
    <Group name='el5'>
        <Group name='x86_64'>
            <Package name='CGAL' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='3.3.1' release='12.el5' arch='x86_64'/>
            </Package>
            <Package name='CGAL-demos-source' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='3.3.1' release='12.el5' arch='x86_64'/>
            </Package>
            <Package name='CGAL-devel' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='3.3.1' release='12.el5' arch='x86_64'/>
            </Package>
[...]
            <Package name='zsh' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='4.2.6' release='1' arch='x86_64'/>
            </Package>
            <Package name='zsh-html' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='4.2.6' release='1' arch='x86_64'/>
            </Package>
            <Package name='zvbi' type='yum'>
                <Instance verify_flags='nomtime' epoch='0'
		version='0.2.22' release='5.0.el5' arch='x86_64'/>
            </Package>
        </Group>
    </Group>
</PackageList>

Thanks!
-- 
Axel.Thimm at ATrpms.net



More information about the Yum mailing list