Skip to contentSkip to conversation

uninative.bbclass: capture stdout/err from patchelf-uninative

PATCH New Patrick Ohly 1 participant 1 message Feb 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uninative.bbclass: capture stdout/err from patchelf-uninative

When patchelf-uninative fails, reporting only the exit code as done by subprocess.check_call() is not enough to understand the problem. We also need to capture and report the output of the command.

---
 meta/classes/uninative.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes/uninative.bbclass +7 -1
index 580917b..0448cf6 100644
@@ -84,5 +84,11 @@ python uninative_changeinterp () {
                 continue
 
             #bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f))
-            subprocess.check_call("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f), shell=True)
+            cmd = "patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f)
+            p = subprocess.Popen(cmd, shell=True,
+                                 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+            stdout, stderr = p.communicate()
+            if p.returncode:
+                bb.fatal("'%s' failed with exit code %d and the following output:\n%s" %
+                         (cmd, p.returncode, stdout))
 }
Signature · 1 line
2.1.4