[yum-cvs] yum/yum __init__.py,1.327,1.328 repos.py,1.105,1.106
Jeremy Katz
katzj at linux.duke.edu
Tue May 29 15:52:35 UTC 2007
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv25536/yum
Modified Files:
__init__.py repos.py
Log Message:
Basic idea is that we move the repo setup into the RepoStorage object
instead of the YumBase object.
And we end up kicking off the real repo setup when either
a) someone explicitly calls YumBase.doRepoSetup()
b) we go to populate package sacks based on the repos.
This fixes things so that the presto callbacks continue to work without
requiring API changes in presto (rh#236512)
Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.327
retrieving revision 1.328
diff -u -r1.327 -r1.328
--- __init__.py 16 May 2007 21:02:03 -0000 1.327
+++ __init__.py 29 May 2007 15:52:33 -0000 1.328
@@ -71,7 +71,7 @@
self._pkgSack = None
self.logger = logging.getLogger("yum.YumBase")
self.verbose_logger = logging.getLogger("yum.verbose.YumBase")
- self._repos = None
+ self._repos = RepoStorage(self)
# Start with plugins disabled
self.disablePlugins()
@@ -182,8 +182,7 @@
#FIXME this method could be a simpler
- self.conf._reposlist = []
-
+ reposlist = []
# Check yum.conf for repositories
for section in self.conf.cfg.sections():
# All sections except [main] are repositories
@@ -195,7 +194,7 @@
except (Errors.RepoError, Errors.ConfigError), e:
self.logger.warning(e)
else:
- self.conf._reposlist.append(thisrepo)
+ reposlist.append(thisrepo)
# Read .repo files from directories specified by the reposdir option
# (typically /etc/yum/repos.d)
@@ -220,8 +219,15 @@
except (Errors.RepoError, Errors.ConfigError), e:
self.logger.warning(e)
else:
- self.conf._reposlist.append(thisrepo)
+ reposlist.append(thisrepo)
+ # Got our list of repo objects, add them to the repos collection
+ for thisrepo in reposlist:
+ try:
+ self._repos.add(thisrepo)
+ except Errors.RepoError, e:
+ self.logger.warning(e)
+ continue
def readRepoConfig(self, parser, section):
'''Parse an INI file section for a repository.
@@ -314,40 +320,9 @@
"""grabs the repomd.xml for each enabled repository and sets up
the basics of the repository"""
- if not self._repos:
- self._repos = RepoStorage()
- # Get our list of repo objects from conf, add them to the repos collection
- for r in self.conf._reposlist:
- try:
- self._repos.add(r)
- except Errors.RepoError, e:
- self.logger.warning(e)
- continue
- elif not doSetup:
- return self._repos
-
- self.plugins.run('prereposetup')
-
- if thisrepo is None:
- repos = self._repos.listEnabled()
- else:
- repos = self._repos.findRepos(thisrepo)
-
- if len(repos) < 1:
- self.logger.critical('No Repositories Available to Set Up')
-
- num = 1
- for repo in repos:
- repo.setup(self.conf.cache, self.mediagrabber)
- num += 1
-
-
- if self._repos.callback and len(repos) > 0:
- self._repos.callback.progressbar(num, len(repos), repo.id)
-
- self.plugins.run('postreposetup')
+ if doSetup:
+ self._repos.doSetup(thisrepo)
return self._repos
-
def doSackSetup(self, archlist=None, thisrepo=None):
warnings.warn('doSackSetup() will go away in a future version of Yum.\n',
Index: repos.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- repos.py 25 Apr 2007 18:28:31 -0000 1.105
+++ repos.py 29 May 2007 15:52:33 -0000 1.106
@@ -27,13 +27,39 @@
"""This class contains multiple repositories and core configuration data
about them."""
- def __init__(self):
+ def __init__(self, ayum):
self.repos = {} # list of repos by repoid pointing a repo object
# of repo options/misc data
self.callback = None # progress callback used for populateSack() for importing the xml files
self.cache = 0
self.pkgSack = MetaSack()
+ self._setup = False
+
+ self.ayum = ayum
+
+ def doSetup(self, thisrepo = None):
+ self.ayum.plugins.run('prereposetup')
+
+ if thisrepo is None:
+ repos = self.listEnabled()
+ else:
+ repos = self.findRepos(thisrepo)
+
+ if len(repos) < 1:
+ self.logger.critical('No Repositories Available to Set Up')
+
+ num = 1
+ for repo in repos:
+ repo.setup(self.ayum.conf.cache, self.ayum.mediagrabber)
+ num += 1
+
+
+ if self.callback and len(repos) > 0:
+ self.callback.progressbar(num, len(repos), repo.id)
+
+ self._setup = True
+ self.ayum.plugins.run('postreposetup')
def __str__(self):
return str(self.repos.keys())
@@ -177,6 +203,9 @@
arguments: which='repoid, enabled, all'
mdtype='metadata, filelists, otherdata, all'"""
+ if not self._setup:
+ self.doSetup()
+
if not callback:
callback = self.callback
myrepos = []
More information about the Yum-cvs-commits
mailing list