From patchwork Mon Nov 30 15:26:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 106496 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.34823.1796052428917560839 for ; Mon, 30 Nov 2026 07:27:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=bsNjVk9l; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.48, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a214c5c4c0so103323775e9.3 for ; Mon, 30 Nov 2026 07:27:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1796052427; x=1796657227; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=SnHnSM50l1mlrB6phSR8+vbbO0KRtYGZfZyEHCTqYh4=; b=bsNjVk9lk+Ya9qBERYjHGIGvGTsE6oBy0F6U1NWJJrTmFJTF8/bhiNMqPO3zUcNfk2 sDvgrt5KylbN4iAY61FnLlDEGBPuDRC64+wG4rO/nVBGfezdUiFD/XZT5/UF4xehXTFf IuLV97RmXnIuVwWhv5Y9KJvoe5GuCj0adhNtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796052427; x=1796657227; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=SnHnSM50l1mlrB6phSR8+vbbO0KRtYGZfZyEHCTqYh4=; b=1DWN9ja+GtLirClGf0rtMsQ/GR76Sdm9/Lt8+Y0RSsQXS2WxEOdHL991cABMzMIjhx KdeBm9siOzjF2P8EdRiE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b2b:b0:4bb:c0b7:6cbf with SMTP id 5b1f17b1804b1-4bbc0b76e34mr118028385e9.2.1796052426672; Mon, 30 Nov 2026 07:27:06 -0800 (PST) Return-Path: Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:2444:81bb:2aff:8d84]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8538b09bsm1704014155e9.4.2026.11.30.07.27.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 07:27:05 -0800 (PST) From: Richard Purdie To: openembedded-core@lists.openembedded.org Subject: [PATCH 01/16] bitbake/base: Implement RECIPE_HOSTTOOLS Date: Mon, 30 Nov 2026 15:26:49 +0000 Message-ID: <20261130152704.3471590-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 15:27:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251610 Being able to have hosttools added within specific recipes would be useful rather than always in the global hosttools directory. Add support for this, impementing it within the TaskStarted event. We need to use a lockfile to ensure the function doesn't race against other tasks also trying to create the same thing. This directory builds on top of HOSTTOOLS which is left as existing so that we don't have to do any work for recipes which don't need specific additional tools. Add a dependency on the HOSTTOOLS to do_configure, so when things change, things do get correctly rebuilt. Previously it was impractical to do this. Move the conditional tools define for testimage/testsdk into the classes as the first user. This also avoids a problematic dependency on BB_INCLUDED which would then have to be excluded. Signed-off-by: Richard Purdie --- meta/classes-global/base.bbclass | 12 +++++++++++- meta/classes-global/sstate.bbclass | 6 +++--- meta/classes-global/staging.bbclass | 2 +- meta/classes-recipe/testimage.bbclass | 2 ++ meta/classes-recipe/testsdk.bbclass | 2 ++ meta/conf/bitbake.conf | 4 +--- meta/conf/layer.conf | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index 9553f004325..5aaa63ce505 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass @@ -153,7 +153,7 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True): notfound.append(tool) if notfound and fatal: - bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) + bb.fatal("The following required tools (as specified by %s) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % (toolsvar, " ".join(notfound))) # We can't use vardepvalue against do_fetch directly since that would overwrite # the other task dependencies so we use an indirect function. @@ -289,6 +289,15 @@ def buildcfg_neededvars(d): if pesteruser: bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser)) +addhandler base_task_eventhandler +base_task_eventhandler[eventmask] = "bb.build.TaskStarted" +python base_task_eventhandler() { + if d.getVar('RECIPE_HOSTTOOLS'): + toolsdir = d.getVar('RECIPE_HOSTTOOLS_DIR') + with bb.utils.fileslocked([toolsdir + ".lock"]): + setup_hosttools_dir(toolsdir, 'RECIPE_HOSTTOOLS', d) +} + addhandler base_eventhandler base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed bb.event.RecipePreDeferredInherits" python base_eventhandler() { @@ -383,6 +392,7 @@ base_do_configure() { echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} fi } +do_configure[vardeps] += "RECIPE_HOSTTOOLS HOSTTOOLS" addtask compile after do_configure do_compile[dirs] = "${B}" diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass index c6d94591823..4f8128d3d4c 100644 --- a/meta/classes-global/sstate.bbclass +++ b/meta/classes-global/sstate.bbclass @@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT # -SSTATE_VERSION = "14" +SSTATE_VERSION = "15" SSTATE_ZSTD_CLEVEL ??= "8" @@ -69,7 +69,7 @@ SSTATE_ALLOW_OVERLAP_FILES += "${DEPLOY_DIR_IMAGE}/microcode" SSTATE_SCAN_FILES ?= "*.la *-config *_config postinst-*" SSTATE_SCAN_CMD ??= 'find ${SSTATE_BUILDDIR} \( -name "${@"\" -o -name \"".join(d.getVar("SSTATE_SCAN_FILES").split())}" \) -type f' -SSTATE_SCAN_CMD_NATIVE ??= 'grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} -e ${HOSTTOOLS_DIR} ${SSTATE_BUILDDIR}' +SSTATE_SCAN_CMD_NATIVE ??= 'grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} -e ${RECIPE_HOSTTOOLS_DIR} -e ${HOSTTOOLS_DIR} ${SSTATE_BUILDDIR}' SSTATE_HASHEQUIV_FILEMAP ?= " \ populate_sysroot:*/postinst-useradd-*:${TMPDIR} \ populate_sysroot:*/postinst-useradd-*:${COREBASE} \ @@ -99,7 +99,7 @@ SSTATECREATEFUNCS[vardeps] = "SSTATE_SCAN_FILES" SSTATEPOSTCREATEFUNCS = "" SSTATEPREINSTFUNCS = "" SSTATEPOSTUNPACKFUNCS = "sstate_hardcode_path_unpack" -EXTRA_STAGING_FIXMES ?= "HOSTTOOLS_DIR" +EXTRA_STAGING_FIXMES ?= "RECIPE_HOSTTOOLS_DIR HOSTTOOLS_DIR" # Check whether sstate exists for tasks that support sstate and are in the # locked signatures file. diff --git a/meta/classes-global/staging.bbclass b/meta/classes-global/staging.bbclass index 20340a16e1a..2d3edbb05ef 100644 --- a/meta/classes-global/staging.bbclass +++ b/meta/classes-global/staging.bbclass @@ -180,7 +180,7 @@ def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d): if not fixme: return cmd = "sed -e 's:^[^/]*/:%s/:g' %s | xargs sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIRHOST:%s:g'" % (target, " ".join(fixme), recipesysroot, recipesysrootnative) - for fixmevar in ['PSEUDO_SYSROOT', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']: + for fixmevar in ['PSEUDO_SYSROOT', 'RECIPE_HOSTTOOLS_DIR', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']: fixme_path = d.getVar(fixmevar) cmd += " -e 's:FIXME_%s:%s:g'" % (fixmevar, fixme_path) bb.debug(2, cmd) diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index 0c1a55a4c98..35eadef1f6d 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass @@ -95,6 +95,8 @@ DEFAULT_TEST_SUITES:remove:qemumips64 = "${MIPSREMOVE}" TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" +RECIPE_HOSTTOOLS += "ip ping ps scp ssh stty" + QEMU_USE_KVM ?= "1" TEST_QEMUBOOT_TIMEOUT ?= "1000" TEST_OVERALL_TIMEOUT ?= "" diff --git a/meta/classes-recipe/testsdk.bbclass b/meta/classes-recipe/testsdk.bbclass index b1c4fa67e65..3cecdf63dab 100644 --- a/meta/classes-recipe/testsdk.bbclass +++ b/meta/classes-recipe/testsdk.bbclass @@ -21,6 +21,8 @@ TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK" TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt" TESTSDK_CASE_DIRS ?= "sdk" +RECIPE_HOSTTOOLS += "ip ping ps scp ssh stty" + def import_and_run(name, d): import importlib diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index d353a7cd2c3..99e76b704dc 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -524,6 +524,7 @@ export PATH # Directory with symlinks to host tools used by build HOSTTOOLS_DIR = "${TMPDIR}/hosttools" +RECIPE_HOSTTOOLS_DIR = "${WORKDIR}/recipe-hosttools" # Tools needed to run builds with OE-Core HOSTTOOLS += " \ @@ -538,9 +539,6 @@ HOSTTOOLS += " \ uniq unzstd wc wget which xargs zstd xz \ " -# Tools needed to run testimage runtime image testing -HOSTTOOLS += "${@'ip ping ps scp ssh stty' if (bb.utils.contains_any('IMAGE_CLASSES', 'testimage testsdk', True, False, d) or any(x in (d.getVar("BBINCLUDED") or "") for x in ["testimage.bbclass", "testsdk.bbclass"])) else ''}" - # Link to these if present HOSTTOOLS_NONFATAL += "aws gcc-ar gpg gpg-agent ld.bfd ld.gold nc pigz sftp socat ssh sudo" diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf index 67fef791545..04bceadddee 100644 --- a/meta/conf/layer.conf +++ b/meta/conf/layer.conf @@ -138,7 +138,7 @@ DUMMY_PACKAGE_ARCHS_TARGET += "sdk-provides-dummy-target" # We need to keep bitbake tools in PATH # Avoid empty path entries BITBAKEPATH := "${@os.path.dirname(bb.utils.which(d.getVar('PATH'),'bitbake'))}" -PATH := "${@'${BITBAKEPATH}:' if '${BITBAKEPATH}' != '' else ''}${HOSTTOOLS_DIR}" +PATH := "${@'${BITBAKEPATH}:' if '${BITBAKEPATH}' != '' else ''}${RECIPE_HOSTTOOLS_DIR}:${HOSTTOOLS_DIR}" # Only OE-Core should set/change this BB_GLOBAL_PYMODULES = "os sys time"