Re: Recursing on repos

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pirla <the.pirla@xxxxxxx> writes:

> Hi all,
> I would like to do something simple...
>
> I would like a script that:
>  disable all repos
>  recurse on every repos and enable one repo at once
>   retrieve a list from the enabled repo
>   disable the repo
>   go to the next repo and do the same things.
>
> I coded this, but it do not work
>
> import yum, os, sys
> yb = yum.YumBase()
> yb.conf.cache = os.geteuid() != 1

 This means if you run it as root it shouldn't speak to the network,
so will only work if you have the primary DB from all the repos. you
have configured.

> for repo in sorted(yb.repos.disableRepo('*')):
>  print "----", repo
>  yb.repos.enableRepo(repo)
>  for enabrepo in yb.repos.listEnabled():
>   print "Abilitato ",enabrepo,"\n"
>  pkgs = yb.pkgSack.returnPackages()
>  for pkg in pkgs:
>   print pkg.name, pkg.ver, pkg.rel, pkg.arch, pkg.repo
>  yb.repos.disableRepo(repo)
>  print "repo disabilitato", repo
>
> I have two kinds of errors.
>  first... 
>   in every package I receive the same package from the first repo

 This is because enable/disable doesn't work as you think it does
above, yb.pkgSack is a Metasack (class defined in packageSack.py) and
that adds the data behind each repo. via. addSack() ... and AFAIK
there is no way to get rid of it with an API.
 Here is how I'd probably do it:

import yum, os, sys
yb = yum.YumBase()
yb.repos.setCacheDir(yum.misc.getCacheDir())

for repo in yb.repos.enableRepo('*'):
    for pkg in yb.pkgSack.returnPackages(repoid=repo):
        print pkg.name, pkg.ver, pkg.rel, pkg.arch, pkg.repo
    yb.pkgSack.dropCachedData()

-- 
James Antill -- james@xxxxxxx
_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxx
http://lists.baseurl.org/mailman/listinfo/yum

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux