From: Kory Maincent <kory.mainc...@bootlin.com>

Isolate the writing of the UBI configuration in a separate function.
This allows to use a custom configuration easily by overriding the
function.

Replace the echo functions by a cat to have a more readable configuration.

Signed-off-by: Kory Maincent <kory.mainc...@bootlin.com>
---
 meta/classes/image_types.bbclass | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index 89a9c92db7..0ffea91195 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -142,6 +142,24 @@ UBI_VOLNAME ?= "${MACHINE}-rootfs"
 UBI_VOLTYPE ?= "dynamic"
 UBI_IMGTYPE ?= "ubifs"
 
+write_ubi_config() {
+       if [ -z "$1" ]; then
+               local vname=""
+       else
+               local vname="_$1"
+       fi
+
+       cat <<EOF > ubinize${vname}-${IMAGE_NAME}.cfg
+[ubifs]
+mode=ubi
+image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.${UBI_IMGTYPE}
+vol_id=0
+vol_type=${UBI_VOLTYPE}
+vol_name=${UBI_VOLNAME}
+vol_flags=autoresize
+EOF
+}
+
 multiubi_mkfs() {
        local mkubifs_args="$1"
        local ubinize_args="$2"
@@ -151,19 +169,8 @@ multiubi_mkfs() {
             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
-               local vname="_$3"
-       fi
+       write_ubi_config "$3"
 
-       echo \[ubifs\] > ubinize${vname}-${IMAGE_NAME}.cfg
-       echo mode=ubi >> 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=${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
                mkfs.ubifs -r ${IMAGE_ROOTFS} -o 
${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs ${mkubifs_args}
        fi
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#165921): 
https://lists.openembedded.org/g/openembedded-core/message/165921
Mute This Topic: https://lists.openembedded.org/mt/91226832/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to