[Yum-devel] [PATCH] metalink hack: 4 => 1

Zdeněk Pavlas zpavlas at redhat.com
Thu Sep 29 09:32:18 UTC 2011


Set up metalink earlier, to avoid calling _hack_mirrorlist_for_anaconda()
at four different places.
---
 yum/__init__.py |    9 +++++++++
 yum/yumRepo.py  |   19 -------------------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 5fb7c00..45130e9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -539,6 +539,15 @@ class YumBase(depsolve.Depsolve):
         repo.yumvar.update(self.conf.yumvar)
         repo.cfg = parser
 
+        #  Anaconda doesn't like having mirrorlist and metalink, so we allow
+        # mirrorlist to act like metalink. Except we'd really like to know which
+        # we have without parsing it ... and want to store it in the right
+        # place etc.
+        #  So here is #1 hack: see if the metalink is unset and the mirrorlist
+        # URL contains the string "metalink", if it does we copy it over.
+        if not repo.metalink and 'metalink' in (repo.mirrorlist or ''):
+            repo.metalink = repo.mirrorlist
+
         return repo
 
     def disablePlugins(self):
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 91b7dde..6042a51 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -621,21 +621,6 @@ class YumRepository(Repository, config.RepoConf):
                 Errors.YumFutureDeprecationWarning, stacklevel=2)
         self._baseurlSetup()
 
-    def _hack_mirrorlist_for_anaconda(self):
-        #  Anaconda doesn't like having mirrorlist and metalink, so we allow
-        # mirrorlist to act like metalink. Except we'd really like to know which
-        # we have without parsing it ... and want to store it in the right
-        # place etc.
-        #  So here is #1 hack: see if the metalin kis unset and the mirrorlist
-        # URL contains the string "metalink", if it does we copy it over.
-        if self.metalink:
-            return
-        if not self.mirrorlist:
-            return
-        if self.mirrorlist.find("metalink") == -1:
-            return
-        self.metalink = self.mirrorlist
-
     def _baseurlSetup(self):
         """go through the baseurls and mirrorlists and populate self.urls
            with valid ones, run  self.check() at the end to make sure it worked"""
@@ -647,7 +632,6 @@ class YumRepository(Repository, config.RepoConf):
         self._orig_baseurl = self.baseurl
 
         mirrorurls = []
-        self._hack_mirrorlist_for_anaconda()
         if self.metalink and not self.mirrorlistparsed:
             # FIXME: This is kind of lying to API callers
             mirrorurls.extend(list(self.metalink_data.urls()))
@@ -916,7 +900,6 @@ Insufficient space in download directory %s
             self._metadataCurrent = False
             return False
 
-        self._hack_mirrorlist_for_anaconda()
         mlfn = self.cachedir + '/' + 'metalink.xml'
         if self.metalink and not os.path.exists(mlfn):
             self._metadataCurrent = False
@@ -1216,7 +1199,6 @@ Insufficient space in download directory %s
         if not oxml: # No old repomd.xml data
             return False
 
-        self._hack_mirrorlist_for_anaconda()
         if not self.metalink: # Nothing to check it against
             return False
 
@@ -1516,7 +1498,6 @@ Insufficient space in download directory %s
         except Errors.RepoMDError, e:
             raise URLGrabError(-1, 'Error importing repomd.xml for %s: %s' % (self, e))
 
-        self._hack_mirrorlist_for_anaconda()
         if self.metalink and not self._checkRepoMetalink(repoXML):
             raise URLGrabError(-1, 'repomd.xml does not match metalink for %s' %
                                self)
-- 
1.7.4.4



More information about the Yum-devel mailing list