Search code examples
yoctocore-imageyocto-recipeyocto-wic

How to copy whole directories containing subdirectories to /boot (i.e bootfs) in Yocto while inheriting core-image class?


I have a directory which again contains subdirectories, which are built has part of other recipe and moved to DEPLOY_DIR_IMAGE using deploy bb class. So now I want to copy it to main image boot partition.

If it was a single file then appending required filename to IMAGE_EFI_BOOT_FILES variable, then yocto copies it to /boot. But same doesn't work for directories containing subdirectories please provide style to include even the subdirectories. Thank you

PS: I have tried appending IMAGE_EFI_BOOT_FILES += "parent_dir/*" didnt work.


Solution

  • Note: I am looking for Yocto built-in which can achieve solution for above mentioned , would like to share other way to resolve the functionality for community's benefit.

    Add following in bb file if you are using one or refer to talel-belhadjsalem answer to use utils.bbclass.

    def add_directory_bootfs(d, dirname, bootfs_dir):
        file_list = list()
        boot_files_list = list()
        deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE')
        for (dirpath, dirnames, filenames) in os.walk(os.path.join(deploy_dir_image, dirname)):
            file_list += [os.path.join(dirpath, file) for file in filenames]
        for file in file_list:
            file_rel_path = os.path.relpath(file, os.path.join(deploy_dir_image, dirname))
            boot_file_entry = os.path.join(dirname, file_rel_path) + ';' + os.path.join(bootfs_dir, dirname, file_rel_path)
            boot_files_list.append(boot_file_entry)
        return ' '.join(boot_files_list)
    
    IMAGE_EFI_BOOT_FILES += "${@add_directory_bootfs(d, 'relative_path_to_dir_in_deploy_dir_image', 'EFI/BOOT')}"