Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] package.bbclass: check packages name conflict in do_package
@ 2023-03-22 16:42 Fawzi KHABER
  2023-03-22 16:42 ` [PATCH 2/2] oeqa/selftest/cases/package.py: adding unittest for package rename conflicts Fawzi KHABER
  2023-03-23  8:25 ` [OE-core] [PATCH 1/2] package.bbclass: check packages name conflict in do_package Alexandre Belloni
  0 siblings, 2 replies; 4+ messages in thread
From: Fawzi KHABER @ 2023-03-22 16:42 UTC (permalink / raw)
  To: openembedded-core; +Cc: Fawzi KHABER, Yoann CONGAL

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:         
+            bb.fatal('package %s is renamed %s using PKG:%s, but package name already exists'%(p,rename,p))
+
     ###########################################################################
     # Optimisations
     ###########################################################################
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] oeqa/selftest/cases/package.py: adding unittest for package rename conflicts
  2023-03-22 16:42 [PATCH 1/2] package.bbclass: check packages name conflict in do_package Fawzi KHABER
@ 2023-03-22 16:42 ` Fawzi KHABER
  2023-03-23  8:25 ` [OE-core] [PATCH 1/2] package.bbclass: check packages name conflict in do_package Alexandre Belloni
  1 sibling, 0 replies; 4+ messages in thread
From: Fawzi KHABER @ 2023-03-22 16:42 UTC (permalink / raw)
  To: openembedded-core; +Cc: Fawzi KHABER, Yoann CONGAL

This Unittest tries to rename a package, using an already used name and
fails on do_package.

Reviewed-by: Yoann CONGAL <yoann.congal@smile.fr>
Signed-off-by: Fawzi KHABER <fawzi.khaber@smile.fr>
---
 .../packagenameconflict/packagenameconflict.bb            | 8 ++++++++
 meta/classes-global/package.bbclass                       | 3 +--
 meta/lib/oeqa/selftest/cases/package.py                   | 7 +++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 meta-selftest/recipes-test/packagenameconflict/packagenameconflict.bb

diff --git a/meta-selftest/recipes-test/packagenameconflict/packagenameconflict.bb b/meta-selftest/recipes-test/packagenameconflict/packagenameconflict.bb
new file mode 100644
index 0000000000..291d37c5f6
--- /dev/null
+++ b/meta-selftest/recipes-test/packagenameconflict/packagenameconflict.bb
@@ -0,0 +1,8 @@
+SUMMARY = "Test case that tries to rename a package to an existing one and fails"
+DESCRIPTION = "This generates a packaging error when a package is renamed to a pre-existing name"
+LICENSE = "MIT"
+
+# Add a new package ${PN}-renametest
+PACKAGES += "${PN}-renametest"
+# ... and try to rename the ${PN}-dev to the new ${PN}-renametest (conflict)
+PKG:${PN}-dev = "${PN}-renametest"
diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index 30dfd63d4f..21461ff314 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -498,13 +498,12 @@ python do_package () {
 
     # 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))
+            bb.fatal('package "%s" is renamed to "%s" using PKG:%s, but package name already exists'%(p,rename,p))
 
     ###########################################################################
     # Optimisations
diff --git a/meta/lib/oeqa/selftest/cases/package.py b/meta/lib/oeqa/selftest/cases/package.py
index 4f7cd10658..1aa6c03f8a 100644
--- a/meta/lib/oeqa/selftest/cases/package.py
+++ b/meta/lib/oeqa/selftest/cases/package.py
@@ -89,6 +89,13 @@ class VersionOrdering(OESelftestTestCase):
             self.assertEqual(status - 100, sort, "%s %s (%d) failed" % (ver1, ver2, sort))
 
 class PackageTests(OESelftestTestCase):
+    # Verify that a recipe cannot rename a package into an existing one
+    def test_package_name_conflict(self):
+        res = bitbake("packagenameconflict", ignore_status=True)
+        self.assertNotEqual(res.status, 0)
+        err = "package name already exists"
+        self.assertTrue(err in res.output)
+
     # Verify that a recipe which sets up hardlink files has those preserved into split packages
     # Also test file sparseness is preserved
     def test_preserve_sparse_hardlinks(self):
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [OE-core] [PATCH 1/2] package.bbclass: check packages name conflict in do_package
  2023-03-22 16:42 [PATCH 1/2] package.bbclass: check packages name conflict in do_package Fawzi KHABER
  2023-03-22 16:42 ` [PATCH 2/2] oeqa/selftest/cases/package.py: adding unittest for package rename conflicts Fawzi KHABER
@ 2023-03-23  8:25 ` Alexandre Belloni
  2023-03-23  9:45   ` Fawzi KHABER
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2023-03-23  8:25 UTC (permalink / raw)
  To: Fawzi KHABER; +Cc: openembedded-core, Yoann CONGAL

Hello,

For some reason, this breaks the reproducible build:

https://autobuilder.yoctoproject.org/typhoon/#/builders/117/builds/2589/steps/13/logs/stdio

ERROR: packagenameconflict-1.0-r0 do_package: package "packagenameconflict-dev" is renamed to "packagenameconflict-renametest" using PKG:packagenameconflict-dev, but package name already exists
ERROR: Logfile of failure stored in: /home/pokybuild/yocto-worker/reproducible/build/build-st/reproducibleA/tmp/work/core2-64-poky-linux/packagenameconflict/1.0-r0/temp/log.do_package.3523737
NOTE: recipe packagenameconflict-1.0-r0: task do_package: Failed
ERROR: Task (/home/pokybuild/yocto-worker/reproducible/build/build-st/meta-selftest/recipes-test/packagenameconflict/packagenameconflict.bb:do_package) failed with exit code '1'
NOTE: Running task 12650 of 16502 (/home/pokybuild/yocto-worker/reproducible/build/build-st/meta-selftest/recipes-devtools/python/python3-async-test_0.6.2.bb:do_package)

On 22/03/2023 17:42:23+0100, 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:         
> +            bb.fatal('package %s is renamed %s using PKG:%s, but package name already exists'%(p,rename,p))
> +
>      ###########################################################################
>      # Optimisations
>      ###########################################################################
> -- 
> 2.39.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#178951): https://lists.openembedded.org/g/openembedded-core/message/178951
> Mute This Topic: https://lists.openembedded.org/mt/97782594/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] package.bbclass: check packages name conflict in do_package
  2023-03-23  8:25 ` [OE-core] [PATCH 1/2] package.bbclass: check packages name conflict in do_package Alexandre Belloni
@ 2023-03-23  9:45   ` Fawzi KHABER
  0 siblings, 0 replies; 4+ messages in thread
From: Fawzi KHABER @ 2023-03-23  9:45 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 105 bytes --]

yes, my bad the recipe is lacking EXCLUDE_FROM_WORLD = "1", i'm sending patch v2
Thanks you Alexandre.

[-- Attachment #2: Type: text/html, Size: 109 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-23  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-22 16:42 [PATCH 1/2] package.bbclass: check packages name conflict in do_package Fawzi KHABER
2023-03-22 16:42 ` [PATCH 2/2] oeqa/selftest/cases/package.py: adding unittest for package rename conflicts Fawzi KHABER
2023-03-23  8:25 ` [OE-core] [PATCH 1/2] package.bbclass: check packages name conflict in do_package Alexandre Belloni
2023-03-23  9:45   ` Fawzi KHABER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox