[v2] multiarch: Fix PN-to-BPN massaging

Message ID f67b7757-1984-4c0d-b2db-70b6a09e4260@web.de
State Accepted, archived
Headers show
Series [v2] multiarch: Fix PN-to-BPN massaging | expand

Commit Message

Jan Kiszka April 1, 2024, 1:17 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

SRC_URI and FILESPATH are differently built, thus can't be handled the
same way when trying to translate PN to BPN. While entries in the former
are space-separated, they are colon-separated in the latter.

Furthermore, the existing logic didn't properly split the entries, rather
processed the complete string. That was surely not desired as well.

Account for all by handling the variables separately and by splitting
them first. This fixes warnings like

WARNING: /build/../repo/meta-isar/recipes-core/images/isar-image-installer.bb: Unable to get checksum for isar-image-installer-native SRC_URI entry debian-configscript.sh: file could not be found

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Changes since v2:
 - picked final patch from local queue, fixing SRC_URI regression

 meta/classes/multiarch.bbclass | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

--
2.35.3

Comments

Uladzimir Bely April 9, 2024, 5:25 a.m. UTC | #1
On Mon, 2024-04-01 at 15:17 +0200, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> SRC_URI and FILESPATH are differently built, thus can't be handled
> the
> same way when trying to translate PN to BPN. While entries in the
> former
> are space-separated, they are colon-separated in the latter.
> 
> Furthermore, the existing logic didn't properly split the entries,
> rather
> processed the complete string. That was surely not desired as well.
> 
> Account for all by handling the variables separately and by splitting
> them first. This fixes warnings like
> 
> WARNING: /build/../repo/meta-isar/recipes-core/images/isar-image-
> installer.bb: Unable to get checksum for isar-image-installer-native
> SRC_URI entry debian-configscript.sh: file could not be found
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Changes since v2:
>  - picked final patch from local queue, fixing SRC_URI regression
> 
>  meta/classes/multiarch.bbclass | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/classes/multiarch.bbclass
> b/meta/classes/multiarch.bbclass
> index 5783b0bf..5c97453b 100644
> --- a/meta/classes/multiarch.bbclass
> +++ b/meta/classes/multiarch.bbclass
> @@ -46,12 +46,16 @@ python multiarch_virtclass_handler() {
>      # parse time, and parsing always happens for all build variants.
> So in those
>      # few variables, we automatically replace ${PN} with ${BPN}.
>      def fixup_pn_in_vars(d):
> -        vars = 'SRC_URI FILESPATH'.split()
> -        for var in vars:
> -            v = d.getVar(var, expand=False)
> -            if v is not None and '${PN}' in v:
> -                d.setVar(var + ':remove', v)
> -                d.appendVar(var, ' ' + v.replace('${PN}', '${BPN}'))
> +        v = d.getVar('SRC_URI', expand=False) or ''
> +        for uri in v.split():
> +            if '${PN}' in uri:
> +                d.setVar('SRC_URI' + ':remove', uri)
> +                d.appendVar('SRC_URI', ' ' + uri.replace('${PN}',
> '${BPN}'))
> +
> +        v = d.getVar('FILESPATH', expand=False) or ''
> +        for path in v.split(':'):
> +            if '${PN}' in path:
> +                d.appendVar('FILESPATH', ':' + path.replace('${PN}',
> '${BPN}'))
> 
>      # When building compat/native, the corresponding suffix needs to
> be
>      # propagated to all bitbake dependency definitions.
> --
> 2.35.3
>

Patch

diff --git a/meta/classes/multiarch.bbclass b/meta/classes/multiarch.bbclass
index 5783b0bf..5c97453b 100644
--- a/meta/classes/multiarch.bbclass
+++ b/meta/classes/multiarch.bbclass
@@ -46,12 +46,16 @@  python multiarch_virtclass_handler() {
     # parse time, and parsing always happens for all build variants. So in those
     # few variables, we automatically replace ${PN} with ${BPN}.
     def fixup_pn_in_vars(d):
-        vars = 'SRC_URI FILESPATH'.split()
-        for var in vars:
-            v = d.getVar(var, expand=False)
-            if v is not None and '${PN}' in v:
-                d.setVar(var + ':remove', v)
-                d.appendVar(var, ' ' + v.replace('${PN}', '${BPN}'))
+        v = d.getVar('SRC_URI', expand=False) or ''
+        for uri in v.split():
+            if '${PN}' in uri:
+                d.setVar('SRC_URI' + ':remove', uri)
+                d.appendVar('SRC_URI', ' ' + uri.replace('${PN}', '${BPN}'))
+
+        v = d.getVar('FILESPATH', expand=False) or ''
+        for path in v.split(':'):
+            if '${PN}' in path:
+                d.appendVar('FILESPATH', ':' + path.replace('${PN}', '${BPN}'))

     # When building compat/native, the corresponding suffix needs to be
     # propagated to all bitbake dependency definitions.