[yum-git] Branch 'yum-3_2_X' - cli.py yum/__init__.py yummain.py

Seth Vidal skvidal at linux.duke.edu
Wed Jul 16 18:07:37 UTC 2008


 cli.py          |    4 ++--
 yum/__init__.py |    8 +++++++-
 yummain.py      |    4 ++--
 3 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit cbd52324de549f77902fdc11c15d332e89fda5b0
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Jul 16 14:05:21 2008 -0400

    return non-zero exit code if the rpm transaction has semi-fatal scriptlet failures.
    adds a fake resultobject returned from runTransaction() so that any future extensions we add
    can be bolted onto the object. resultobject.return_code is the important attribute

diff --git a/cli.py b/cli.py
index 1554911..b5e95cf 100644
--- a/cli.py
+++ b/cli.py
@@ -456,7 +456,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
             cb.display.output = False
 
         self.verbose_logger.log(yum.logginglevels.INFO_2, _('Running Transaction'))
-        self.runTransaction(cb=cb)
+        resultobject = self.runTransaction(cb=cb)
 
         self.verbose_logger.debug('Transaction time: %0.3f' % (time.time() - ts_st))
         # close things
@@ -466,7 +466,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         # put back the sigquit handler
         signal.signal(signal.SIGQUIT, sigquit)
         
-        return 0
+        return resultobject.return_code
         
     def gpgsigcheck(self, pkgs):
         '''Perform GPG signature verification on the given packages, installing
diff --git a/yum/__init__.py b/yum/__init__.py
index c13055c..3f9c8a6 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -773,11 +773,16 @@ class YumBase(depsolve.Depsolve):
         # ts.run() exit codes are, hmm, "creative": None means all ok, empty 
         # list means some errors happened in the transaction and non-empty 
         # list that there were errors preventing the ts from starting...
+        
+        # make resultobject - just a plain yumgenericholder object
+        resultobject = misc.GenericHolder
+        resultobject.return_code = 0
         if errors is None:
             pass
         elif len(errors) == 0:
             errstring = _('Warning: scriptlet or other non-fatal errors occurred during transaction.')
             self.verbose_logger.debug(errstring)
+            resultobject.return_code = 1
         else:
             raise Errors.YumBaseError, errors
                           
@@ -794,7 +799,8 @@ class YumBase(depsolve.Depsolve):
                         self.logger.critical(_('Failed to remove transaction file %s') % fn)
 
         self.plugins.run('posttrans')
-    
+        return resultobject
+
     def costExcludePackages(self):
         """exclude packages if they have an identical package in another repo
         and their repo.cost value is the greater one"""
diff --git a/yummain.py b/yummain.py
index 2935fb6..1787d4f 100755
--- a/yummain.py
+++ b/yummain.py
@@ -192,7 +192,7 @@ def main(args):
 
     # Run the transaction
     try:
-        base.doTransaction()
+        return_code = base.doTransaction()
     except plugins.PluginYumExit, e:
         return exPluginExit(e)
     except Errors.YumBaseError, e:
@@ -204,7 +204,7 @@ def main(args):
 
     verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
     if unlock(): return 200
-    return 0
+    return return_code
 
 def hotshot(func, *args, **kwargs):
     import hotshot.stats, os.path



More information about the Yum-cvs-commits mailing list