diff mbox series

lib/package: cleanup objdump invocation when scanning for library dependencies

Message ID 20241029161548.2662190-1-ross.burton@arm.com
State New
Headers show
Series lib/package: cleanup objdump invocation when scanning for library dependencies | expand

Commit Message

Ross Burton Oct. 29, 2024, 4:15 p.m. UTC
Instead of using os.popen() directly, and passing a string then having
to quote the arguments, use subprocess.run() and pass a list of arguments.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oe/package.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mathieu Dubois-Briand Oct. 30, 2024, 9:38 a.m. UTC | #1
On Tue, Oct 29, 2024 at 04:15:48PM +0000, Ross Burton wrote:
> Instead of using os.popen() directly, and passing a string then having
> to quote the arguments, use subprocess.run() and pass a list of arguments.
> 
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---

Hi Ross,

It seems this breaks a lot of things on the autobuilder, I get lot of
fails like:
FileNotFoundError: [Errno 2] No such file or directory:
'x86_64-poky-linux-objdump'

https://valkyrie.yoctoproject.org/#/builders/78/builds/347/steps/13/logs/stdio
https://valkyrie.yoctoproject.org/#/builders/50/builds/366/steps/11/logs/stdio
https://valkyrie.yoctoproject.org/#/builders/64/builds/306/steps/12/logs/stdio

Can you have a look please ?
diff mbox series

Patch

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 16359232ecd..f935b684de0 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1625,11 +1625,11 @@  def process_shlibs(pkgfiles, d):
         sonames = set()
         renames = []
         ldir = os.path.dirname(file).replace(pkgdest + "/" + pkg, '')
-        cmd = d.getVar('OBJDUMP') + " -p " + shlex.quote(file) + " 2>/dev/null"
-        fd = os.popen(cmd)
-        lines = fd.readlines()
-        fd.close()
         rpath = tuple()
+        cmd = [d.getVar("OBJDUMP"), "-p", file]
+        proc = subprocess.run(cmd, capture_output=True, text=True)
+        # Ignore errors silently as not all matching files will be parsed successfully
+        lines = proc.stdout.splitlines()
         for l in lines:
             m = re.match(r"\s+RPATH\s+([^\s]*)", l)
             if m: