Patchwork [1/1] insane.bbclass: use bb.process.Popen instead of subprocess.check_output

login
register
mail settings
Submitter Scott Garman
Date Jan. 5, 2012, 9:12 p.m.
Message ID <7583e732bc226f24befcad605b4bfa0536a1ae3c.1325797875.git.scott.a.garman@intel.com>
Download mbox | patch
Permalink /patch/18517/
State Accepted
Commit 0443487fe0bc628db9b03306bdc9dcdb39a121dc
Headers show

Comments

Scott Garman - Jan. 5, 2012, 9:12 p.m.
subprocess.check_output was only introduced in Python v2.7, so we
cannot use it. This refactors the QA test to use bb.process.Popen
instead.

This fixes the error:

AttributeError: 'module' object has no attribute 'check_output'

It no longer checks the return status of prelink-rtld, as that
case was simply adding noise. This QA test is intended to only
warn about specific paths that binaries could be linking to, not
handle the case where there is a missing library.

Signed-off-by: Scott Garman <scott.a.garman@intel.com>
---
 meta/classes/insane.bbclass |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
Richard Purdie - Jan. 5, 2012, 10:21 p.m.
On Thu, 2012-01-05 at 13:12 -0800, Scott Garman wrote:
> subprocess.check_output was only introduced in Python v2.7, so we
> cannot use it. This refactors the QA test to use bb.process.Popen
> instead.
> 
> This fixes the error:
> 
> AttributeError: 'module' object has no attribute 'check_output'
> 
> It no longer checks the return status of prelink-rtld, as that
> case was simply adding noise. This QA test is intended to only
> warn about specific paths that binaries could be linking to, not
> handle the case where there is a missing library.
> 
> Signed-off-by: Scott Garman <scott.a.garman@intel.com>
> ---
>  meta/classes/insane.bbclass |   16 ++++++----------
>  1 files changed, 6 insertions(+), 10 deletions(-)

Merged to master, thanks for the quick fix!

Cheers,

Richard

Patch

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index b8d4507..8d6b11c 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -227,16 +227,12 @@  def package_qa_check_unsafe_references_in_binaries(path, name, d, elf, messages)
 		sysroot_path_usr = sysroot_path + exec_prefix
 
 		try:
-			ldd_output = sub.check_output(["prelink-rtld", "--root", sysroot_path, path])
-		except sub.CalledProcessError as e:
-			if e.returncode != 127:
-				error_msg = pn + ": prelink-rtld aborted when processing %s" % path
-				package_qa_handle_error("unsafe-references-in-binaries", error_msg, d)
-				return False
-			else:
-				# Sometimes this is done deliberately (e.g, e2fsprogs), so only warn
-				bb.warn("%s has missing library dependencies" % path)
-				return
+			ldd_output = bb.process.Popen(["prelink-rtld", "--root", sysroot_path, path], stdout=sub.PIPE).stdout.read()
+		except bb.process.CmdError:
+			error_msg = pn + ": prelink-rtld aborted when processing %s" % path
+			package_qa_handle_error("unsafe-references-in-binaries", error_msg, d)
+			return False
+
 		if sysroot_path_usr in ldd_output:
 			error_msg = pn + ": %s links to something under exec_prefix" % path
 			package_qa_handle_error("unsafe-references-in-binaries", error_msg, d)