Add the addition of a bootconfig block at the end of an image as a
conversion type; while a bootconfig is mostly used in conjuntion with an
initramfs (i.e.: a cpio image or one of its compressed forms), having it
as a generic conversion type simplifies the implemntation and is ready
for future modifications at kernel side.

The following configurations variables are introduced (in a separate
bbclass, for further usage by other components):

  - BOOTCONFIG_SOURCES: list of source files to be used as bootconfig,
    to be found inside DEPLOY_DIR_IMAGE;
  - BOOTCONFIG_TASKS: list of tasks deploying the bootconfig source
    files specified in BOOTCONFIG_SOURCES to DEPLOY_DIR_IMAGE; an image
    using the bootconfig modifier will depend on them.

Signed-off-by: Francesco Valla <[email protected]>
---
 meta/classes-recipe/bootconfig-config.bbclass | 12 ++++++++++++
 meta/classes-recipe/image_types.bbclass       | 28 +++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/meta/classes-recipe/bootconfig-config.bbclass 
b/meta/classes-recipe/bootconfig-config.bbclass
new file mode 100644
index 
0000000000000000000000000000000000000000..79e6a915eefb28164cc414f65875b4386764ce5a
--- /dev/null
+++ b/meta/classes-recipe/bootconfig-config.bbclass
@@ -0,0 +1,12 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+# Name of the file(s) to be used as bootconfig source, to be found inside 
DEPLOY_DIR_IMAGE
+BOOTCONFIG_SOURCES ?= ""
+
+# Task deploying the bootconfig source to DEPLOY_DIR_IMAGE
+#  e.g.: BOOTCONFIG_TASKS = "bootconfig-debug:do_deploy"
+BOOTCONFIG_TASKS ?= ""
diff --git a/meta/classes-recipe/image_types.bbclass 
b/meta/classes-recipe/image_types.bbclass
index 
e6ef0ce11e40c0f8388fb5547ab03943004bde2f..7d0120e6cd56c9a08fb3c2ac8ea6edb56602aa53
 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -264,9 +264,31 @@ IMAGE_CMD:f2fs () {
        sload.f2fs -f ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}.f2fs
 }
 
+oe_bootconfig() {
+       local src_image=$1
+
+       if [ -z "${BOOTCONFIG_SOURCES}" ]; then
+               bbfatal "bootconfig image type requested but BOOTCONFIG_SOURCES 
is not set"
+       fi
+
+       cp ${src_image} ${src_image}.bootconfig
+
+       # Add bootconfig(s) to file
+       rm -f bootconfig.txt
+       for src in ${BOOTCONFIG_SOURCES}; do
+               cat ${DEPLOY_DIR_IMAGE}/${src} >> bootconfig.txt
+       done
+
+       bootconfig -a bootconfig.txt ${src_image}.bootconfig
+       rm bootconfig.txt
+
+       # Re-read bootconfig
+       bootconfig -l ${src_image}.bootconfig
+}
+
 EXTRA_IMAGECMD = ""
 
-inherit siteinfo kernel-arch image-artifact-names
+inherit siteinfo kernel-arch image-artifact-names bootconfig-config
 
 JFFS2_ENDIANNESS ?= "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 
'-l', '-b', d)}"
 JFFS2_ERASEBLOCK ?= "0x40000"
@@ -333,7 +355,7 @@ IMAGE_TYPES:append:x86-64 = " hddimg iso"
 # CONVERSION_CMD/DEPENDS.
 COMPRESSIONTYPES ?= ""
 
-CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip 7zip zst sum md5sum sha1sum 
sha224sum sha256sum sha384sum sha512sum bmap u-boot vmdk vhd vhdx vdi qcow2 
base64 gzsync zsync ${COMPRESSIONTYPES}"
+CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip 7zip zst sum md5sum sha1sum 
sha224sum sha256sum sha384sum sha512sum bmap u-boot vmdk vhd vhdx vdi qcow2 
base64 gzsync zsync bootconfig ${COMPRESSIONTYPES}"
 CONVERSION_CMD:lzma = "lzma -k -f -7 ${IMAGE_NAME}.${type}"
 CONVERSION_CMD:gz = "gzip -f -9 -n -c --rsyncable ${IMAGE_NAME}.${type} > 
${IMAGE_NAME}.${type}.gz"
 CONVERSION_CMD:bz2 = "pbzip2 -f -k ${IMAGE_NAME}.${type}"
@@ -360,6 +382,7 @@ CONVERSION_CMD:qcow2 = "qemu-img convert -O qcow2 
${IMAGE_NAME}.${type} ${IMAGE_
 CONVERSION_CMD:base64 = "base64 ${IMAGE_NAME}.${type} > 
${IMAGE_NAME}.${type}.base64"
 CONVERSION_CMD:zsync = "zsyncmake_curl ${IMAGE_NAME}.${type}"
 CONVERSION_CMD:gzsync = "zsyncmake_curl -z ${IMAGE_NAME}.${type}"
+CONVERSION_CMD:bootconfig = "oe_bootconfig ${IMAGE_NAME}.${type}"
 CONVERSION_DEPENDS_lzma = "xz-native"
 CONVERSION_DEPENDS_gz = "pigz-native"
 CONVERSION_DEPENDS_bz2 = "pbzip2-native"
@@ -380,6 +403,7 @@ CONVERSION_DEPENDS_vhdx = "qemu-system-native"
 CONVERSION_DEPENDS_vhd = "qemu-system-native"
 CONVERSION_DEPENDS_zsync = "zsync-curl-native"
 CONVERSION_DEPENDS_gzsync = "zsync-curl-native"
+CONVERSION_DEPENDS_bootconfig = "linux-bootconfig-native ${BOOTCONFIG_TASKS}"
 
 RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4"
 RUNNABLE_MACHINE_PATTERNS ?= "qemu"

-- 
2.53.0

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

Reply via email to