oe/patch: more detailed error reporting
PATCH 1/2 oe/patch: more detailed error reporting
Show the actual command that failed when raising a CmdError. Makes figuring out what actually failed much easier.
[YOCTO #9344]
Signed-off-by Markus Lehtonen <[email protected]>
--- meta/lib/oe/patch.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
meta/lib/oe/patch.py +5 -3
@@ -8,12 +8,14 @@ class NotFoundError(bb.BBHandledException): return "Error: %s not found." % self.path class CmdError(bb.BBHandledException): - def __init__(self, exitstatus, output): + def __init__(self, command, exitstatus, output): + self.command = command self.status = exitstatus self.output = output def __str__(self): - return "Command Error: exit status: %d Output:\n%s" % (self.status, self.output) + return "Command Error: '%s' exited with %d Output:\n%s" % \ + (self.command, self.status, self.output) def runcmd(args, dir = None):
@@ -32,7 +34,7 @@ def runcmd(args, dir = None): # print("cmd: %s" % cmd) (exitstatus, output) = oe.utils.getstatusoutput(cmd) if exitstatus != 0: - raise CmdError(exitstatus >> 8, output) + raise CmdError(cmd, exitstatus >> 8, output) return output finally:
Signature · 1 line
2.6.2
PATCH 2/2 oe/patch: print cleaner error message when patch fails to apply
[YOCTO #9344]
Signed-off-by Markus Lehtonen <[email protected]>
--- meta/lib/oe/patch.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
meta/lib/oe/patch.py +9 -5
@@ -214,13 +214,17 @@ class PatchTree(PatchSet): if not force: shellcmd.append('--dry-run') - output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + try: + output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) - if force: - return + if force: + return - shellcmd.pop(len(shellcmd) - 1) - output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + shellcmd.pop(len(shellcmd) - 1) + output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + except CmdError as err: + raise bb.BBHandledException("Applying '%s' failed:\n%s" % + (os.path.basename(patch['file']), err.output)) if not reverse: self._appendPatchFile(patch['file'], patch['strippath'])
Signature · 1 line
2.6.2