[yum-commits] Branch 'yum-3_2_X' - 3 commits - test/testbase.py yum/config.py yum/depsolve.py yum/__init__.py yum/yumRepo.py

James Antill james at osuosl.org
Wed Oct 7 13:34:48 UTC 2009


 test/testbase.py |    1 +
 yum/__init__.py  |   21 ++++++++++++---------
 yum/config.py    |    5 ++---
 yum/depsolve.py  |    1 +
 yum/yumRepo.py   |   37 ++++++++++++++++++-------------------
 5 files changed, 34 insertions(+), 31 deletions(-)

New commits:
commit 108ff72bb248bb9f6c67e800aceeb0e320a66ee7
Author: James Antill <james at and.org>
Date:   Tue Oct 6 17:33:20 2009 -0400

    Add a yumdb_info dict to FakePackage()

diff --git a/test/testbase.py b/test/testbase.py
index cadc28b..3edfe57 100644
--- a/test/testbase.py
+++ b/test/testbase.py
@@ -79,6 +79,7 @@ class FakePackage(packages.YumAvailablePackage):
         self.epoch = epoch
         self.arch = arch
         self.pkgtup = (self.name, self.arch, self.epoch, self.version, self.release)
+        self.yumdb_info = {}
 
         self.prco['provides'].append((name, 'EQ', (epoch, version, release)))
 
commit 950ea447f9dc876930284bfa48198f6ce99066ef
Author: James Antill <james at and.org>
Date:   Tue Oct 6 17:16:24 2009 -0400

    Make mdpolicy to be a list, to give users/callers greater control

diff --git a/yum/config.py b/yum/config.py
index 63b3d17..ae294d3 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -667,9 +667,8 @@ class YumConf(StartupConf):
     skip_broken = BoolOption(False)
     #  Note that "instant" is the old behaviour, but group:primary is very
     # similar but better :).
-    mdpolicy = SelectionOption('group:primary',
-                               ('instant', 'group:all', 'group:main',
-                                'group:small', 'group:primary'))
+    mdpolicy = ListOption(['group:primary'])
+    #  ('instant', 'group:all', 'group:main', 'group:small', 'group:primary'))
     multilib_policy = SelectionOption('all',('best', 'all'))
                  # all == install any/all arches you can
                  # best == use the 'best  arch' for the system
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 4658702..feb1f7d 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1355,13 +1355,6 @@ class YumRepository(Repository, config.RepoConf):
         self._doneOldRepoXML()
         return True
 
-    def _instantLoadRepoXML(self, text=None):
-        """ Retrieve the new repomd.xml from the repository, then check it
-            and parse it. If it fails revert.
-            Mostly traditional behaviour. """
-        if self._commonLoadRepoXML(text):
-            self._commonRetrieveDataMD([])
-
     def _groupLoadRepoXML(self, text=None, mdtypes=None):
         """ Retrieve the new repomd.xml from the repository, then check it
             and parse it. If it fails we revert to the old version and pretend
@@ -1375,19 +1368,25 @@ class YumRepository(Repository, config.RepoConf):
 
     def _loadRepoXML(self, text=None):
         """retrieve/check/read in repomd.xml from the repository"""
+        md_groups = {'instant'       : [],
+                     'group:primary' : ['primary'],
+                     'group:small'   : ["primary", "updateinfo"],
+                     'group:main'    : ["primary", "group", "filelists",
+                                        "updateinfo", "prestodelta"]}
+        mdtypes = set()
+        if type(self.mdpolicy) in types.StringTypes:
+            mdtypes.update(md_groups.get(self.mdpolicy, [self.mdpolicy]))
+        else:
+            for mdpolicy in self.mdpolicy:
+                mdtypes.update(md_groups.get(mdpolicy, [mdpolicy]))
+
+        if not mdtypes or 'group:all' in mdtypes:
+            mdtypes = None
+        else:
+            mdtypes = sorted(list(mdtypes))
+
         try:
-            if self.mdpolicy in ["instant"]:
-                return self._instantLoadRepoXML(text)
-            if self.mdpolicy in ["group:all"]:
-                return self._groupLoadRepoXML(text)
-            if self.mdpolicy in ["group:main"]:
-                return self._groupLoadRepoXML(text, ["primary", "group",
-                                                     "filelists", "updateinfo",
-                                                     "prestodelta"])
-            if self.mdpolicy in ["group:small"]:
-                return self._groupLoadRepoXML(text, ["primary", "updateinfo"])
-            if self.mdpolicy in ["group:primary"]:
-                return self._groupLoadRepoXML(text, ["primary"])
+            return self._groupLoadRepoXML(text, mdtypes)
         except KeyboardInterrupt:
             self._revertOldRepoXML() # Undo metadata cookie?
             raise
commit 56b17c3a8199537c45851f0b558c25f8cf5fcff3
Author: James Antill <james at and.org>
Date:   Tue Oct 6 16:31:10 2009 -0400

    Preserve "reason=dep" across updates and add it for dep. installs.

diff --git a/yum/__init__.py b/yum/__init__.py
index a5b4922..79383a5 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2932,6 +2932,14 @@ class YumBase(depsolve.Depsolve):
                 self.tsInfo.remove(txmbr.po.pkgtup)
         return found
 
+    def _add_up_txmbr(self, requiringPo, upkg, ipkg):
+        txmbr = self.tsInfo.addUpdate(upkg, ipkg)
+        if requiringPo:
+            txmbr.setAsDep(requiringPo)
+        if ('reason' in ipkg.yumdb_info and ipkg.yumdb_info.reason == 'dep'):
+            txmbr.reason = 'dep'
+        return txmbr
+
     def update(self, po=None, requiringPo=None, **kwargs):
         """try to mark for update the item(s) specified. 
             po is a package object - if that is there, mark it for update,
@@ -3097,9 +3105,7 @@ class YumBase(depsolve.Depsolve):
                         self.tsInfo.addObsoleted(obsoletee, po)
                         tx_return.append(txmbr)
                 else:
-                    txmbr = self.tsInfo.addUpdate(po, installed_pkg)
-                    if requiringPo:
-                        txmbr.setAsDep(requiringPo)
+                    txmbr = self._add_up_txmbr(requiringPo, po, installed_pkg)
                     tx_return.append(txmbr)
                         
         for available_pkg in availpkgs:
@@ -3122,9 +3128,8 @@ class YumBase(depsolve.Depsolve):
                 
                 else:
                     updated_pkg =  self.getInstalledPackageObject(updated)
-                    txmbr = self.tsInfo.addUpdate(available_pkg, updated_pkg)
-                    if requiringPo:
-                        txmbr.setAsDep(requiringPo)
+                    txmbr = self._add_up_txmbr(requiringPo,
+                                               available_pkg, updated_pkg)
                     tx_return.append(txmbr)
                     
             # check to see if the pkg we want to install is not _quite_ the newest
@@ -3147,9 +3152,7 @@ class YumBase(depsolve.Depsolve):
                     self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s'), 
                                             ipkg.pkgtup)
                 elif ipkg.verLT(available_pkg):
-                    txmbr = self.tsInfo.addUpdate(available_pkg, ipkg)
-                    if requiringPo:
-                        txmbr.setAsDep(requiringPo)
+                    txmbr = self._add_up_txmbr(requiringPo, available_pkg, ipkg)
                     tx_return.append(txmbr)
 
         return tx_return
diff --git a/yum/depsolve.py b/yum/depsolve.py
index c5baacb..8bed47c 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -584,6 +584,7 @@ class Depsolve(object):
             # FIXME: Don't we want .install() here, so obsoletes get done?
             txmbr = self.tsInfo.addInstall(best)
             txmbr.setAsDep(po=requiringPo)
+            txmbr.reason = "dep"
             self._last_req = best
 
             # if we had other packages with this name.arch that we found


More information about the Yum-commits mailing list