summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.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/package.bbclass
parentd760fb97f52c705944a259be267e0ea8516074e3 (diff)
downloadpoky-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/package.bbclass')
-rw-r--r--meta/classes/package.bbclass16
1 files changed, 10 insertions, 6 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 41139ef921..bc83bfbf4e 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1061,7 +1061,7 @@ python emit_pkgdata() {
1061 1061
1062 def get_directory_size(dir): 1062 def get_directory_size(dir):
1063 if os.listdir(dir): 1063 if os.listdir(dir):
1064 size = int(os.popen('du -sk %s' % dir).readlines()[0].split('\t')[0]) 1064 size = int(bb.process.run('du -sk %s' % dir)[0].split('\t')[0])
1065 else: 1065 else:
1066 size = 0 1066 size = 0
1067 return size 1067 return size
@@ -1221,7 +1221,7 @@ python package_do_filedeps() {
1221 rpfiles.append(os.path.join(root, file)) 1221 rpfiles.append(os.path.join(root, file))
1222 1222
1223 for files in chunks(rpfiles, 100): 1223 for files in chunks(rpfiles, 100):
1224 dep_pipe = os.popen(rpmdeps + " " + " ".join(files)) 1224 dep_pipe = bb.process.Popen(rpmdeps + " " + " ".join(files), shell=True).stdout
1225 1225
1226 process_deps(dep_pipe, pkg, provides_files, requires_files) 1226 process_deps(dep_pipe, pkg, provides_files, requires_files)
1227 1227
@@ -1263,11 +1263,15 @@ python package_do_shlibs() {
1263 1263
1264 def linux_so(root, path, file): 1264 def linux_so(root, path, file):
1265 needs_ldconfig = False 1265 needs_ldconfig = False
1266 cmd = d.getVar('OBJDUMP', True) + " -p " + pipes.quote(os.path.join(root, file)) + " 2>/dev/null" 1266 cmd = d.getVar('OBJDUMP', True) + " -p " + pipes.quote(os.path.join(root, file))
1267 cmd = "PATH=\"%s\" %s" % (d.getVar('PATH', True), cmd) 1267 cmd = "PATH=\"%s\" %s" % (d.getVar('PATH', True), cmd)
1268 fd = os.popen(cmd) 1268 try:
1269 lines = fd.readlines() 1269 lines = ""
1270 fd.close() 1270 lines = bb.process.run(cmd)[0]
1271 # Some ".so" maybe ascii text, e.g: /usr/lib64/libpthread.so,
1272 # ingore those errors.
1273 except Exception:
1274 sys.exc_clear()
1271 for l in lines: 1275 for l in lines:
1272 m = re.match("\s+NEEDED\s+([^\s]*)", l) 1276 m = re.match("\s+NEEDED\s+([^\s]*)", l)
1273 if m: 1277 if m: