Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 23/25] lib/oe/lsb: Merge distro_identifier functions
Date: Sun,  2 Aug 2026 11:28:52 +0100	[thread overview]
Message-ID: <20260802102854.3952760-24-richard.purdie@linuxfoundation.org> (raw)
In-Reply-To: <20260802102854.3952760-1-richard.purdie@linuxfoundation.org>

In order to access LSB_DISTRO_ADJUST fuctions, a portion of the lsb
distro_indetifier code was left in base.bbclass. There is a way to handle
this so merge the code into one function and use it from all call
sites.

This makes the code slightly less of a maze.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes-global/base.bbclass      | 12 +-----------
 meta/classes-global/sanity.bbclass    |  8 ++++----
 meta/classes-recipe/testimage.bbclass |  2 +-
 meta/classes/report-error.bbclass     |  2 +-
 meta/lib/oe/lsb.py                    | 10 +++++++++-
 meta/lib/oeqa/sdk/testsdk.py          |  2 +-
 6 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index 8b4abe8f1e2..5177179d572 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -35,16 +35,6 @@ TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}"
 inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native
 inherit_defer toolchain/${TOOLCHAIN}
 
-def lsb_distro_identifier(d):
-    adjust = d.getVar('LSB_DISTRO_ADJUST')
-    adjust_func = None
-    if adjust:
-        try:
-            adjust_func = globals()[adjust]
-        except KeyError:
-            pass
-    return oe.lsb.distro_identifier(adjust_func)
-
 die() {
 	bbfatal_log "$*"
 }
@@ -313,7 +303,7 @@ python base_eventhandler() {
 
     if isinstance(e, bb.event.ConfigParsed):
         if not d.getVar("NATIVELSBSTRING", False):
-            d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
+            d.setVar("NATIVELSBSTRING", oe.lsb.distro_identifier(d))
         d.setVar("ORIGNATIVELSBSTRING", d.getVar("NATIVELSBSTRING", False))
         d.setVar('BB_VERSION', bb.__version__)
 
diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 91c22599bfe..71cedea62c0 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -382,7 +382,7 @@ def check_supported_distro(sanity_data):
         return
 
     try:
-        distro = oe.lsb.distro_identifier()
+        distro = oe.lsb.distro_identifier(sanity_data)
     except Exception:
         distro = None
 
@@ -463,7 +463,7 @@ def check_make_version(sanity_data):
         return "Please install a make version of %s or later.\n" % make_minimum_version
 
     if bb.utils.vercmp_string_op(version, "4.2.1", "=="):
-        distro = oe.lsb.distro_identifier()
+        distro = oe.lsb.distro_identifier(sanity_data)
         if "ubuntu" in distro or "debian" in distro or "linuxmint" in distro:
             return None
         return "make version 4.2.1 is known to have issues on Centos/OpenSUSE and other non-Ubuntu systems. Please use a buildtools-make-tarball or a newer version of make.\n"
@@ -552,7 +552,7 @@ def check_tar_version(sanity_data):
         return "Unable to execute tar --help, exit code %d\n%s\n" % (e.returncode, e.output)
 
     try:
-        distro = oe.lsb.distro_identifier()
+        distro = oe.lsb.distro_identifier(sanity_data)
     except Exception:
         distro = None
 
@@ -1161,7 +1161,7 @@ def check_sanity(sanity_data):
     network_error = False
     # NATIVELSBSTRING var may have been overridden with "universal", so
     # get actual host distribution id and version
-    nativelsbstr = lsb_distro_identifier(sanity_data)
+    nativelsbstr = oe.lsb.distro_identifier(sanity_data)
     if last_sanity_version < sanity_version or last_nativelsbstr != nativelsbstr: 
         check_sanity_version_change(status, sanity_data)
         status.addresult(check_sanity_sstate_dir_change(sstate_dir, sanity_data))
diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass
index 5f0ec0b3a05..419ad6dcb02 100644
--- a/meta/classes-recipe/testimage.bbclass
+++ b/meta/classes-recipe/testimage.bbclass
@@ -160,7 +160,7 @@ def get_testimage_configuration(d, test_type, machine):
                     'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
                     'STARTTIME': d.getVar("DATETIME"),
                     'TCLIBC': d.getVar("TCLIBC"),
-                    'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'),
+                    'HOST_DISTRO': oe.lsb.distro_identifier(d).replace(' ', '-'),
                     'LAYERS': get_layers(d.getVar("BBLAYERS"))}
     return configuration
 get_testimage_configuration[vardepsexclude] = "DATETIME"
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index ad31ac25833..6989738fadd 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -60,7 +60,7 @@ python errorreport_handler () {
             nativelsbstr = e.data.getVar("NATIVELSBSTRING")
             # provide a bit more host info in case of uninative build
             if e.data.getVar('UNINATIVE_URL') != 'unset':
-                return '/'.join([nativelsbstr, lsb_distro_identifier(e.data)])
+                return '/'.join([nativelsbstr, oe.lsb.distro_identifier(e.data)])
             return nativelsbstr
 
         logpath = e.data.getVar('ERR_REPORT_DIR')
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py
index 650fb0572d0..1dfc19be333 100644
--- a/meta/lib/oe/lsb.py
+++ b/meta/lib/oe/lsb.py
@@ -18,7 +18,7 @@ def get_os_release():
                 data[key.strip()] = val.strip('"\'')
     return data
 
-def distro_identifier(adjust_hook=None):
+def distro_identifier(d=None):
     """Return a distro identifier string based upon /etc/os-release
        with optional adjustment via a hook"""
 
@@ -28,6 +28,14 @@ def distro_identifier(adjust_hook=None):
 
     distro_id = distro_data.get('ID')
     release = distro_data.get('VERSION_ID')
+    adjust_hook = None
+    if d:
+        adjust = d.getVar('LSB_DISTRO_ADJUST')
+        if adjust:
+            try:
+               adjust_hook = bb.utils.get_context()[adjust]
+            except KeyError:
+                pass
 
     if adjust_hook:
         distro_id, release = adjust_hook(distro_id, release)
diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py
index 98ef9c71cd6..7b0765f2726 100644
--- a/meta/lib/oeqa/sdk/testsdk.py
+++ b/meta/lib/oeqa/sdk/testsdk.py
@@ -18,7 +18,7 @@ class TestSDKBase(object):
                         'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"),
                         'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
                         'STARTTIME': d.getVar("DATETIME"),
-                        'HOST_DISTRO': oe.lsb.distro_identifier().replace(' ', '-'),
+                        'HOST_DISTRO': oe.lsb.distro_identifier(d).replace(' ', '-'),
                         'LAYERS': get_layers(d.getVar("BBLAYERS"))}
         return configuration
 


  parent reply	other threads:[~2026-08-02 10:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 10:28 [PATCH 00/25] Class file improvements Richard Purdie
2026-08-02 10:28 ` [PATCH 01/25] sstatesig: Use kernel.bbclass instead of linux-kernel-base.bbclass Richard Purdie
2026-08-02 10:28 ` [PATCH 02/25] linux-kernel-base: Delete unused function Richard Purdie
2026-08-02 10:28 ` [PATCH 03/25] lib/oe/kernel: Move python functions from linux-kernel-base to library code Richard Purdie
2026-08-02 10:28 ` [PATCH 04/25] kernel-yocto: Simplify code for cleanliness and slight performance Richard Purdie
2026-08-02 10:28 ` [PATCH 05/25] kernel-arch: Move kernel and uboot arch functions to lib/oe/kernel.py Richard Purdie
2026-08-02 10:28 ` [PATCH 06/25] kernel-arch: Simplify KERNEL_ARCH variable usage Richard Purdie
2026-08-02 10:28 ` [PATCH 07/25] kernel-arch: Don't export UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 08/25] u-boot: Separate out from kernel-arch.bbclass Richard Purdie
2026-08-02 10:28 ` [PATCH 09/25] barebox: " Richard Purdie
2026-08-02 10:28 ` [PATCH 10/25] lib/oe/kernel: Simplify map_uboot_arch Richard Purdie
2026-08-02 10:28 ` [PATCH 11/25] image_types/kernel-uimage: Swap UBOOT_ARCH for oe.kernel.map_uboot_arch call Richard Purdie
2026-08-02 10:58   ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 12/25] kernel-fit-image: " Richard Purdie
2026-08-02 10:28 ` [PATCH 13/25] linux-yocto-fitimage: Set UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 14/25] kernel-arch: Drop UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 15/25] linux-libc-headers: Drop kernel-arch and set ARCH directly Richard Purdie
2026-08-02 10:28 ` [PATCH 16/25] toolchain-scripts: Drop usage of kernel-arch Richard Purdie
2026-08-02 10:28 ` [PATCH 17/25] kernel-arch: Move ARCH usage into target classes Richard Purdie
2026-08-02 10:28 ` [PATCH 18/25] linux-yocto-fitimage: Drop obsolete dependency on linux-kernel-base Richard Purdie
2026-08-02 10:58   ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 19/25] linux-kernel-base: Fold remainder into kernel-arch and drop Richard Purdie
2026-08-02 10:28 ` [PATCH 20/25] kernel-devicetree: Add missing function prefixes Richard Purdie
2026-08-02 10:28 ` [PATCH 21/25] utils: Drop explode_deps function Richard Purdie
2026-08-02 10:28 ` [PATCH 22/25] utils: Move functions from utils.bbclass to utils.py Richard Purdie
2026-08-02 10:58   ` Patchtest results for " patchtest
2026-08-02 10:28 ` Richard Purdie [this message]
2026-08-02 10:28 ` [PATCH 24/25] sanity: Move code to lib/oe Richard Purdie
2026-08-02 10:58   ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 25/25] sanity: Drop unreachable code Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260802102854.3952760-24-richard.purdie@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox