From 5996b2b58e36864edc077326a942795ca12f48da Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Tue, 29 May 2012 22:53:08 +0800 Subject: meta: replace os.popen with subprocess.Popen Replace os.popen with subprocess.Popen since the older function would fail (more or less) silently if the executed program cannot be found There are both bb.process.run() and bb.process.Popen() which wraps the subprocess module, use it for simplifying the code. Note: We don't need the "2>/dev/null" or "2>&1" since bb.process.run() can handle it, it will raise exception when error occurs, we should handle the exception ourselves if we want to ignore the error. More info: http://docs.python.org/library/subprocess.html#subprocess-replacements [YOCTO #2454] (From OE-Core rev: e83d8e58a6b107eea87df0ec233a1bc932b2c6ea) Signed-off-by: Robert Yang Signed-off-by: Richard Purdie --- meta/classes/debian.bbclass | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'meta/classes/debian.bbclass') diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass index 3637e2e..963d11c 100644 --- a/meta/classes/debian.bbclass +++ b/meta/classes/debian.bbclass @@ -60,10 +60,14 @@ python debian_package_name_hook () { for f in files: if so_re.match(f): fp = os.path.join(root, f) - cmd = (d.getVar('BUILD_PREFIX', True) or "") + "objdump -p " + fp + " 2>/dev/null" - fd = os.popen(cmd) - lines = fd.readlines() - fd.close() + cmd = (d.getVar('BUILD_PREFIX', True) or "") + "objdump -p " + fp + try: + lines = "" + lines = bb.process.run(cmd)[0] + # Some ".so" maybe ascii text, e.g: /usr/lib64/libpthread.so, + # ingore those errors. + except Exception: + sys.exc_clear() for l in lines: m = re.match("\s+SONAME\s+([^\s]*)", l) if m and not m.group(1) in sonames: -- cgit v1.1