Patchwork [2/5] package.bbclass: show warning when package is trying to provide already provided shlib

login
register
mail settings
Submitter Martin Jansa
Date Jan. 18, 2014, 2:02 p.m.
Message ID <c121197f51f33bbfe6a4322597205d51287bc261.1390052636.git.Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/65179/
State New
Headers show

Comments

Martin Jansa - Jan. 18, 2014, 2:02 p.m.
* move read_shlib_providers before registering package as provider
  and don't change provider if it already exists, show warning instead

[YOCTO #4628]

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/package.bbclass | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Martin Jansa - Jan. 19, 2014, 1:13 p.m.
On Sat, Jan 18, 2014 at 03:02:07PM +0100, Martin Jansa wrote:
> * move read_shlib_providers before registering package as provider
>   and don't change provider if it already exists, show warning instead
> 
> [YOCTO #4628]
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/classes/package.bbclass | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 7dcec5e..aa8156d 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -1356,6 +1356,7 @@ python package_do_shlibs() {
>          list_re = re.compile('^(.*)\.list$')
>          # Go from least to most specific since the last one found wins
>          for dir in reversed(shlibs_dirs):
> +            bb.debug(2, "Reading shlib providers in %s" % (dir))
>              if not os.path.exists(dir):
>                  continue
>              for file in os.listdir(dir):
> @@ -1471,6 +1472,8 @@ python package_do_shlibs() {
>  
>      needed = {}
>      shlib_provider = {}
> +    read_shlib_providers()
> +
>      for pkg in packages.split():
>          private_libs = d.getVar('PRIVATE_LIBS_' + pkg, True) or d.getVar('PRIVATE_LIBS', True)
>          needs_ldconfig = False
> @@ -1504,6 +1507,12 @@ python package_do_shlibs() {
>          if len(sonames):
>              fd = open(shlibs_file, 'w')
>              for s in sonames:
> +                if s in shlib_provider:
> +                    (old_pkg, old_pkgver) = shlib_provider[s]
> +                    if old_pkg != pkg:
> +                        bb.warn('%s-%s is already registered as shlib provider for %s, ignoring %s-%s trying to register the same' % (old_pkg, old_pkgver, s, pkg, pkgver))
> +                        continue

I'll drop continue and update warning message, changing registered
provider for last built is still undeterministic but slightly better
e.g. when changing packaging and the shlib is moved between packages
(I've run into this in efl, when moving to split packages and they were
still getting runtime dependency on old efl package).

> +                bb.debug(1, 'registering %s-%s as shlib provider for %s' % (pkg, pkgver, s))
>                  fd.write(s + '\n')
>                  shlib_provider[s] = (pkg, pkgver)
>              fd.close()
> @@ -1517,8 +1526,7 @@ python package_do_shlibs() {
>                  postinst = '#!/bin/sh\n'
>              postinst += d.getVar('ldconfig_postinst_fragment', True)
>              d.setVar('pkg_postinst_%s' % pkg, postinst)
> -
> -    read_shlib_providers()
> +        bb.debug(1, 'LIBNAMES: pkg %s sonames %s' % (pkg, sonames))
>  
>      bb.utils.unlockfile(lf)
>  
> -- 
> 1.8.5.2
>

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7dcec5e..aa8156d 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1356,6 +1356,7 @@  python package_do_shlibs() {
         list_re = re.compile('^(.*)\.list$')
         # Go from least to most specific since the last one found wins
         for dir in reversed(shlibs_dirs):
+            bb.debug(2, "Reading shlib providers in %s" % (dir))
             if not os.path.exists(dir):
                 continue
             for file in os.listdir(dir):
@@ -1471,6 +1472,8 @@  python package_do_shlibs() {
 
     needed = {}
     shlib_provider = {}
+    read_shlib_providers()
+
     for pkg in packages.split():
         private_libs = d.getVar('PRIVATE_LIBS_' + pkg, True) or d.getVar('PRIVATE_LIBS', True)
         needs_ldconfig = False
@@ -1504,6 +1507,12 @@  python package_do_shlibs() {
         if len(sonames):
             fd = open(shlibs_file, 'w')
             for s in sonames:
+                if s in shlib_provider:
+                    (old_pkg, old_pkgver) = shlib_provider[s]
+                    if old_pkg != pkg:
+                        bb.warn('%s-%s is already registered as shlib provider for %s, ignoring %s-%s trying to register the same' % (old_pkg, old_pkgver, s, pkg, pkgver))
+                        continue
+                bb.debug(1, 'registering %s-%s as shlib provider for %s' % (pkg, pkgver, s))
                 fd.write(s + '\n')
                 shlib_provider[s] = (pkg, pkgver)
             fd.close()
@@ -1517,8 +1526,7 @@  python package_do_shlibs() {
                 postinst = '#!/bin/sh\n'
             postinst += d.getVar('ldconfig_postinst_fragment', True)
             d.setVar('pkg_postinst_%s' % pkg, postinst)
-
-    read_shlib_providers()
+        bb.debug(1, 'LIBNAMES: pkg %s sonames %s' % (pkg, sonames))
 
     bb.utils.unlockfile(lf)