]> code.ossystems Code Review - openembedded-core.git/commitdiff
package.bbclass: Rewrite shlib_provider handling to include RPATH
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 7 Jul 2014 17:40:55 +0000 (18:40 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 Jul 2014 16:37:38 +0000 (17:37 +0100)
Change the do_package shlibs code to account for RPATHS. This means that
for library dependency purposes, only libraries in system paths or in
any declared RPATH will be seen. This is important to resolve problems
people have been having where similarly named libraries in "private"
paths were conflicting, e.g. with gstreamer.

For now this code assumes the default search path is libdir and
base_libdir and places ASSUME_SHLIBS in libdir so they are searched by
default.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/package.bbclass

index d7de72bda39223d3f5f813c6d61efae435d88124..988e1488933fc437b21d14bd555aec114fd54ba1 100644 (file)
@@ -1375,7 +1375,9 @@ python package_do_shlibs() {
                     fd.close()
                     for l in lines:
                         s = l.strip().split(":")
-                        shlib_provider[s[0]] = (dep_pkg, s[2])
+                        if s[0] not in shlib_provider:
+                            shlib_provider[s[0]] = {}
+                        shlib_provider[s[0]][s[1]] = (dep_pkg, s[2])
 
     def linux_so(file, needed, sonames, renames, pkgver):
         needs_ldconfig = False
@@ -1518,13 +1520,15 @@ python package_do_shlibs() {
         if len(sonames):
             fd = open(shlibs_file, 'w')
             for s in sonames:
-                if s[0] in shlib_provider:
-                    (old_pkg, old_pkgver) = shlib_provider[s[0]]
+                if s[0] in shlib_provider and s[1] in shlib_provider[s[0]]:
+                    (old_pkg, old_pkgver) = shlib_provider[s[0]][s[1]]
                     if old_pkg != pkg:
                         bb.warn('%s-%s was registered as shlib provider for %s, changing it to %s-%s because it was built later' % (old_pkg, old_pkgver, s[0], pkg, pkgver))
                 bb.debug(1, 'registering %s-%s as shlib provider for %s' % (pkg, pkgver, s[0]))
                 fd.write(s[0] + ':' + s[1] + ':' + s[2] + '\n')
-                shlib_provider[s[0]] = (pkg, pkgver)
+                if s[0] not in shlib_provider:
+                    shlib_provider[s[0]] = {}
+                shlib_provider[s[0]][s[1]] = (pkg, pkgver)
             fd.close()
         if needs_ldconfig and use_ldconfig:
             bb.debug(1, 'adding ldconfig call to postinst for %s' % pkg)
@@ -1539,6 +1543,7 @@ python package_do_shlibs() {
 
     assumed_libs = d.getVar('ASSUME_SHLIBS', True)
     if assumed_libs:
+        libdir = d.getVar("libdir", True)
         for e in assumed_libs.split():
             l, dep_pkg = e.split(":")
             lib_ver = None
@@ -1546,7 +1551,9 @@ python package_do_shlibs() {
             if len(dep_pkg) == 2:
                 lib_ver = dep_pkg[1]
             dep_pkg = dep_pkg[0]
-            shlib_provider[l] = (dep_pkg, lib_ver)
+            shlib_provider[l][libdir] = (dep_pkg, lib_ver)
+
+    libsearchpath = [d.getVar('libdir', True), d.getVar('base_libdir', True)]
 
     for pkg in packages.split():
         bb.debug(2, "calculating shlib requirements for %s" % pkg)
@@ -1562,21 +1569,27 @@ python package_do_shlibs() {
                 bb.debug(2, '%s: Dependency %s covered by PRIVATE_LIBS' % (pkg, n[0]))
                 continue
             if n[0] in shlib_provider.keys():
-                (dep_pkg, ver_needed) = shlib_provider[n[0]]
+                match = None
+                for p in n[2] + libsearchpath:
+                    if p in shlib_provider[n[0]]:
+                        match = p
+                        break
+                if match:
+                    (dep_pkg, ver_needed) = shlib_provider[n[0]][match]
 
-                bb.debug(2, '%s: Dependency %s requires package %s (used by files: %s)' % (pkg, n[0], dep_pkg, n[1]))
+                    bb.debug(2, '%s: Dependency %s requires package %s (used by files: %s)' % (pkg, n[0], dep_pkg, n[1]))
 
-                if dep_pkg == pkg:
-                    continue
+                    if dep_pkg == pkg:
+                        continue
 
-                if ver_needed:
-                    dep = "%s (>= %s)" % (dep_pkg, ver_needed)
-                else:
-                    dep = dep_pkg
-                if not dep in deps:
-                    deps.append(dep)
-            else:
-                bb.note("Couldn't find shared library provider for %s, used by files: %s" % (n[0], n[1]))
+                    if ver_needed:
+                        dep = "%s (>= %s)" % (dep_pkg, ver_needed)
+                    else:
+                        dep = dep_pkg
+                    if not dep in deps:
+                        deps.append(dep)
+                    continue
+            bb.note("Couldn't find shared library provider for %s, used by files: %s" % (n[0], n[1]))
 
         deps_file = os.path.join(pkgdest, pkg + ".shlibdeps")
         if os.path.exists(deps_file):