On Mon, Jul 27, 2026 at 2:34 AM Benjamin Robin <[email protected]>
wrote:

> 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 <[email protected]>
>

LGTM Thanks

Reviewed-by: Joshua Watt <[email protected]>


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

Reply via email to