Julien Stephan via lists.openembedded.org <jstephan=
[email protected]> escreveu (sexta, 5/07/2024 à(s) 12:31):

> According to the comment in do_symlink_kernsrc, this function exists
> for compatibility with old style kernel recipes:
>
>     # Old style kernels may set ${S} = ${WORKDIR}/git for example
>
> For such recipes  S will always be different from STAGING_KERNEL_DIR.
> This is fine for the first build or when unpack is rerun because new
> sources are in S. However the following command breaks the build:
>
>     bitbake -C do_symlink_kernsrc virtual/kernel
>
> At this point, S is a symlink to STAGING_KERNEL_DIR, (meaning S !=
> STAGING_KERNEL_DIR). We first remove the contents of STAGING_KERNEL_DIR
> without removing the folder itself causing us to lose kernel sources.
> Then we create a symlink from S to STAGING_KERNEL_DIR which results in the
> following broken symlinks:
>
>     ${WORKDIR}/git -> <...>/build/tmp/work-shared/<machine>/kernel-source
>     kernel-source -> <...>/build/tmp/work-shared/<machine>/kernel-source
>
> The build fails with the following error:
>
>     ERROR: <linux_recipe> do_kernel_checkout: FileExistsError(17, 'File
> exists')
>     ERROR: Task (<linux_recipe>:do_kernel_checkout)
>     failed with exit code '1'
>
> Attempting to access the kernel-source directory results in:
>
>     ls: cannot access 'kernel-source': Too many levels of symbolic links
>
> Fix this by checking if S is a symlink, and if so, verifying whether the
> symlink
> points to STAGING_KERNEL_DIR to avoid losing sources
>
> Signed-off-by: Julien Stephan <[email protected]>
> ---
>  meta/classes-recipe/kernel.bbclass | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/kernel.bbclass
> b/meta/classes-recipe/kernel.bbclass
> index 89badd90f18..e328151cb59 100644
> --- a/meta/classes-recipe/kernel.bbclass
> +++ b/meta/classes-recipe/kernel.bbclass
> @@ -184,7 +184,12 @@ do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR}
> ${B} ${STAGING_KERNEL_BUILDD
>  python do_symlink_kernsrc () {
>      s = d.getVar("S")
>      kernsrc = d.getVar("STAGING_KERNEL_DIR")
> -    if s != kernsrc:
> +    if os.path.islink(s):
> +        _s = os.readlink(s)
> +    else:
> +        _s = s
> +
> +    if _s != kernsrc:
>          bb.utils.mkdirhier(kernsrc)
>          bb.utils.remove(kernsrc, recurse=True)
>          if s[-1] == '/':
> --
> 2.45.1
>

What kernel bbclass are you using to build your kernel?
Please note that a very similar logic was replicated on
the kernel-yocto.bbclass do_kernel_checkout function
so it will be good to test with and without the kernel-yocto.bbclass.
https://git.yoctoproject.org/poky/tree/meta/classes-recipe/kernel-yocto.bbclass#n376

I recently came across this problem in a change that I ended up having to
revert.
https://github.com/Freescale/meta-freescale/pull/1843
https://github.com/Freescale/meta-freescale/pull/1857

Jose


>
>
> 
>
>

-- 
Best regards,

José Quaresma
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#201603): 
https://lists.openembedded.org/g/openembedded-core/message/201603
Mute This Topic: https://lists.openembedded.org/mt/107052142/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to