Skip to contentSkip to conversation

package.bbclass: add PRIVATE_LIBS_ALL

PATCH In review Alexander Kanavin 1 participant 2 messages Sep 3, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package.bbclass: add PRIVATE_LIBS_ALL

PRIVATE_LIBS is used to exclude 'private' libraries from getting added to automatic runtime dependency resolution. That variable has to list all libraries by name which becomes a maintenance issue if the list of such libraries frequently changes, or is very large.

PRIVATE_LIBS_ALL allows declaring all libraries private, either for a specific target package (e.g. -ptest), or for all packages produced by a recipe.

---
 meta/classes/package.bbclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/classes/package.bbclass +6 -4
index 114d6559f5e..f6ccd908b4a 100644
@@ -1646,7 +1646,7 @@ python package_do_shlibs() {
                 prov = (this_soname, ldir, pkgver)
                 if not prov in sonames:
                     # if library is private (only used by package) then do not build shlib for it
-                    if not private_libs or this_soname not in private_libs:
+                    if (not private_libs or this_soname not in private_libs) and not private_libs_all:
                         sonames.add(prov)
                 if libdir_re.match(os.path.dirname(file)):
                     needs_ldconfig = True
@@ -1739,6 +1739,7 @@ python package_do_shlibs() {
     for pkg in shlib_pkgs:
         private_libs = d.getVar('PRIVATE_LIBS_' + pkg) or d.getVar('PRIVATE_LIBS') or ""
         private_libs = private_libs.split()
+        private_libs_all = d.getVar('PRIVATE_LIBS_ALL_' + pkg) or d.getVar('PRIVATE_LIBS_ALL')
         needs_ldconfig = False
         bb.debug(2, "calculating shlib provides for %s" % pkg)
 
@@ -1821,6 +1822,7 @@ python package_do_shlibs() {
 
         private_libs = d.getVar('PRIVATE_LIBS_' + pkg) or d.getVar('PRIVATE_LIBS') or ""
         private_libs = private_libs.split()
+        private_libs_all = d.getVar('PRIVATE_LIBS_ALL_' + pkg) or d.getVar('PRIVATE_LIBS_ALL')
 
         deps = list()
         for n in needed[pkg]:
@@ -1829,8 +1831,8 @@ python package_do_shlibs() {
             # /opt/abc/lib/libfoo.so.1 and contains /usr/bin/abc depending on system library libfoo.so.1
             # but skipping it is still better alternative than providing own
             # version and then adding runtime dependency for the same system library
-            if private_libs and n[0] in private_libs:
-                bb.debug(2, '%s: Dependency %s covered by PRIVATE_LIBS' % (pkg, n[0]))
+            if (private_libs and n[0] in private_libs) or private_libs_all:
+                bb.debug(2, '%s: Dependency %s covered by PRIVATE_LIBS or PRIVATE_LIBS_ALL' % (pkg, n[0]))
                 continue
             if n[0] in shlib_provider.keys():
                 shlib_provider_path = []
@@ -2113,7 +2115,7 @@ python package_depchains() {
 
 # Since bitbake can't determine which variables are accessed during package
 # iteration, we need to list them here:
-PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm pkg_postinst_ontarget INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR USERADD_PARAM GROUPADD_PARAM CONFFILES SYSTEMD_SERVICE LICENSE SECTION pkg_preinst pkg_prerm RREPLACES GROUPMEMS_PARAM SYSTEMD_AUTO_ENABLE SKIP_FILEDEPS PRIVATE_LIBS"
+PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm pkg_postinst_ontarget INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR USERADD_PARAM GROUPADD_PARAM CONFFILES SYSTEMD_SERVICE LICENSE SECTION pkg_preinst pkg_prerm RREPLACES GROUPMEMS_PARAM SYSTEMD_AUTO_ENABLE SKIP_FILEDEPS PRIVATE_LIBS PRIVATE_LIBS_ALL"
 
 def gen_packagevar(d):
     ret = []
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · Alexander Kanavin

PRIVATE_LIBS is used to exclude 'private' libraries from getting added to automatic runtime dependency resolution. That variable has to list all libraries by name which becomes a maintenance issue if the list of such libraries frequently changes, or is very large.

PRIVATE_LIBS_ALL allows declaring all libraries private, either for a specific target package (e.g. -ptest), or for all packages produced by a recipe.

Please discard this, we can use fnmatch.fnmatch(*filename*, *pattern*) to simply allow wildcards in PRIVATE_LIBS. I will make another patch.

Alex