Yum api从组列表中获取包

时间:2015-01-22 10:44:25

标签: linux python-2.7 yum

如何获取“base”组中的包列表?

import yum
yb = yum.YumBase()
yb.disablePlugins()
yb.setCacheDir()
repos = yb.repos.listEnabled()
destdir="/tmp/repo"
arch = "x86_64"
repoid="Myrepo"
baseurl="http://mirror.yandex.ru/centos/6.6/os/%s" % (arch)
imgurl="%s/images/install.img" % (baseurl)
repopath="Myrepo"
cachedir = "/tmp"     #yum.misc.getCacheDir()
yb.repos.setCacheDir(cachedir)
newrepo = yum.yumRepo.YumRepository(repoid)
newrepo.name = repopath
newrepo.baseurl = baseurl
newrepo.mirrorlist = None
newrepo.basecachedir = cachedir
newrepo.metadata_expire = 0
newrepo.timestamp_check = False
yb.repos.add(newrepo)
yb.repos.enableRepo(newrepo.id)
yb.repos.doSetup()
yb.cleanRpmDB()
XM = yb.selectGroup(grpid='base')
print XM

输出:

[]  警告:组基础没有要安装的任何软件包。

处理完成,退出代码为0

0 个答案:

没有答案