Patchwork [RFC,3/4] package.bbclass: add SHLIBSSEARCHDIRS to define where to search for shlib providers

login
register
mail settings
Submitter Martin Jansa
Date July 6, 2013, 11:13 p.m.
Message ID <1373152387-19393-3-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/53239/
State New
Headers show

Comments

Martin Jansa - July 6, 2013, 11:13 p.m.
* when package contains some files matching "^.*\.so", but in directory
  not default linker search paths (e.g. /opt/package/bundled-lib/libfoo.so)
  don't register it as libfoo provider, because it's possible that there
  is different package providing libfoo.so in ${libdir} and that would
  be better shlib provider for other packages to depend on
* recipes providing libs intentionally in some other directory can
  define own SHLIBSSEARCHDIRS value

[YOCTO #4628]

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/package.bbclass | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
Richard Purdie - Sept. 2, 2013, 11:22 a.m.
On Sun, 2013-07-07 at 01:13 +0200, Martin Jansa wrote:
> * when package contains some files matching "^.*\.so", but in directory
>   not default linker search paths (e.g. /opt/package/bundled-lib/libfoo.so)
>   don't register it as libfoo provider, because it's possible that there
>   is different package providing libfoo.so in ${libdir} and that would
>   be better shlib provider for other packages to depend on
> * recipes providing libs intentionally in some other directory can
>   define own SHLIBSSEARCHDIRS value
> 
> [YOCTO #4628]
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/classes/package.bbclass | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 6c3ca56..3713fd3 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -1307,6 +1307,9 @@ SHLIBSDIRS = "${@getshlibsdirs(d)}"
>  SHLIBSDIR = "${TMPDIR}/pkgdata/${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/shlibs"
>  SHLIBSWORKDIR = "${PKGDESTWORK}/shlibs"
>  
> +# default search path when searching for shlibs provided by package
> +SHLIBSSEARCHDIRS ?= "${baselib} ${libdir}"
> +
>  python package_do_shlibs() {
>      import re, pipes

Did you end up setting SHLIBSSEARCHDIRS for many recipes out of
interest?

Cheers,

Richard
Martin Jansa - Sept. 2, 2013, 11:27 a.m.
On Mon, Sep 02, 2013 at 12:22:18PM +0100, Richard Purdie wrote:
> On Sun, 2013-07-07 at 01:13 +0200, Martin Jansa wrote:
> > * when package contains some files matching "^.*\.so", but in directory
> >   not default linker search paths (e.g. /opt/package/bundled-lib/libfoo.so)
> >   don't register it as libfoo provider, because it's possible that there
> >   is different package providing libfoo.so in ${libdir} and that would
> >   be better shlib provider for other packages to depend on
> > * recipes providing libs intentionally in some other directory can
> >   define own SHLIBSSEARCHDIRS value
> > 
> > [YOCTO #4628]
> > 
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > ---
> >  meta/classes/package.bbclass | 26 +++++++++++++++++++++++---
> >  1 file changed, 23 insertions(+), 3 deletions(-)
> > 
> > diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> > index 6c3ca56..3713fd3 100644
> > --- a/meta/classes/package.bbclass
> > +++ b/meta/classes/package.bbclass
> > @@ -1307,6 +1307,9 @@ SHLIBSDIRS = "${@getshlibsdirs(d)}"
> >  SHLIBSDIR = "${TMPDIR}/pkgdata/${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/shlibs"
> >  SHLIBSWORKDIR = "${PKGDESTWORK}/shlibs"
> >  
> > +# default search path when searching for shlibs provided by package
> > +SHLIBSSEARCHDIRS ?= "${baselib} ${libdir}"
> > +
> >  python package_do_shlibs() {
> >      import re, pipes
> 
> Did you end up setting SHLIBSSEARCHDIRS for many recipes out of
> interest?

No, but I was testing it only with world builds which won't cause any
fatal error when something is missing in shlibs providers.

Maybe I should revert it in my build and compare runtime deps after
another build (I'll do this when jenkins server is free again).

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 6c3ca56..3713fd3 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1307,6 +1307,9 @@  SHLIBSDIRS = "${@getshlibsdirs(d)}"
 SHLIBSDIR = "${TMPDIR}/pkgdata/${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/shlibs"
 SHLIBSWORKDIR = "${PKGDESTWORK}/shlibs"
 
+# default search path when searching for shlibs provided by package
+SHLIBSSEARCHDIRS ?= "${baselib} ${libdir}"
+
 python package_do_shlibs() {
     import re, pipes
 
@@ -1317,6 +1320,20 @@  python package_do_shlibs() {
 
     lib_re = re.compile("^.*\.so")
     libdir_re = re.compile(".*/%s$" % d.getVar('baselib', True))
+    
+    shlibs_search_dirs = d.getVar('SHLIBSSEARCHDIRS', True)
+    shlibs_search_dirs_re_txt = ""
+    for dir in shlibs_search_dirs.split(' '):
+        # strip leading and trailing slash, it's added in regexp
+        if dir.endswith("/"):
+            dir = dir[:-1]
+        if dir.startswith("/"):
+            dir = dir[1:]
+        if shlibs_search_dirs_re_txt:
+            shlibs_search_dirs_re_txt += "|"
+        shlibs_search_dirs_re_txt += "(^.*/%s/.*$)" % dir
+    shlibs_search_dirs_re = re.compile(shlibs_search_dirs_re_txt)
+    bb.debug(2, "will use following RE to search for provides sonames %s" % shlibs_search_dirs_re_txt)
 
     packages = d.getVar('PACKAGES', True)
     targetos = d.getVar('TARGET_OS', True)
@@ -1375,9 +1392,12 @@  python package_do_shlibs() {
             if m:
                 this_soname = m.group(1)
                 if not this_soname in sonames:
-                    # if library is private (only used by package) then do not build shlib for it
-                    if not private_libs or -1 == private_libs.find(this_soname):
-                        sonames.append(this_soname)
+                    if shlibs_search_dirs_re.match(file):
+                        # if library is private (only used by package) then do not build shlib for it
+                        if not private_libs or -1 == private_libs.find(this_soname):
+                            sonames.append(this_soname)
+                    else:
+                        bb.debug(2, "ignoring soname %s from %s, because path doesn't match %s" % (this_soname, file, shlibs_search_dirs_re_txt))
                 if libdir_re.match(os.path.dirname(file)):
                     needs_ldconfig = True
                 if snap_symlinks and (os.path.basename(file) != this_soname):