summaryrefslogtreecommitdiffstats
path: root/meta/classes/insane.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-05-29 22:53:08 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-30 12:04:45 +0100
commit5996b2b58e36864edc077326a942795ca12f48da (patch)
tree5f67615a25685f4b0d4a8150f51932a5b478ccfa /meta/classes/insane.bbclass
parentd760fb97f52c705944a259be267e0ea8516074e3 (diff)
downloadast2050-yocto-poky-5996b2b58e36864edc077326a942795ca12f48da.zip
ast2050-yocto-poky-5996b2b58e36864edc077326a942795ca12f48da.tar.gz
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 <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/insane.bbclass')
-rw-r--r--meta/classes/insane.bbclass31
1 files changed, 20 insertions, 11 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 4d139e8..fa7b5f0 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -154,14 +154,29 @@ def package_qa_check_rpath(file,name, d, elf, messages):
if not bad_dirs[0] in d.getVar('WORKDIR', True):
bb.fatal("This class assumed that WORKDIR is ${TMPDIR}/work... Not doing any check")
- output = os.popen("%s -B -F%%r#F '%s'" % (scanelf,file))
- txt = output.readline().split()
+ output, errors = bb.process.run("%s -B -F%%r#F '%s'" % (scanelf,file))
+ txt = output.split()
for line in txt:
for dir in bad_dirs:
if dir in line:
messages.append("package %s contains bad RPATH %s in file %s" % (name, line, file))
QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
+
+def package_qa_get_objdump(d, path):
+ """
+ Get the result of objdump, ignore the errors since not all files can be objdumped
+ """
+ env_path = d.getVar('PATH', True)
+ objdump = d.getVar('OBJDUMP', True)
+
+ try:
+ lines = ""
+ lines = bb.process.run("LC_ALL=C PATH=%s %s -p '%s'" % (env_path, objdump, path))[0]
+ except Exception:
+ sys.exc_clear()
+ return lines
+
def package_qa_check_useless_rpaths(file, name, d, elf, messages):
"""
Check for RPATHs that are useless but not dangerous
@@ -169,15 +184,12 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
if not elf:
return
- objdump = d.getVar('OBJDUMP', True)
- env_path = d.getVar('PATH', True)
-
libdir = d.getVar("libdir", True)
base_libdir = d.getVar("base_libdir", True)
import re
rpath_re = re.compile("\s+RPATH\s+(.*)")
- for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, file), "r"):
+ for line in package_qa_get_objdump(d, file):
m = rpath_re.match(line)
if m:
rpath = m.group(1)
@@ -369,7 +381,7 @@ def package_qa_check_desktop(path, name, d, elf, messages):
"""
if path.endswith(".desktop"):
desktop_file_validate = os.path.join(d.getVar('STAGING_BINDIR_NATIVE',True),'desktop-file-validate')
- output = os.popen("%s %s" % (desktop_file_validate, path))
+ output, errors = bb.process.run("%s %s" % (desktop_file_validate, path))
# This only produces output on errors
for l in output:
messages.append("Desktop file issue: " + l.strip())
@@ -392,14 +404,11 @@ def package_qa_hash_style(path, name, d, elf, messages):
if not gnu_hash:
return
- objdump = d.getVar('OBJDUMP', True)
- env_path = d.getVar('PATH', True)
-
sane = False
has_syms = False
# If this binary has symbols, we expect it to have GNU_HASH too.
- for line in os.popen("LC_ALL=C PATH=%s %s -p '%s' 2> /dev/null" % (env_path, objdump, path), "r"):
+ for line in package_qa_get_objdump(d, path):
if "SYMTAB" in line:
has_syms = True
if "GNU_HASH" in line:
OpenPOWER on IntegriCloud