Skip to contentSkip to conversation

package.bbclass: allow additional implementations for dependencies

RFC PATCH New André Draszik 1 participant 1 message Mar 21, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 package.bbclass: allow additional implementations for dependencies

From: André Draszik <[email protected]>

The existing code in here is pretty much hard-coded to extract package RDEPENDS based on information obtained from elf files, i.e. by looking at the NEEDED entries, and it appears pretty much impossible to extend this.

There are use-cases, where automatic inter-package and recipe dependency tracking is useful for other types of files, e.g. in Java world one could parse the .jar files' MANIFEST.MF to extract information very similar to that extracted from elf files, and then create the packages with that information applied. JAR files are simply another form of shared library.

Currently, it is rather hard to impossible to add such functionality to be executed at the right time, i.e. before read_shlibdeps() is executed (which itself adds that information to each package's RDEPENDS).

Introduce the infrastructure to be able to do so. The expectation is that some filetype specific additional bbclass (e.g. a Java JAR file specific one to stay with above example) extends PACKAGE_DEP_FUNCS with a function to ultimately create files with layout/contents similar to what is already done in existing files matching PACKAGE_LIBDEPS_EXTENSIONS during the package build process - based on the interdependency information from that specific filetype, e.g. JAR - and store that in a new file in the same directory as existing .shlibdeps, .pcdeps, etc. (pkgdest) and whose suffix is to be added to PACKAGE_LIBDEPS_EXTENSIONS.

---
 meta/classes/package.bbclass | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
meta/classes/package.bbclass +11 -4
index 4c0a859536..0af282fbef 100644
@@ -1970,12 +1970,13 @@ python package_do_pkgconfig () {
             fd.close()
 }
 
+PACKAGE_LIBDEPS_EXTENSIONS ?= ".shlibdeps .pcdeps .clilibdeps"
 def read_libdep_files(d):
     pkglibdeps = {}
     packages = d.getVar('PACKAGES').split()
     for pkg in packages:
         pkglibdeps[pkg] = {}
-        for extension in ".shlibdeps", ".pcdeps", ".clilibdeps":
+        for extension in d.getVar('PACKAGE_LIBDEPS_EXTENSIONS').split():
             depsfile = d.expand("${PKGDEST}/" + pkg + extension)
             if os.access(depsfile, os.R_OK):
                 fd = open(depsfile)
@@ -2156,13 +2157,19 @@ PACKAGEBUILDPKGD ?= " \
 PACKAGESPLITFUNCS ?= " \
                 package_do_split_locales \
                 populate_packages"
+# Functions that generate dependencies based on
+# elf NEEDED, pkgconfig, etc. This can be extended
+# to handle other file types.
+PACKAGE_DEP_FUNCS ?= " \
+                package_do_filedeps \
+                package_do_shlibs \
+                package_do_pkgconfig \
+                "
 # Functions which process metadata based on split packages
 PACKAGEFUNCS += " \
                 package_fixsymlinks \
                 package_name_hook \
-                package_do_filedeps \
-                package_do_shlibs \
-                package_do_pkgconfig \
+                ${PACKAGE_DEP_FUNCS} \
                 read_shlibdeps \
                 package_depchains \
                 emit_pkgdata"
Signature · 1 line
2.20.1