On Fri, 2023-05-12 at 12:22 -0500, Randolph Sapp via
lists.openembedded.org wrote:
> From: Randolph Sapp <[email protected]>
> 
> Upstream's dtb directory structure has no real standard. They just tend
> to idle around the 2/3 directory depth. Recursively search for the
> dtb/dtbo files instead of assuming anything.
> 
> Fixes: 04ab57d200 (kernel-devicetree: allow specification of dtb
> directory, 2023-05-02)
> 
> Signed-off-by: Randolph Sapp <[email protected]>
> ---
>  meta/classes-recipe/kernel-devicetree.bbclass | 21 +++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/classes-recipe/kernel-devicetree.bbclass 
> b/meta/classes-recipe/kernel-devicetree.bbclass
> index 831fdd1527..fa6de7a140 100644
> --- a/meta/classes-recipe/kernel-devicetree.bbclass
> +++ b/meta/classes-recipe/kernel-devicetree.bbclass
> @@ -12,12 +12,21 @@ python () {
>              d.appendVar("PACKAGES", " 
> ${KERNEL_PACKAGE_NAME}-image-zimage-bundle")
>  }
>  
> -FILES:${KERNEL_PACKAGE_NAME}-devicetree = " \
> -    /${KERNEL_DTBDEST}/*.dtb \
> -    /${KERNEL_DTBDEST}/*.dtbo \
> -    /${KERNEL_DTBDEST}/*/*.dtb \
> -    /${KERNEL_DTBDEST}/*/*.dtbo \
> -"
> +# recursivly search for devicetree files
> +def find_device_trees(d):
> +    import glob
> +    import os
> +
> +    file_paths = []
> +    dest_dir = d.getVar('D')
> +    full_dtb_dir = dest_dir + '/' + d.getVar('KERNEL_DTBDEST')
> +
> +    for file in glob.glob(full_dtb_dir + '/**/*.dtb*', recursive=True):
> +        file_paths.append('/' + os.path.relpath(file, dest_dir))
> +
> +    return ' '.join(file_paths)
> +
> +FILES:${KERNEL_PACKAGE_NAME}-devicetree = "${@find_device_trees(d)}"
>  FILES:${KERNEL_PACKAGE_NAME}-image-zimage-bundle = 
> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"

I suspect this still suffers from a determinism problem as the previous
patch did but now it depends on whether the build had occurred or not.

I also really don't like resorting to python functions like this,
they're horrible for performance overhead. I did wonder if:

FILES:${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_DTBDEST}/**/*.dtb*"

would work?

Also, are there automated tests we should be adding to catch bugs like
this?

Cheers,

Richard

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

Reply via email to