[yocto] [[AUH] 1/4] upgradehelper: commit_changes ensure that patch_file exist

Aníbal Limón anibal.limon at linux.intel.com
Fri Dec 11 13:15:02 PST 2015


If patch_file isn't generated treat it as an error this avoid
future exceptions in package_handler when try to send/save email.

Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 upgradehelper.py | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/upgradehelper.py b/upgradehelper.py
index 54f9a10..e5c2629 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -369,6 +369,8 @@ class Updater(object):
             f.write("\n%s\n" % msg_body)
 
     def commit_changes(self, pkg_ctx):
+        fail = False
+
         try:
             pkg_ctx['patch_file'] = None
 
@@ -376,19 +378,32 @@ class Updater(object):
                 I(" %s: Auto commit changes ..." % pkg_ctx['PN'])
                 self.git.commit(pkg_ctx['recipe'].commit_msg, self.opts['author'])
 
-                I(" %s: Save patch in directory: %s." %
-                        (pkg_ctx['PN'], pkg_ctx['workdir']))
-
                 stdout = self.git.create_patch(pkg_ctx['workdir'])
                 pkg_ctx['patch_file'] = stdout.strip()
+
+                if not pkg_ctx['patch_file']:
+                    msg = "Patch file not generated."
+                    E(" %s: %s\n %s" % (pkg_ctx['PN'], msg, stdout))
+                    pkg_ctx['error'] = Error(msg, stdout)
+                    fail = True
+                else:
+                    I(" %s: Save patch in directory: %s." %
+                        (pkg_ctx['PN'], pkg_ctx['workdir']))
         except Error as e:
+            msg = ''
+
             for line in e.stdout.split("\n"):
                 if line.find("nothing to commit") == 0:
-                    I(" %s: Nothing to commit!" % pkg_ctx['PN'])
-                    return
+                    msg = "Nothing to commit!"
+                    I(" %s: %s" % (pkg_ctx['PN'], msg))
 
             I(" %s: %s" % (pkg_ctx['PN'], e.stdout))
-            raise e
+
+            pkg_ctx['error'] = Error(msg, e.stdout)
+            fail = True
+
+        if fail:
+            raise pkg_ctx['error']
 
     def send_status_mail(self, statistics_summary):
         if "status_recipients" not in settings:
@@ -554,7 +569,12 @@ class Updater(object):
                 pkg_ctx['error'] = e
                 failed_pkgs_ctx.append(pkg_ctx)
 
-            self.commit_changes(pkg_ctx)
+            try:
+                self.commit_changes(pkg_ctx)
+            except:
+                if pkg_ctx in succeeded_pkgs_ctx:
+                    succeeded_pkgs_ctx.remove(pkg_ctx)
+                    failed_pkgs_ctx.append(pkg_ctx)
 
         if self.opts['testimage']:
             if len(succeeded_pkgs_ctx) > 0:
-- 
2.1.4




More information about the yocto mailing list