yifengyou / rpms / yum

Forked from rpms/yum 3 years ago
Clone

Blame SOURCES/BZ-1004853-yum-cron-handle-empty-transaction.patch

5e9bef
commit ae22bcdbacc01b12175304e14df59bdda45aa108
5e9bef
Author: Andreas Fleig <andreasfleig@googlemail.com>
5e9bef
Date:   Wed Mar 16 12:35:38 2016 +0100
5e9bef
5e9bef
    yum-cron: don't fail on empty transaction. BZ 1004853
5e9bef
    
5e9bef
    Even if refreshUpdates() returns True, the transaction may still be
5e9bef
    empty if some updateinfo filters were applied there and thus a later
5e9bef
    call to buildTransaction() would return 0 (success).  This wasn't
5e9bef
    handled by findDeps() properly, making it emit an error message in such
5e9bef
    a case.
5e9bef
    
5e9bef
    Note that, in the first place, we shouldn't return True from
5e9bef
    refreshUpdates() if the transaction becomes empty after applying the
5e9bef
    filters.  However, we should handle this particular buildTransaction()
5e9bef
    outcome in findDeps() regardless and that's sufficient to fix this bug.
5e9bef
    
5e9bef
    See also:
5e9bef
    http://lists.baseurl.org/pipermail/yum/2014-December/024141.html
5e9bef
5e9bef
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
5e9bef
index ccba690..5c3c1f9 100755
5e9bef
--- a/yum-cron/yum-cron.py
5e9bef
+++ b/yum-cron/yum-cron.py
5e9bef
@@ -513,7 +513,13 @@ class YumCronBase(yum.YumBase, YumOutput):
5e9bef
         except yum.Errors.RepoError, e:
5e9bef
             self.emitCheckFailed("%s" %(e,))
5e9bef
             sys.exit()
5e9bef
-        if res != 2:
5e9bef
+        if res == 0:
5e9bef
+            # success, empty transaction
5e9bef
+            sys.exit(0)
5e9bef
+        elif res == 2:
5e9bef
+            # success, dependencies resolved
5e9bef
+            pass
5e9bef
+        else:
5e9bef
             self.emitCheckFailed("Failed to build transaction: %s" %(str.join("\n", resmsg),))
5e9bef
             sys.exit(1)
5e9bef
 
5e9bef
commit 485121311f4ff40b939965587db735b05aec6fe0
5e9bef
Author: Felix Kaiser <felix.kaiser@fxkr.net>
5e9bef
Date:   Wed Mar 16 13:16:13 2016 +0100
5e9bef
5e9bef
    yum-cron: fix exit code in findDeps()
5e9bef
5e9bef
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
5e9bef
index 5c3c1f9..12c7720 100755
5e9bef
--- a/yum-cron/yum-cron.py
5e9bef
+++ b/yum-cron/yum-cron.py
5e9bef
@@ -512,7 +512,7 @@ class YumCronBase(yum.YumBase, YumOutput):
5e9bef
             (res, resmsg) = self.buildTransaction()
5e9bef
         except yum.Errors.RepoError, e:
5e9bef
             self.emitCheckFailed("%s" %(e,))
5e9bef
-            sys.exit()
5e9bef
+            sys.exit(1)
5e9bef
         if res == 0:
5e9bef
             # success, empty transaction
5e9bef
             sys.exit(0)