From patchwork Mon Jul 27 08:34:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Robin X-Patchwork-Id: 93572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25CF0C5321C for ; Mon, 27 Jul 2026 08:34:55 +0000 (UTC) Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.26960.1785141291634822164 for ; Mon, 27 Jul 2026 01:34:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=uxmtR+A5; spf=pass (domain: bootlin.com, ip: 185.246.84.56, mailfrom: benjamin.robin@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 02F381A1283 for ; Mon, 27 Jul 2026 08:34:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CBE73601BE; Mon, 27 Jul 2026 08:34:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B8F9811C12291; Mon, 27 Jul 2026 10:34:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785141285; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=HK7u+3x1oJ1O2SaNcLkpaf/VYKpwjkI+NByxxoF0DXs=; b=uxmtR+A5t+LS4HUT3gP64feuBybZJz5yXiPkjFDqjJ2UW1jzxVwtsiV3U/EWy3jYBGTshe U74GDVqRUpltHD51zc1fRA97JcMeDjviGBnug2PF9lTBIHsLeR4K1h91bvpKP41G92Zi89 d1W7KdEp0PADJ+QqmIoC9hxFgbkxbVEy79iXyltYomB0BF59tNHe59Lho4l/A0bZZWBqvY xoPurVEmWVyuPkTm3OpB5Wsv4aXbAA1l2N10QgXU5JX48fUHmoTnawRm5ri/9ryHiLbteA lDpOi/SsqIDV4IKc4R1ZSUg7jQ1n/100ensQ/TXFZ41/eq75Zk2bZFdKbpt8HQ== From: Benjamin Robin Date: Mon, 27 Jul 2026 10:34:28 +0200 Subject: [PATCH RFC 1/3] spdx_common: simplify get_patched_src() implementation MIME-Version: 1.0 Message-Id: <20260727-fix-get-patched-src-v1-1-f5054ca10e14@bootlin.com> References: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> In-Reply-To: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> To: openembedded-core@lists.openembedded.org Cc: jpewhacker@gmail.com, antonin.godard@bootlin.com, mathieu.dubois-briand@bootlin.com, thomas.petazzoni@bootlin.com, daniel.turull@ericsson.com, Benjamin Robin X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 27 Jul 2026 08:34:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/242064 The behavior remains unchanged: - Instead of saving and restoring the values of various variables, use a copy of the data store via `d.createCopy()`. This prevents side effects for other tasks. - This allows removing the `try ... finally` block. - The function `is_work_shared_spdx()` no longer needs to be called twice. - In the work-shared case, there is no need to modify `WORKDIR` since no task is executed from that branch. Signed-off-by: Benjamin Robin --- meta/lib/oe/spdx_common.py | 81 ++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py index 6b1a409c40c2..9d1e22629b21 100644 --- a/meta/lib/oe/spdx_common.py +++ b/meta/lib/oe/spdx_common.py @@ -172,50 +172,47 @@ def get_patched_src(d): Save patched source of the recipe in SPDX_WORKDIR. """ spdx_workdir = d.getVar("SPDXWORK") - spdx_sysroot_native = d.getVar("STAGING_DIR_NATIVE") - workdir = d.getVar("WORKDIR") + # The kernel class functions require it to be on work-shared, so we don't change WORKDIR + if not is_work_shared_spdx(d): + spdx_sysroot_native = d.getVar("STAGING_DIR_NATIVE") + localdata = d.createCopy() - try: - # The kernel class functions require it to be on work-shared, so we dont change WORKDIR - if not is_work_shared_spdx(d): - # Change the WORKDIR to make do_unpack do_patch run in another dir. - d.setVar("WORKDIR", spdx_workdir) - # Restore the original path to recipe's native sysroot (it's relative to WORKDIR). - d.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) - - # The changed 'WORKDIR' also caused 'B' changed, create dir 'B' for the - # possibly requiring of the following tasks (such as some recipes's - # do_patch required 'B' existed). - bb.utils.mkdirhier(d.getVar("B")) - - bb.build.exec_func("do_unpack", d) - - if d.getVar("SRC_URI") != "": - if bb.data.inherits_class("dos2unix", d): - bb.build.exec_func("do_convert_crlf_to_lf", d) - bb.build.exec_func("do_patch", d) - - # Copy source from work-share to spdx_workdir - if is_work_shared_spdx(d): - share_src = d.getVar("S") - d.setVar("WORKDIR", spdx_workdir) - d.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) - # Copy source to ${SPDXWORK}, same basename dir of ${S}; - src_dir = spdx_workdir + "/" + os.path.basename(share_src) - # For kernel souce, rename suffix dir 'kernel-source' - # to ${BP} (${BPN}-${PV}) - if bb.data.inherits_class("kernel", d): - src_dir = spdx_workdir + "/" + d.getVar("BP") - - bb.note(f"copyhardlinktree {share_src} to {src_dir}") - oe.path.copyhardlinktree(share_src, src_dir) - - # Some userland has no source. - if not os.path.exists(spdx_workdir): - bb.utils.mkdirhier(spdx_workdir) - finally: - d.setVar("WORKDIR", workdir) + # Change the WORKDIR to make do_unpack do_patch run in another dir. + localdata.setVar("WORKDIR", spdx_workdir) + # Restore the original path to recipe's native sysroot (it's relative to WORKDIR). + localdata.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) + + # The changed 'WORKDIR' also caused 'B' changed, create dir 'B' for the + # possibly requiring of the following tasks (such as some recipe's + # do_patch required 'B' existed). + bb.utils.mkdirhier(localdata.getVar("B")) + + bb.build.exec_func("do_unpack", localdata) + + if localdata.getVar("SRC_URI") != "": + if bb.data.inherits_class("dos2unix", localdata): + bb.build.exec_func("do_convert_crlf_to_lf", localdata) + bb.build.exec_func("do_patch", localdata) + + # Copy source from work-shared to spdx_workdir + else: + share_src = d.getVar("S") + + if bb.data.inherits_class("kernel", d): + # For kernel source, rename suffix dir 'kernel-source' to ${BP} (${BPN}-${PV}) + dir_name = d.getVar("BP") + else: + # Copy source to ${SPDXWORK}, same basename dir of ${S} + dir_name = os.path.basename(share_src) + + src_dir = f"{spdx_workdir}/{dir_name}" + bb.note(f"copyhardlinktree {share_src} to {src_dir}") + oe.path.copyhardlinktree(share_src, src_dir) + + # Some userland has no source. + if not os.path.exists(spdx_workdir): + bb.utils.mkdirhier(spdx_workdir) def has_task(d, task): From patchwork Mon Jul 27 08:34:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Robin X-Patchwork-Id: 93571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11A00C53219 for ; Mon, 27 Jul 2026 08:34:55 +0000 (UTC) Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.26609.1785141293345590302 for ; Mon, 27 Jul 2026 01:34:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=aIPcVs/L; spf=pass (domain: bootlin.com, ip: 185.246.84.56, mailfrom: benjamin.robin@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 741B21A1284; Mon, 27 Jul 2026 08:34:51 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 49858601BE; Mon, 27 Jul 2026 08:34:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7C09511C1228F; Mon, 27 Jul 2026 10:34:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785141290; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=jyeNRReNFsNLkNVHSUFhnIlW7EcP92Zk9cs7H8tPbZI=; b=aIPcVs/LFLq4ZdnDQa3V6SiuO+s4l180MIOtrYPT/vzdJNE3HaRUSgHE7H5bU4C2B7KHBw ph4mN0sNhNQ8AuTsLAa0fv+fhRdTppUpsE+btTxlNg+X6DqHlsvWuVqaYxf4kP3v8XBi4F Ax752dhTzGWjEjs/lYeywPNgGLO79uM8PVY9+om0Bq6VFjPNhFkotyMzBy6ksAoikxgn6Z IkUVFjFAkC3/KrThPuc5+z2TJB+VA5djf51SgyAjJWJiAimbVkf+fnIuUEa4CuLRngzVfl kOCYdqdlWt9IRQsMdDZ9xJooxqZMwwDtJcM4VTeXkj/X9ZM/VUw7nsQNHTIGWA== From: Benjamin Robin Date: Mon, 27 Jul 2026 10:34:29 +0200 Subject: [PATCH RFC 2/3] spdx_common: modify UNPACKDIR instead of WORKDIR in get_patched_src() MIME-Version: 1.0 Message-Id: <20260727-fix-get-patched-src-v1-2-f5054ca10e14@bootlin.com> References: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> In-Reply-To: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> To: openembedded-core@lists.openembedded.org Cc: jpewhacker@gmail.com, antonin.godard@bootlin.com, mathieu.dubois-briand@bootlin.com, thomas.petazzoni@bootlin.com, daniel.turull@ericsson.com, Benjamin Robin X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 27 Jul 2026 08:34:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/242065 This change will affect the SPDX output: the source file path will no longer be prefixed by `sources/`. The rest of the changes are safe because: - `S` should reference `UNPACKDIR` and not directly reference `WORKDIR`. - After analyzing all public layers, no `do_unpack()` or `do_patch()` was found to reference the `${B}` variable. The comment mentioning the `${B}` variable traces back to [1] (though no further explanation was provided). Additionally, this ensures proper capture of sources if the recipe modifies `UNPACKDIR` outside of `WORKDIR` (though such cases should be rare). With these changes, SPDXWORK is no longer a working directory which is "temporary" replacing WORKDIR, it is now a "temporary" directory containing unpacked source files. The run.do_patch.XXXX and associated files are now stored in ${WORKDIR}/temp. [1] https://github.com/doubleopen-io/meta-doubleopen/blob/ e84f0c32663da9c743e4f1802042b733df0e36d7/classes/doubleopen.bbclass#L285 Signed-off-by: Benjamin Robin --- meta/lib/oe/spdx30_tasks.py | 1 - meta/lib/oe/spdx_common.py | 18 +++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py index ef12e638ae85..4da9e8bb7e24 100644 --- a/meta/lib/oe/spdx30_tasks.py +++ b/meta/lib/oe/spdx30_tasks.py @@ -843,7 +843,6 @@ def create_spdx(d): lambda filepath: [oe.spdx30.software_SoftwarePurpose.source], license_data, ignore_dirs=[".git"], - ignore_top_level_dirs=["temp"], archive=None, ) build_inputs |= files diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py index 9d1e22629b21..013f23ae7c65 100644 --- a/meta/lib/oe/spdx_common.py +++ b/meta/lib/oe/spdx_common.py @@ -169,28 +169,20 @@ def collect_package_providers(d, direct_deps): def get_patched_src(d): """ - Save patched source of the recipe in SPDX_WORKDIR. + Save patched source of the recipe in SPDXWORK. """ spdx_workdir = d.getVar("SPDXWORK") - # The kernel class functions require it to be on work-shared, so we don't change WORKDIR + # Do not unpack the sources again for the recipe using work-shared if not is_work_shared_spdx(d): - spdx_sysroot_native = d.getVar("STAGING_DIR_NATIVE") localdata = d.createCopy() - # Change the WORKDIR to make do_unpack do_patch run in another dir. - localdata.setVar("WORKDIR", spdx_workdir) - # Restore the original path to recipe's native sysroot (it's relative to WORKDIR). - localdata.setVar("STAGING_DIR_NATIVE", spdx_sysroot_native) - - # The changed 'WORKDIR' also caused 'B' changed, create dir 'B' for the - # possibly requiring of the following tasks (such as some recipe's - # do_patch required 'B' existed). - bb.utils.mkdirhier(localdata.getVar("B")) + # Change the UNPACKDIR to make do_unpack do_patch run in another dir. + localdata.setVar("UNPACKDIR", spdx_workdir) bb.build.exec_func("do_unpack", localdata) - if localdata.getVar("SRC_URI") != "": + if localdata.getVar("SRC_URI"): if bb.data.inherits_class("dos2unix", localdata): bb.build.exec_func("do_convert_crlf_to_lf", localdata) bb.build.exec_func("do_patch", localdata) From patchwork Mon Jul 27 08:34:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Robin X-Patchwork-Id: 93570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1F85C531D0 for ; Mon, 27 Jul 2026 08:34:54 +0000 (UTC) Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.26610.1785141294066655478 for ; Mon, 27 Jul 2026 01:34:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=PI5pV8jD; spf=pass (domain: bootlin.com, ip: 185.246.85.4, mailfrom: benjamin.robin@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5CFB34E40F93; Mon, 27 Jul 2026 08:34:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 32159601BE; Mon, 27 Jul 2026 08:34:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E476811C12296; Mon, 27 Jul 2026 10:34:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785141291; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UwOonLbUz9x75wk9WT35OzCYJP4x+wUYc8xubS8LWxY=; b=PI5pV8jDB/FmcLJRlsXCJbvzijH0XBg/H2YOJBUxyaTwZbfgF6jV0wNoOMK8SvPpteSkp2 vR8H9DHqs2MaH9AnJ6X4fpp9+Wmx9aIxZ1b0aqN8vDaLDqyygqY+8r1qBdLJm/gl/MnSgO FMzl84Erw9SDWvnzBn0GXPWBJT+r4vm/Pc6hHoyNH+A+aRb6ivI/df3LOTcLZfXQ9QyZ/O Tn6R2TJXYWcueQuUtOsSLKz4oOZp5n90trny8XgulJ1Xls7ZZFgjCA2WH8GEk6OwjilKYp yuAfs05Ak6x0aAlsjE+Ie4TpT7QFQ0R6EVsnPYnA1Ifenylh+qtJUEN9yl0tYw== From: Benjamin Robin Date: Mon, 27 Jul 2026 10:34:30 +0200 Subject: [PATCH RFC 3/3] spdx_common: In get_patched_src() ensure kernel dir name to be ${BP} MIME-Version: 1.0 Message-Id: <20260727-fix-get-patched-src-v1-3-f5054ca10e14@bootlin.com> References: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> In-Reply-To: <20260727-fix-get-patched-src-v1-0-f5054ca10e14@bootlin.com> To: openembedded-core@lists.openembedded.org Cc: jpewhacker@gmail.com, antonin.godard@bootlin.com, mathieu.dubois-briand@bootlin.com, thomas.petazzoni@bootlin.com, daniel.turull@ericsson.com, Benjamin Robin X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 27 Jul 2026 08:34:54 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/242066 If a kernel recipe is using a tar file instead of git repository, it is necessary to override `S` to point to the unpacked tar archive. In this case `${S}` is not going to be in work-shared. So we must handle this case in get_patched_src() to ensure that the kernel is extracted in the following path: `${SPDXWORK}/${BP}`. For a full detailed analysis see [1], but in summary this change is necessary because: - In `save_debugsources_info()` the sources are extracted from the debug symbol. For the kernel Linux the source file path is modified to look like `${BP}/init/main.c` (`${KERNEL_SRC_PATH}` is replaced by `${BP}`). - In `get_patched_src()` the sources of the recipe are extracted (again) in a sub-directory of `${SPDXWORK}`. If `${S}` is in work-shared and if the recipe inherits the kernel class, then the sources are extracted in `${SPDXWORK}/${BP}`. - In `add_package_files()`, with topdir equal to `${SPDXWORK}`, all the files (recursively) found in topdir are listed. For each source file, if the file path (relative to topdir) is in the list of source files retrieved by save_debugsources_info, then the file is added to the SPDX SBoM. - If we are using a tar archive, `${S}` is set for example to `${UNPACKDIR}/linux-${PV}`, so in `get_patched_src()` the sources are extracted in `${SPDXWORK}/sources/linux-${PV}` since `UNPACKDIR = ${WORKDIR}/sources`. `${BP}/init/main.c` is not in `${SPDXWORK}`, but `sources/linux-${PV}/init/main.c` is. [1] https://github.com/bootlin/yocto-kiss/pull/26#discussion_r3626224833 Signed-off-by: Benjamin Robin --- meta/lib/oe/spdx_common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/meta/lib/oe/spdx_common.py b/meta/lib/oe/spdx_common.py index 013f23ae7c65..e40cf36bba18 100644 --- a/meta/lib/oe/spdx_common.py +++ b/meta/lib/oe/spdx_common.py @@ -187,6 +187,14 @@ def get_patched_src(d): bb.build.exec_func("do_convert_crlf_to_lf", localdata) bb.build.exec_func("do_patch", localdata) + if bb.data.inherits_class("kernel", localdata): + # For kernel source, rename suffix dir to ${BP} (${BPN}-${PV}) + dir_name = localdata.getVar("BP") + kernel_dst_path = f"{spdx_workdir}/{dir_name}" + kernel_src_path = localdata.getVar("S") + if not os.path.exists(kernel_dst_path): + shutil.move(kernel_src_path, kernel_dst_path) + # Copy source from work-shared to spdx_workdir else: share_src = d.getVar("S")