[yum-commits] Branch 'yum-3_2_X' - 2 commits - docs/yum.conf.5 yum/misc.py yum/packages.py yum/yumRepo.py

James Antill james at osuosl.org
Mon Mar 2 22:46:13 UTC 2009


 docs/yum.conf.5 |    5 +++++
 yum/misc.py     |   12 ++++++++++++
 yum/packages.py |   22 ++++------------------
 yum/yumRepo.py  |   18 ++++++++++++++++++
 4 files changed, 39 insertions(+), 18 deletions(-)

New commits:
commit 64fd03f4111c250b36342000c5248d871e54b42b
Author: James Antill <james at and.org>
Date:   Mon Mar 2 17:41:34 2009 -0500

    Add hack for mirrorlist to treat as metalink, for anaconda

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index c8a634c..3a03d6b 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -441,11 +441,16 @@ checksum data. This data is checked against any downloaded repomd.xml file
 and all of the information from the metalink file must match. This can be used
 instead of or with the \fBbaseurl\fR option. Substitution variables, described
 below, can be used with this option. This option disables the mirrorlist option.
+As a special hack is the mirrorlist URL contains the word "metalink" then the
+value of mirrorlist is copied to metalink (if metalink is not set).
 
 .IP \fBmirrorlist\fR
 Specifies a URL to a file containing a list of baseurls. This can be used
 instead of or with the \fBbaseurl\fR option. Substitution variables, described
 below, can be used with this option. 
+As a special hack is the mirrorlist URL contains the word "metalink" then the
+value of mirrorlist is copied to metalink (if metalink is not set).
+
 
 .IP \fBenabled\fR
 Either `1' or `0'. This tells yum whether or not use this repository.
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 964f19d..24b3b04 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -555,6 +555,21 @@ 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"""
@@ -566,6 +581,7 @@ 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()))
@@ -1103,6 +1119,7 @@ class YumRepository(Repository, config.RepoConf):
         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
 
@@ -1365,6 +1382,7 @@ class YumRepository(Repository, config.RepoConf):
         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)
commit 263e29c28960e58c1aed3f71d0497b254d76688c
Author: James Antill <james at and.org>
Date:   Mon Mar 2 15:13:46 2009 -0500

    Add misc.re_primary_dirname and use misc.re_* for _return_primary_dirs/_files

diff --git a/yum/misc.py b/yum/misc.py
index 94ad708..eeb142f 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -91,6 +91,18 @@ def re_primary_filename(filename):
             return True
     return False
 
+_re_compiled_pri_dnames_match = None
+def re_primary_dirname(dirname):
+    global _re_compiled_pri_dnames_match
+    if _re_compiled_pri_dnames_match is None:
+        one   = re.compile('.*bin\/.*')
+        two   = re.compile('^\/etc\/.*')
+        _re_compiled_pri_dnames_match = (one, two)
+    for rec in _re_compiled_pri_dnames_match:
+        if rec.match(dirname):
+            return True
+    return False
+
 _re_compiled_full_match = None
 def re_full_search_needed(s):
     """ Tests if a string needs a full nevra match, instead of just name. """
diff --git a/yum/packages.py b/yum/packages.py
index 89a9d46..bcdb129 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -871,37 +871,23 @@ class YumAvailablePackage(PackageObject, RpmBase):
         return msg
     
     def _return_primary_files(self, list_of_files=None):
-        fileglobs = ['.*bin\/.*', '^\/etc\/.*', '^\/usr\/lib\/sendmail$']
-        file_re = []
-        for glob in fileglobs:
-            file_re.append(re.compile(glob))        
-
-
         returns = {}
         if list_of_files is None:
             list_of_files = self.returnFileEntries('file')
         for item in list_of_files:
             if item is None:
                 continue
-            for glob in file_re:
-                if glob.match(item):
-                    returns[item] = 1
+            if misc.re_primary_filename(item):
+                returns[item] = 1
         return returns.keys()
 
     def _return_primary_dirs(self):
-        dirglobs = ['.*bin\/.*', '^\/etc\/.*']
-        dir_re = []
-        
-        for glob in dirglobs:
-            dir_re.append(re.compile(glob))
-
         returns = {}
         for item in self.returnFileEntries('dir'):
             if item is None:
                 continue
-            for glob in dir_re:
-                if glob.match(item):
-                    returns[item] = 1
+            if misc.re_primary_dirname(item):
+                returns[item] = 1
         return returns.keys()
         
         


More information about the Yum-commits mailing list