[yum-git] cli.py yumcommands.py yum/__init__.py

Seth Vidal skvidal at linux.duke.edu
Mon Feb 4 22:33:42 UTC 2008


 cli.py          |    2 +-
 yum/__init__.py |   24 ++++++++++++++++++++++++
 yumcommands.py  |    6 +-----
 3 files changed, 26 insertions(+), 6 deletions(-)

New commits:
commit 4c6a643fa77617a6a5508de1fdd7167a18880fc1
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Mon Feb 4 17:32:20 2008 -0500

    make reinstall a base method and clean up its error handling.

diff --git a/cli.py b/cli.py
index e7b2c6c..e67ed22 100644
--- a/cli.py
+++ b/cli.py
@@ -389,7 +389,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         dscb = self.dsCallback
         self.dsCallback = None # dumb, dumb dumb dumb!
         self.populateTs(keepold=0) # sigh
-        tserrors = self.ts.test(testcb, conf=tsConf)
+        tserrors = self.ts.test(testcb)
         del testcb
         
         self.verbose_logger.log(yum.logginglevels.INFO_2,
diff --git a/yum/__init__.py b/yum/__init__.py
index 14c893f..aa6d55e 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2428,6 +2428,30 @@ class YumBase(depsolve.Depsolve):
 
         return tx_return
 
+    def reinstall(self, po=None, **kwargs):
+        """Setup the problem filters to allow a reinstall to work, then
+           pass everything off to install"""
+           
+        if rpm.RPMPROB_FILTER_REPLACEPKG not in self.tsInfo.probFilterFlags:
+            self.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACEPKG)
+        if rpm.RPMPROB_FILTER_REPLACENEWFILES not in self.tsInfo.probFilterFlags:
+            self.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACENEWFILES)
+        if rpm.RPMPROB_FILTER_REPLACEOLDFILES not in self.tsInfo.probFilterFlags:
+            self.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACEOLDFILES)
+
+        tx_mbrs = []
+        tx_mbrs.extend(self.remove(po, **kwargs))
+        if not tx_mbrs:
+            raise Errors.RemoveError, _("Problem in reinstall: no package matched to remove")
+        templen = len(tx_mbrs)
+        tx_mbrs.extend(self.install(po, **kwargs))
+        if len(tx_mbrs) == templen:
+            raise Errors.RemoveError, _("Problem in reinstall: no package matched to install")
+
+        return tx_mbrs
+        
+
+        
     def _nevra_kwarg_parse(self, kwargs):
             
         returndict = {}
diff --git a/yumcommands.py b/yumcommands.py
index 987992b..2a1247a 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -741,13 +741,9 @@ class ReInstallCommand(YumCommand):
         base.verbose_logger.log(logginglevels.INFO_2, 
                 "Setting up Reinstall Process")
         oldcount = len(base.tsInfo)
-        base.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACEPKG)
-        base.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACENEWFILES)
-        base.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_REPLACEOLDFILES) 
         try:
             for item in extcmds:
-                base.remove(pattern=item)
-                base.install(pattern=item)
+                base.reinstall(pattern=item)
 
             if len(base.tsInfo) > oldcount:
                 return 2, [_('Package(s) to install')]



More information about the Yum-cvs-commits mailing list