diff options
author | Ross Burton <ross.burton@intel.com> | 2019-12-13 11:33:51 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-29 09:27:16 +0000 |
commit | 3780744968f0b26cc2f4fea61a0cc594da6fa616 (patch) | |
tree | 7524dc36d40b39698f797b4c56f901e82938dac0 /meta/classes | |
parent | f6a35934540e910794b8729ecc278189a39b710f (diff) | |
download | poky-3780744968f0b26cc2f4fea61a0cc594da6fa616.tar.gz |
chrpath: Cleanup and fix previous patch
Ensure self.data isn't accessed without assignment. Also clean up old style
popen use and replace with modern/simpler subprocess.
(From OE-Core rev: 39825cba4761a6b4b2473825705975f9f421ec8b)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/chrpath.bbclass | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass index 67b197ec22..26b984c4db 100644 --- a/meta/classes/chrpath.bbclass +++ b/meta/classes/chrpath.bbclass | |||
@@ -2,7 +2,7 @@ CHRPATH_BIN ?= "chrpath" | |||
2 | PREPROCESS_RELOCATE_DIRS ?= "" | 2 | PREPROCESS_RELOCATE_DIRS ?= "" |
3 | 3 | ||
4 | def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): | 4 | def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): |
5 | import subprocess as sub, oe.qa | 5 | import subprocess, oe.qa |
6 | 6 | ||
7 | with oe.qa.ELFFile(fpath) as elf: | 7 | with oe.qa.ELFFile(fpath) as elf: |
8 | try: | 8 | try: |
@@ -10,14 +10,11 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin | |||
10 | except oe.qa.NotELFFileError: | 10 | except oe.qa.NotELFFileError: |
11 | return | 11 | return |
12 | 12 | ||
13 | p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 13 | try: |
14 | out, err = p.communicate() | 14 | out = subprocess.check_output([cmd, "-l", fpath], universal_newlines=True) |
15 | # If returned successfully, process stdout for results | 15 | except subprocess.CalledProcessError: |
16 | if p.returncode != 0: | ||
17 | return | 16 | return |
18 | 17 | ||
19 | out = out.decode('utf-8') | ||
20 | |||
21 | # Handle RUNPATH as well as RPATH | 18 | # Handle RUNPATH as well as RPATH |
22 | out = out.replace("RUNPATH=","RPATH=") | 19 | out = out.replace("RUNPATH=","RPATH=") |
23 | # Throw away everything other than the rpath list | 20 | # Throw away everything other than the rpath list |
@@ -50,10 +47,11 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin | |||
50 | 47 | ||
51 | args = ":".join(new_rpaths) | 48 | args = ":".join(new_rpaths) |
52 | #bb.note("Setting rpath for %s to %s" %(fpath, args)) | 49 | #bb.note("Setting rpath for %s to %s" %(fpath, args)) |
53 | p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 50 | try: |
54 | out, err = p.communicate() | 51 | subprocess.check_output([cmd, "-r", args, fpath], |
55 | if p.returncode != 0: | 52 | stderr=subprocess.PIPE, universal_newlines=True) |
56 | bb.fatal("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN'), p.returncode, out, err)) | 53 | except subprocess.CalledProcessError as e: |
54 | bb.fatal("chrpath command failed with exit code %d:\n%s\n%s" % (e.returncode, e.stdout, e.stderr)) | ||
57 | 55 | ||
58 | def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): | 56 | def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): |
59 | import subprocess as sub | 57 | import subprocess as sub |