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 <[email protected]> --- 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
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#242548): https://lists.openembedded.org/g/openembedded-core/message/242548 Mute This Topic: https://lists.openembedded.org/mt/120561039/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
