classes/patch.bbclass: Make sure to raise func_failed on any exception from within...
authorHolger Freyther <zecke@selfish.org>
Sat, 31 Mar 2007 15:57:22 +0000 (15:57 +0000)
committerHolger Freyther <zecke@selfish.org>
Sat, 31 Mar 2007 15:57:22 +0000 (15:57 +0000)
    non existing patches raised a IOError by the md5sum method which was not
    catched at all and lead bitbake to exit due an unhandled exception. This
    is bad for all autobuilders.

classes/patch.bbclass

index 0a7b94c..07d1847 100644 (file)
@@ -3,10 +3,20 @@
 def patch_init(d):
        import os, sys
 
+       class NotFoundError(Exception):
+               def __init__(self, path):
+                       self.path = path
+               def __str__(self):
+                       return "Error: %s not found." % self.path
+
        def md5sum(fname):
                import md5, sys
 
-               f = file(fname, 'rb')
+               try:
+                       f = file(fname, 'rb')
+               except IOError:
+                       raise NotFoundError(fname)
+
                m = md5.new()
                while True:
                        d = f.read(8096)
@@ -24,11 +34,6 @@ def patch_init(d):
                def __str__(self):
                        return "Command Error: exit status: %d  Output:\n%s" % (self.status, self.output)
 
-       class NotFoundError(Exception):
-               def __init__(self, path):
-                       self.path = path
-               def __str__(self):
-                       return "Error: %s not found." % self.path
 
        def runcmd(args, dir = None):
                import commands
@@ -482,7 +487,7 @@ python patch_do_patch() {
                bb.note("Applying patch '%s'" % pname)
                try:
                        patchset.Import({"file":unpacked, "remote":url, "strippath": pnum}, True)
-               except NotFoundError:
+               except:
                        import sys
                        raise bb.build.FuncFailed(str(sys.exc_value))
                resolver.Resolve()