diff mbox series

[v2,1/2] package.bbclass: check packages name conflict in do_package

Message ID 20230323095655.6319-1-fawzi.khaber@smile.fr
State Accepted, archived
Commit f6cb63d3a871c4eef52d981131a56bf41aa1dcdf
Headers show
Series [v2,1/2] package.bbclass: check packages name conflict in do_package | expand

Commit Message

Fawzi KHABER March 23, 2023, 9:56 a.m. UTC
It is possible to rename packages with the macro PKG:${PN} and result in
a package name conflict if the target name exists already.

Add a fatal check to prevent this issue to go unnoticed.

Fix [Yocto #12060]

Reviewed-by: Yoann CONGAL <yoann.congal@smile.fr>
Signed-off-by: Fawzi KHABER <fawzi.khaber@smile.fr>
---
 meta/classes-global/package.bbclass | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Yoann Congal March 27, 2023, 9:48 p.m. UTC | #1
Hi Fawzi,

On 3/23/23 10:56, Fawzi KHABER wrote:
> It is possible to rename packages with the macro PKG:${PN} and result in
> a package name conflict if the target name exists already.
> 
> Add a fatal check to prevent this issue to go unnoticed.
> 
> Fix [Yocto #12060]
> 
> Reviewed-by: Yoann CONGAL <yoann.congal@smile.fr>
> Signed-off-by: Fawzi KHABER <fawzi.khaber@smile.fr>
> ---
>  meta/classes-global/package.bbclass | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
> index 7e96601cd9..30dfd63d4f 100644
> --- a/meta/classes-global/package.bbclass
> +++ b/meta/classes-global/package.bbclass
> @@ -496,6 +496,16 @@ python do_package () {
>  
>      bb.build.exec_func("package_convert_pr_autoinc", d)
>  
> +    # Check for conflict between renamed packages and existing ones
> +    # for each package in PACKAGES, check if it will be renamed to an existing one
> +
> +    for p in packages:
> +        localdata = bb.data.createCopy(d)
> +        localdata.setVar('OVERRIDES', p)
> +        rename = localdata.getVar('PKG')
> +        if (rename != None) and rename in packages:         
This line adds a bunch of whitespaces at the end of the line.

> +            bb.fatal('package %s is renamed %s using PKG:%s, but package name already exists'%(p,rename,p))
> +
>      ###########################################################################
>      # Optimisations
>      ###########################################################################
diff mbox series

Patch

diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index 7e96601cd9..30dfd63d4f 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -496,6 +496,16 @@  python do_package () {
 
     bb.build.exec_func("package_convert_pr_autoinc", d)
 
+    # Check for conflict between renamed packages and existing ones
+    # for each package in PACKAGES, check if it will be renamed to an existing one
+
+    for p in packages:
+        localdata = bb.data.createCopy(d)
+        localdata.setVar('OVERRIDES', p)
+        rename = localdata.getVar('PKG')
+        if (rename != None) and rename in packages:         
+            bb.fatal('package %s is renamed %s using PKG:%s, but package name already exists'%(p,rename,p))
+
     ###########################################################################
     # Optimisations
     ###########################################################################