]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
image_types: allow the creation of block devices on top of UBI volumes
authorThomas Perrot <thomas.perrot@bootlin.com>
Mon, 18 Oct 2021 23:21:23 +0000 (01:21 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 23 Oct 2021 16:41:46 +0000 (17:41 +0100)
Currently, the function multiubi_mkfs doesn't allow using anything else than
UBIFS over UBI.

Here, we propose to introduce two variables that allow to customize the ubinize
configuration and the image dependency, in order to be able to build UBI
images using the ubiblock abstraction layer and block filesystems.

For example, with this change it is possible to build a UBI volume using a
compressed squashfs, with the following configuration:
UBI_VOLTYPE ?= "static"
UBI_IMGTYPE ?= "squasfs-lz4"

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image_types.bbclass

index 32d4cd4c768ca1b3943007e0c645c78b4b5c6694..f643ed3ce7f1f1b82206aab6da2821a400d76ddb 100644 (file)
@@ -139,16 +139,18 @@ IMAGE_CMD:cpio () {
 }
 
 UBI_VOLNAME ?= "${MACHINE}-rootfs"
+UBI_VOLTYPE ?= "dynamic"
+UBI_IMGTYPE ?= "ubifs"
 
 multiubi_mkfs() {
        local mkubifs_args="$1"
        local ubinize_args="$2"
-    
+
         # Added prompt error message for ubi and ubifs image creation.
         if [ -z "$mkubifs_args" ] || [ -z "$ubinize_args" ]; then
             bbfatal "MKUBIFS_ARGS and UBINIZE_ARGS have to be set, see http://www.linux-mtd.infradead.org/faq/ubifs.html for details"
         fi
-    
+
        if [ -z "$3" ]; then
                local vname=""
        else
@@ -157,9 +159,9 @@ multiubi_mkfs() {
 
        echo \[ubifs\] > ubinize${vname}-${IMAGE_NAME}.cfg
        echo mode=ubi >> ubinize${vname}-${IMAGE_NAME}.cfg
-       echo image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs >> ubinize${vname}-${IMAGE_NAME}.cfg
+       echo image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.${UBI_IMGTYPE} >> ubinize${vname}-${IMAGE_NAME}.cfg
        echo vol_id=0 >> ubinize${vname}-${IMAGE_NAME}.cfg
-       echo vol_type=dynamic >> ubinize${vname}-${IMAGE_NAME}.cfg
+       echo vol_type=${UBI_VOLTYPE} >> ubinize${vname}-${IMAGE_NAME}.cfg
        echo vol_name=${UBI_VOLNAME} >> ubinize${vname}-${IMAGE_NAME}.cfg
        echo vol_flags=autoresize >> ubinize${vname}-${IMAGE_NAME}.cfg
        if [ -n "$vname" ]; then
@@ -198,7 +200,7 @@ IMAGE_CMD:multiubi () {
 IMAGE_CMD:ubi () {
        multiubi_mkfs "${MKUBIFS_ARGS}" "${UBINIZE_ARGS}"
 }
-IMAGE_TYPEDEP:ubi = "ubifs"
+IMAGE_TYPEDEP:ubi = "${UBI_IMGTYPE}"
 
 IMAGE_CMD:ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs ${MKUBIFS_ARGS}"
 
@@ -329,7 +331,7 @@ CONVERSION_DEPENDS_gzsync = "zsync-curl-native"
 RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4"
 RUNNABLE_MACHINE_PATTERNS ?= "qemu"
 
-DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso" 
+DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso"
 
 # The IMAGE_TYPES_MASKED variable will be used to mask out from the IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk, vhd, vhdx, vdi, qcow2, hddimg, iso, etc.