[yum-git] 2 commits - cli.py rpmUtils/transaction.py yumcommands.py

Seth Vidal skvidal at linux.duke.edu
Mon Feb 4 21:17:00 UTC 2008


 cli.py                  |    8 +++++---
 rpmUtils/transaction.py |   12 +++++++-----
 yumcommands.py          |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 8 deletions(-)

New commits:
commit cd0948d87dd6cba834f44fa00be5bac4bf5e8c4a
Merge: df3868c... d5d941e...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Mon Feb 4 16:15:40 2008 -0500

    Merge branch 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum
    
    * 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum:
      Only show URL if it has one, Ie. glibc

commit df3868cea5909caa69a81bc18b5e639d60c27416
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Mon Feb 4 16:15:16 2008 -0500

    implement a 'reinstall'.
    It does not work automatically and it clearly shouldn't. reinstall
    is a weird and special case and should be treated as such.

diff --git a/cli.py b/cli.py
index 92dd2d2..e7b2c6c 100644
--- a/cli.py
+++ b/cli.py
@@ -26,6 +26,7 @@ import time
 import random
 import logging
 from optparse import OptionParser
+import rpm
 
 import output
 import shell
@@ -94,6 +95,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         self.registerCommand(yumcommands.DepListCommand())
         self.registerCommand(yumcommands.RepoListCommand())
         self.registerCommand(yumcommands.HelpCommand())
+        self.registerCommand(yumcommands.ReInstallCommand())        
 
     def registerCommand(self, command):
         for name in command.getNames():
@@ -376,9 +378,9 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
             
         self.verbose_logger.log(yum.logginglevels.INFO_2,
             _('Running Transaction Test'))
-        tsConf = {}
-        for feature in ['diskspacecheck']: # more to come, I'm sure
-            tsConf[feature] = getattr(self.conf, feature)
+        if self.conf.diskspacecheck == False:
+            self.tsInfo.problemFilterFlags.append(rpm.RPMPROB_FILTER_DISKSPACE)
+            
         
         testcb = RPMTransaction(self, test=True)
         
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index bb481e6..7e231a7 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -82,19 +82,21 @@ class TransactionWrapper:
     def addTsFlag(self, flag):
         curflags = self.ts.setFlags(0)
         self.ts.setFlags(curflags | flag)
+
+#    def addProblemFilter(self, filt):
+#        curfilter = self.ts.setProbFilter(0)
+#        self.ts.setProbFilter(cutfilter | filt)    
         
     def test(self, cb, conf={}):
         """tests the ts we've setup, takes a callback function and a conf dict 
            for flags and what not"""
-        #FIXME
-        # I don't like this function - it should test, sure - but not
-        # with this conf dict, we should be doing that beforehand and
-        # we should be packing this information away elsewhere.
+    
         self.addTsFlag(rpm.RPMTRANS_FLAG_TEST)
+        # FIXME GARBAGE - remove once this is reimplemented elsehwere
+        # KEEPING FOR API COMPLIANCE ONLY
         if conf.has_key('diskspacecheck'):
             if conf['diskspacecheck'] == 0:
                 self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
-    
         tserrors = self.ts.run(cb.callback, '')
     
         reserrors = []
diff --git a/yumcommands.py b/yumcommands.py
index 22599c3..987992b 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -24,6 +24,8 @@ import cli
 from yum import logginglevels
 import yum.Errors
 from yum.i18n import _
+import rpm
+
 
 def checkRootUID(base):
     """
@@ -722,3 +724,42 @@ class HelpCommand(YumCommand):
 
     def needTs(self, base, basecmd, extcmds):
         return False
+
+class ReInstallCommand(YumCommand):
+    def getNames(self):
+        return ['reinstall']
+
+    def getUsage(self):
+        return "PACKAGE..."
+
+    def doCheck(self, base, basecmd, extcmds):
+        checkRootUID(base)
+        checkGPGKey(base)
+        checkPackageArg(base, basecmd, extcmds)
+
+    def doCommand(self, base, basecmd, extcmds):
+        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)
+
+            if len(base.tsInfo) > oldcount:
+                return 2, [_('Package(s) to install')]
+            return 0, [_('Nothing to do')]            
+            
+        except yum.Errors.YumBaseError, e:
+            return 1, [str(e)]
+
+    def getSummary(self):
+        return "reinstall a package"
+
+
+    def needTs(self, base, basecmd, extcmds):
+        return False
+        



More information about the Yum-cvs-commits mailing list