[oe-commits] [openembedded-core] branch master updated: chrpath: Cleanup and fix previous patch

git at git.openembedded.org git at git.openembedded.org
Sun Dec 29 09:27:43 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

The following commit(s) were added to refs/heads/master by this push:
     new 39825cb  chrpath: Cleanup and fix previous patch
39825cb is described below

commit 39825cba4761a6b4b2473825705975f9f421ec8b
Author: Ross Burton <ross.burton at intel.com>
AuthorDate: Fri Dec 13 11:33:51 2019 +0000

    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.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/chrpath.bbclass | 20 +++++++++-----------
 meta/lib/oe/qa.py            |  4 +++-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
index 67b197e..26b984c 100644
--- a/meta/classes/chrpath.bbclass
+++ b/meta/classes/chrpath.bbclass
@@ -2,7 +2,7 @@ CHRPATH_BIN ?= "chrpath"
 PREPROCESS_RELOCATE_DIRS ?= ""
 
 def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False):
-    import subprocess as sub, oe.qa
+    import subprocess, oe.qa
 
     with oe.qa.ELFFile(fpath) as elf:
         try:
@@ -10,14 +10,11 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin
         except oe.qa.NotELFFileError:
             return
 
-    p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
-    out, err = p.communicate()
-    # If returned successfully, process stdout for results
-    if p.returncode != 0:
+    try:
+        out = subprocess.check_output([cmd, "-l", fpath], universal_newlines=True)
+    except subprocess.CalledProcessError:
         return
 
-    out = out.decode('utf-8')
-
     # Handle RUNPATH as well as RPATH
     out = out.replace("RUNPATH=","RPATH=")
     # Throw away everything other than the rpath list
@@ -50,10 +47,11 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin
 
         args = ":".join(new_rpaths)
         #bb.note("Setting rpath for %s to %s" %(fpath, args))
-        p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE)
-        out, err = p.communicate()
-        if p.returncode != 0:
-            bb.fatal("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN'), p.returncode, out, err))
+        try:
+            subprocess.check_output([cmd, "-r", args, fpath],
+            stderr=subprocess.PIPE, universal_newlines=True)
+        except subprocess.CalledProcessError as e:
+            bb.fatal("chrpath command failed with exit code %d:\n%s\n%s" % (e.returncode, e.stdout, e.stderr))
 
 def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False):
     import subprocess as sub
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 21066c4..ea831b9 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -41,13 +41,15 @@ class ELFFile:
     def __init__(self, name):
         self.name = name
         self.objdump_output = {}
+        self.data = None
 
     # Context Manager functions to close the mmap explicitly
     def __enter__(self):
         return self
 
     def __exit__(self, exc_type, exc_value, traceback):
-        self.data.close()
+        if self.data:
+            self.data.close()
 
     def open(self):
         with open(self.name, "rb") as f:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list