Patchwork lib/oe/patch.py: Fix patch resolver logic

login
register
mail settings
Submitter Richard Purdie
Date March 1, 2012, 11:41 p.m.
Message ID <1330645282.15224.0.camel@ted>
Download mbox | patch
Permalink /patch/22559/
State New
Headers show

Comments

Richard Purdie - March 1, 2012, 11:41 p.m.
Currently, if PATCHRESOLVE is user and and PatchTree() is being used, you can
get backtraces if patch applcication fails. This is because even in the failure
case, self._current is incremented, meaning second time around, there are array
range issues.

This patch changes the code so _current is only incremented upon successful
patch application, thereby resolving this failure.

[YOCTO #2043 partially]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
Richard Purdie - March 2, 2012, 12:20 p.m.
On Thu, 2012-03-01 at 23:41 +0000, Richard Purdie wrote:
> Currently, if PATCHRESOLVE is user and and PatchTree() is being used, you can
> get backtraces if patch applcication fails. This is because even in the failure
> case, self._current is incremented, meaning second time around, there are array
> range issues.
> 
> This patch changes the code so _current is only incremented upon successful
> patch application, thereby resolving this failure.
> 
> [YOCTO #2043 partially]
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

This patch is wrong, it breaks with multiple patch application. I've
posted an updated patch.

Cheers,

Richard

Patch

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 6f7f900..065a8f7 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -134,20 +134,23 @@  class PatchTree(PatchSet):
         bb.note("patches is %s" % self.patches)
         if all:
             for i in self.patches:
+                bb.note("applying patch %s" % i)
+                self._applypatch(i, force)
+
                 if self._current is not None:
                     self._current = self._current + 1
                 else:
                     self._current = 0
-                bb.note("applying patch %s" % i)
-                self._applypatch(i, force)
         else:
+            bb.note("applying patch %s" % self.patches[self._current or 0])
+            ret = self._applypatch(self.patches[self._current or 0], force)
+
             if self._current is not None:
                 self._current = self._current + 1
             else:
                 self._current = 0
-            bb.note("applying patch %s" % self.patches[self._current])
-            return self._applypatch(self.patches[self._current], force)
 
+            return ret
 
     def Pop(self, force = None, all = None):
         if all: