zypp: abort with error msg for repo resolver issues
authorJF Ding <jian-feng.ding@intel.com>
Sat, 11 Feb 2012 10:23:04 +0000 (18:23 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Sat, 11 Feb 2012 10:23:04 +0000 (18:23 +0800)
will not regard them as warning and continue

mic/utils/errors.py
plugins/backend/zypppkgmgr.py

index 4b13010..5e7777b 100644 (file)
@@ -41,6 +41,12 @@ class ConfigError(CreatorError):
 class KsError(CreatorError):
     keyword = '<kickstart>'
 
+class RepoError(CreatorError):
+    keyword = '<repo>'
+
+class RpmError(CreatorError):
+    keyword = '<rpm>'
+
 class MountError(CreatorError):
     keyword = '<mount>'
 
index 7054546..b1ee743 100644 (file)
@@ -31,7 +31,7 @@ from mic import msger
 from mic.kickstart import ksparser
 from mic.utils import misc, rpmmisc, runner, fs_related
 from mic.utils.proxy import get_proxy_for
-from mic.utils.errors import CreatorError
+from mic.utils.errors import CreatorError, RepoError, RpmError
 from mic.imager.baseimager import BaseImageCreator
 
 class RepositoryStub:
@@ -48,12 +48,6 @@ class RepositoryStub:
         self.keeppackages = True
         self.priority = None
 
-class RepoError(CreatorError):
-    pass
-
-class RpmError(CreatorError):
-    pass
-
 from mic.pluginbase import BackendPlugin
 class Zypp(BackendPlugin):
     name = 'zypp'
@@ -535,14 +529,16 @@ class Zypp(BackendPlugin):
 
     def buildTransaction(self):
         if not self.Z.resolver().resolvePool():
-            msger.warning("Problem count: %d" \
-                          % len(self.Z.resolver().problems()))
+            probs = self.Z.resolver().problems()
 
-            for problem in self.Z.resolver().problems():
-                msger.warning("Problem: %s, %s" \
+            for problem in probs:
+                msger.warning("repo problem: %s, %s" \
                               % (problem.description().decode("utf-8"),
                                  problem.details().decode("utf-8")))
 
+            raise RepoError("found %d resolver problem, abort!" \
+                            % len(probs))
+
     def getLocalPkgPath(self, po):
         repoinfo = po.repoInfo()
         cacheroot = repoinfo.packagesPath()