image-bootfiles class copy files listed in IMAGE_BOOT_FILES to the IMAGE_BOOT_FILES_DIR directory of the root filesystem.
This is useful when there is no explicit boot partition but all boot files should instead reside inside the root filesystem. Signed-off-by: Marcus Folkesson <[email protected]> --- Notes: v3: - Skip the intermediate bootfiles() function - Rename variable names to be consistent - Various python optimizations meta/classes/image-bootfiles.bbclass | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 meta/classes/image-bootfiles.bbclass diff --git a/meta/classes/image-bootfiles.bbclass b/meta/classes/image-bootfiles.bbclass new file mode 100644 index 0000000000..79c58f414a --- /dev/null +++ b/meta/classes/image-bootfiles.bbclass @@ -0,0 +1,38 @@ +# +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2024 Marcus Folkesson +# Author: Marcus Folkesson <[email protected]> +# +# Writes IMAGE_BOOT_FILES to the IMAGE_BOOT_FILES_DIR directory +# +# +# Usage: add inherit += "image-bootfiles" to your image +# + +IMAGE_BOOT_FILES_DIR ?= "boot" + +python bootfiles_populate() { + import shutil + from oe.bootfiles import get_boot_files + + deploy_image_dir = d.getVar("DEPLOY_DIR_IMAGE") + boot_dir = os.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("IMAGE_BOOT_FILES_DIR")) + + boot_files = d.getVar("IMAGE_BOOT_FILES") + if boot_files is None: + return + + install_files = get_boot_files(deploy_image_dir, boot_files) + if install_files is None: + bb.warn("Could not find any boot files to install even though IMAGE_BOOT_FILES is not empty") + return + + os.makedirs(boot_dir, exist_ok=True) + for src, dst in install_files: + image_src = os.path.join(deploy_image_dir, src) + image_dst = os.path.join(boot_dir, dst) + shutil.copyfile(image_src, image_dst) +} + +IMAGE_PREPROCESS_COMMAND += "bootfiles_populate;" -- 2.45.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#199960): https://lists.openembedded.org/g/openembedded-core/message/199960 Mute This Topic: https://lists.openembedded.org/mt/106345350/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
