Add a function for adding repos to the yum object.
This allows us to re-use the code if we add repos later, like the repo we just gathered and createrepod
This commit is contained in:
parent
4002565f53
commit
7a8ab8817a
@ -139,6 +139,66 @@ class Pungi(pypungi.PungiBase):
|
|||||||
self.last_po = 0
|
self.last_po = 0
|
||||||
self.resolved_deps = {} # list the deps we've already resolved, short circuit.
|
self.resolved_deps = {} # list the deps we've already resolved, short circuit.
|
||||||
|
|
||||||
|
def _add_yum_repo(self, name, url, mirrorlist=False, groups=True,
|
||||||
|
cost=1000, includepkgs=[], excludepkgs=[],
|
||||||
|
proxy=None):
|
||||||
|
"""This function adds a repo to the yum object.
|
||||||
|
|
||||||
|
name: Name of the repo
|
||||||
|
|
||||||
|
url: Full url to the repo
|
||||||
|
|
||||||
|
mirrorlist: Bool for whether or not url is a mirrorlist
|
||||||
|
|
||||||
|
groups: Bool for whether or not to use groupdata from this repo
|
||||||
|
|
||||||
|
cost: an optional int representing the cost of a repo
|
||||||
|
|
||||||
|
includepkgs: An optional list of includes to use
|
||||||
|
|
||||||
|
excludepkgs: An optional list of excludes to use
|
||||||
|
|
||||||
|
proxy: An optional proxy to use
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.logger.info('Adding repo %s' % name)
|
||||||
|
thisrepo = yum.yumRepo.YumRepository(name)
|
||||||
|
thisrepo.name = name
|
||||||
|
# add excludes and such here when pykickstart gets them
|
||||||
|
if mirrorlist:
|
||||||
|
thisrepo.mirrorlist = yum.parser.varReplace(url,
|
||||||
|
self.ayum.conf.yumvar)
|
||||||
|
self.mirrorlists.append(thisrepo.mirrorlist)
|
||||||
|
self.logger.info('Mirrorlist for repo %s is %s' %
|
||||||
|
(thisrepo.name, thisrepo.mirrorlist))
|
||||||
|
else:
|
||||||
|
thisrepo.baseurl = yum.parser.varReplace(url,
|
||||||
|
self.ayum.conf.yumvar)
|
||||||
|
self.repos.extend(thisrepo.baseurl)
|
||||||
|
self.logger.info('URL for repo %s is %s' %
|
||||||
|
(thisrepo.name, thisrepo.baseurl))
|
||||||
|
thisrepo.basecachedir = self.ayum.conf.cachedir
|
||||||
|
thisrepo.enablegroups = groups
|
||||||
|
# This is until yum uses this failover by default
|
||||||
|
thisrepo.failovermethod = 'priority'
|
||||||
|
thisrepo.exclude = excludepkgs
|
||||||
|
thisrepo.includepkgs = includepkgs
|
||||||
|
thisrepo.cost = cost
|
||||||
|
# Yum doesn't like proxy being None
|
||||||
|
if proxy:
|
||||||
|
thisrepo.proxy = proxy
|
||||||
|
self.ayum.repos.add(thisrepo)
|
||||||
|
self.ayum.repos.enableRepo(thisrepo.id)
|
||||||
|
self.ayum._getRepos(thisrepo=thisrepo.id, doSetup=True)
|
||||||
|
# Set the repo callback.
|
||||||
|
self.ayum.repos.setProgressBar(CallBack())
|
||||||
|
self.ayum.repos.callback = CallBack()
|
||||||
|
thisrepo.metadata_expire = 0
|
||||||
|
thisrepo.mirrorlist_expire = 0
|
||||||
|
if os.path.exists(os.path.join(thisrepo.cachedir, 'repomd.xml')):
|
||||||
|
os.remove(os.path.join(thisrepo.cachedir, 'repomd.xml'))
|
||||||
|
|
||||||
def _inityum(self):
|
def _inityum(self):
|
||||||
"""Initialize the yum object. Only needed for certain actions."""
|
"""Initialize the yum object. Only needed for certain actions."""
|
||||||
|
|
||||||
@ -198,42 +258,25 @@ class Pungi(pypungi.PungiBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
for repo in self.ksparser.handler.repo.repoList:
|
for repo in self.ksparser.handler.repo.repoList:
|
||||||
self.logger.info('Adding repo %s' % repo.name)
|
|
||||||
thisrepo = yum.yumRepo.YumRepository(repo.name)
|
|
||||||
thisrepo.name = repo.name
|
|
||||||
# add excludes and such here when pykickstart gets them
|
|
||||||
if repo.mirrorlist:
|
if repo.mirrorlist:
|
||||||
thisrepo.mirrorlist = yum.parser.varReplace(repo.mirrorlist, self.ayum.conf.yumvar)
|
# The not bool() thing is because pykickstart is yes/no on
|
||||||
self.mirrorlists.append(thisrepo.mirrorlist)
|
# whether to ignore groups, but yum is a yes/no on whether to
|
||||||
self.logger.info('Mirrorlist for repo %s is %s' % (thisrepo.name, thisrepo.mirrorlist))
|
# include groups. Awkward.
|
||||||
|
self._add_yum_repo(repo.name, repo.mirrorlist,
|
||||||
|
mirrorlist=True,
|
||||||
|
groups=not bool(repo.ignoregroups),
|
||||||
|
cost=repo.cost,
|
||||||
|
includepkgs=repo.includepkgs,
|
||||||
|
excludepkgs=repo.excludepkgs,
|
||||||
|
proxy=repo.proxy)
|
||||||
else:
|
else:
|
||||||
thisrepo.baseurl = yum.parser.varReplace(repo.baseurl, self.ayum.conf.yumvar)
|
self._add_yum_repo(repo.name, repo.baseurl,
|
||||||
self.repos.extend(thisrepo.baseurl)
|
mirrorlist=False,
|
||||||
self.logger.info('URL for repo %s is %s' % (thisrepo.name, thisrepo.baseurl))
|
groups=not bool(repo.ignoregroups),
|
||||||
thisrepo.basecachedir = self.ayum.conf.cachedir
|
cost=repo.cost,
|
||||||
thisrepo.enablegroups = True
|
includepkgs=repo.includepkgs,
|
||||||
thisrepo.failovermethod = 'priority' # This is until yum uses this failover by default
|
excludepkgs=repo.excludepkgs,
|
||||||
thisrepo.exclude = repo.excludepkgs
|
proxy=repo.proxy)
|
||||||
thisrepo.includepkgs = repo.includepkgs
|
|
||||||
if repo.cost:
|
|
||||||
thisrepo.cost = repo.cost
|
|
||||||
if repo.ignoregroups:
|
|
||||||
thisrepo.enablegroups = 0
|
|
||||||
if repo.proxy:
|
|
||||||
thisrepo.proxy = repo.proxy
|
|
||||||
self.ayum.repos.add(thisrepo)
|
|
||||||
self.ayum.repos.enableRepo(thisrepo.id)
|
|
||||||
self.ayum._getRepos(thisrepo=thisrepo.id, doSetup = True)
|
|
||||||
|
|
||||||
self.ayum.repos.setProgressBar(CallBack())
|
|
||||||
self.ayum.repos.callback = CallBack()
|
|
||||||
|
|
||||||
# Set the metadata and mirror list to be expired so we always get new ones.
|
|
||||||
for repo in self.ayum.repos.listEnabled():
|
|
||||||
repo.metadata_expire = 0
|
|
||||||
repo.mirrorlist_expire = 0
|
|
||||||
if os.path.exists(os.path.join(repo.cachedir, 'repomd.xml')):
|
|
||||||
os.remove(os.path.join(repo.cachedir, 'repomd.xml'))
|
|
||||||
|
|
||||||
self.logger.info('Getting sacks for arches %s' % arches)
|
self.logger.info('Getting sacks for arches %s' % arches)
|
||||||
self.ayum._getSacks(archlist=arches)
|
self.ayum._getSacks(archlist=arches)
|
||||||
|
Loading…
Reference in New Issue
Block a user