]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
native: Improve ${PN}-XXX package name handling
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 6 Jan 2025 16:06:10 +0000 (16:06 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 10 Jan 2025 11:23:43 +0000 (11:23 +0000)
If a recipe has something like:

RPROVIDES:${PN}-xxx = "yyy"

then the current code will turn this into:

RPROVIDES:${BPN}-native-xxx = "yyy-native"

which can lead to errors. Add in some handling for this special case in the class
extension code.

The corresponding entry in PACKAGES is correctly remapped, the variables aren't
remapped to match though.

Note that merging this does trigger new dependencies to be exposed, some of which
can't be met or are incorrect. These need to be fixed on a case by case basis.

There was also a problem in the existing code when handling anonymous python in
PACKAGES since it would pass bizarre package names like "d)}" to the remapping code.
This patch changes it to ignore anonymous python since in the native case, this likely
isn't wanted anyway. This also then avoids ${PN}-ptest in the native case which was a
common dependency problem.

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

index d9651a7f22dedfe4040d4ad33ae572a7b9ff1581..1d9432138efe19003be583ccf0d301e2365dfccd 100644 (file)
@@ -119,6 +119,7 @@ SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}"
 INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}"
 
 python native_virtclass_handler () {
+    import re
     pn = e.data.getVar("PN")
     if not pn.endswith("-native"):
         return
@@ -158,10 +159,20 @@ python native_virtclass_handler () {
                 newdeps.append(dep.replace(pn, bpn) + "-native")
             else:
                 newdeps.append(dep)
-        d.setVar(varname, " ".join(newdeps))
+        output_varname = varname
+        # Handle ${PN}-xxx -> ${BPN}-xxx-native
+        if suffix != "${PN}" and "${PN}" in suffix:
+            output_varname = varname.replace("${PN}", "${BPN}") + "-native"
+            d.renameVar(varname, output_varname)
+        d.setVar(output_varname, " ".join(newdeps))
 
     map_dependencies("DEPENDS", e.data, selfref=False)
-    for pkg in e.data.getVar("PACKAGES", False).split():
+    # We need to handle things like ${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)}
+    # and not pass ${PN}-test since in the native case it would be ignored. This does mean we ignore
+    # anonymous python derived PACKAGES entries.
+    for pkg in re.split(r"\${@(?:{.*?}|.)+?}|\s", d.getVar("PACKAGES", False)):
+        if not pkg:
+            continue
         map_dependencies("RDEPENDS", e.data, pkg)
         map_dependencies("RRECOMMENDS", e.data, pkg)
         map_dependencies("RSUGGESTS", e.data, pkg)