All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] classes/debian: fix library path handling
@ 2018-01-16 13:37 Ross Burton
  2018-01-16 13:37 ` [PATCH 2/2] classes/debian: clean up process spawning Ross Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2018-01-16 13:37 UTC (permalink / raw)
  To: openembedded-core

The existing code is looking for libraries in all paths which end in ${libdir}.
This caused false-positives for recipes such as lz4 which had files called
/usr/lib/lz4/ptest/usr/lib/liblz4.so, and resulted in lz4-ptest being
incorrectly renamed to liblz4.

Solve this by explicitly looking for ${libdir} etc under the packages-split
directory.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/debian.bbclass | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass
index 5cdbf360dcb..edc6da1ba3a 100644
--- a/meta/classes/debian.bbclass
+++ b/meta/classes/debian.bbclass
@@ -25,12 +25,10 @@ python () {
 }
 
 python debian_package_name_hook () {
-    import glob, copy, stat, errno, re
+    import glob, copy, stat, errno, re, pathlib
 
-    pkgdest = d.getVar('PKGDEST')
+    pkgdest = d.getVar("PKGDEST")
     packages = d.getVar('PACKAGES')
-    bin_re = re.compile(".*/s?" + os.path.basename(d.getVar("bindir")) + "$")
-    lib_re = re.compile(".*/" + os.path.basename(d.getVar("libdir")) + "$")
     so_re = re.compile("lib.*\.so")
 
     def socrunch(s):
@@ -60,17 +58,25 @@ python debian_package_name_hook () {
                 d.appendVar('RPROVIDES_' + pkg, " " + pkg + " (=" + d.getVar("PKGV") + ")")
 
     def auto_libname(packages, orig_pkg):
+        p = lambda var: pathlib.PurePath(d.getVar(var))
+        libdirs = (p("base_libdir"), p("libdir"))
+        bindirs = (p("base_bindir"), p("base_sbindir"), p("bindir"), p("sbindir"))
+
         sonames = []
         has_bins = 0
         has_libs = 0
-        for file in pkgfiles[orig_pkg]:
-            root = os.path.dirname(file)
-            if bin_re.match(root):
+        for f in pkgfiles[orig_pkg]:
+            # This is .../packages-split/orig_pkg/
+            pkgpath = pathlib.PurePath(pkgdest, orig_pkg)
+            # Strip pkgpath off the full path to a file in the package, re-root
+            # so it is absolute, and then get the parent directory of the file.
+            path = pathlib.PurePath("/") / (pathlib.PurePath(f).relative_to(pkgpath).parent)
+            if path in bindirs:
                 has_bins = 1
-            if lib_re.match(root):
+            if path in libdirs:
                 has_libs = 1
-                if so_re.match(os.path.basename(file)):
-                    cmd = (d.getVar('TARGET_PREFIX') or "") + "objdump -p " + file + " 2>/dev/null"
+                if so_re.match(os.path.basename(f)):
+                    cmd = (d.getVar('TARGET_PREFIX') or "") + "objdump -p " + f + " 2>/dev/null"
                     fd = os.popen(cmd)
                     lines = fd.readlines()
                     fd.close()
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] classes/debian: clean up process spawning
  2018-01-16 13:37 [PATCH 1/2] classes/debian: fix library path handling Ross Burton
@ 2018-01-16 13:37 ` Ross Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Ross Burton @ 2018-01-16 13:37 UTC (permalink / raw)
  To: openembedded-core

This code is old and was of it's time, rewrite it to use modernish (we support
Python 3.4, so can't use subprocess.run()) subprocess and re idioms instead.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/debian.bbclass | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass
index edc6da1ba3a..989ea8f8d28 100644
--- a/meta/classes/debian.bbclass
+++ b/meta/classes/debian.bbclass
@@ -25,7 +25,7 @@ python () {
 }
 
 python debian_package_name_hook () {
-    import glob, copy, stat, errno, re, pathlib
+    import glob, copy, stat, errno, re, pathlib, subprocess
 
     pkgdest = d.getVar("PKGDEST")
     packages = d.getVar('PACKAGES')
@@ -76,15 +76,14 @@ python debian_package_name_hook () {
             if path in libdirs:
                 has_libs = 1
                 if so_re.match(os.path.basename(f)):
-                    cmd = (d.getVar('TARGET_PREFIX') or "") + "objdump -p " + f + " 2>/dev/null"
-                    fd = os.popen(cmd)
-                    lines = fd.readlines()
-                    fd.close()
-                    for l in lines:
-                        m = re.match("\s+SONAME\s+([^\s]*)", l)
-                        if m and not m.group(1) in sonames:
-                            sonames.append(m.group(1))
-
+                    try:
+                        cmd = [d.expand("${TARGET_PREFIX}objdump"), "-p", f]
+                        output = subprocess.check_output(cmd).decode("utf-8")
+                        for m in re.finditer("\s+SONAME\s+([^\s]+)", output):
+                            if m.group(1) not in sonames:
+                                sonames.append(m.group(1))
+                    except subprocess.CalledProcessError:
+                        pass
         bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
         soname = None
         if len(sonames) == 1:
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-16 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 13:37 [PATCH 1/2] classes/debian: fix library path handling Ross Burton
2018-01-16 13:37 ` [PATCH 2/2] classes/debian: clean up process spawning Ross Burton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.