diff mbox series

meta/classes/create-spdx.bbclass: support to inherit SPDX class conditionally

Message ID 20241227061111.2086879-1-hongxu.jia@windriver.com
State New
Headers show
Series meta/classes/create-spdx.bbclass: support to inherit SPDX class conditionally | expand

Commit Message

Hongxu Jia Dec. 27, 2024, 6:11 a.m. UTC
In order to inherit SPDX class conditionally, using variable ${SPDX_CLASS}
to inherit SPDX class other than original 'INHERIT:remove = "create-spdx"'
and INHERIT += "create-spdx-2.2"

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes/create-spdx.bbclass     | 3 ++-
 meta/lib/oeqa/selftest/cases/spdx.py | 8 ++------
 2 files changed, 4 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass
index b604973ae0..35cd63f31e 100644
--- a/meta/classes/create-spdx.bbclass
+++ b/meta/classes/create-spdx.bbclass
@@ -5,4 +5,5 @@ 
 #
 # Include this class when you don't care what version of SPDX you get; it will
 # be updated to the latest stable version that is supported
-inherit create-spdx-3.0
+SPDX_CLASS ??= "create-spdx-3.0"
+inherit ${SPDX_CLASS}
diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py
index f3b955ed2b..4789041a6a 100644
--- a/meta/lib/oeqa/selftest/cases/spdx.py
+++ b/meta/lib/oeqa/selftest/cases/spdx.py
@@ -24,8 +24,7 @@  class SPDX22Check(OESelftestTestCase):
     def check_recipe_spdx(self, high_level_dir, spdx_file, target_name):
         config = textwrap.dedent(
             """\
-            INHERIT:remove = "create-spdx"
-            INHERIT += "create-spdx-2.2"
+            SPDX_CLASS = "create-spdx-2.2"
             """
         )
         self.write_config(config)
@@ -89,8 +88,7 @@  class SPDX3CheckBase(object):
         config = (
             textwrap.dedent(
                 f"""\
-                INHERIT:remove = "create-spdx"
-                INHERIT += "{self.SPDX_CLASS}"
+                SPDX_CLASS = "create-spdx-3.0"
                 """
             )
             + textwrap.dedent(extraconf)
@@ -138,8 +136,6 @@  class SPDX3CheckBase(object):
 
 
 class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
-    SPDX_CLASS = "create-spdx-3.0"
-
     def test_base_files(self):
         self.check_recipe_spdx(
             "base-files",