[yocto] How to add task only if flag set

Timothy Froehlich tfroehlich at archsys.io
Thu Mar 21 17:21:50 PDT 2019


I'm working with a read only file system and I'm working on splitting
packages so that their config dirs are symlinked in from the persistent
data partition. But I'd like to be able to enable or disable this
optionally, so that I can still build an image with a r/w file system and a
single partition for easier development. I've got a class file with a new
task that moves config files to /data and symlinks them back, but I can't
figure out how to conditionally enable it. Ideally it'd be enabled only if
read-only-rootfs is set in IMAGE_FEATURES.

Here's the class if it helps:

ORIGINAL_FILES ??= "file1 file2..."
SYMLINK_NAMES ??= "sym1 sym2..."

do_symlink_to_data () {
    install -d ${D}/${PERSIST_DIR}

    ORIG_ARR=(${ORIGINAL_FILES})
    SYMLINK_ARR=(${SYMLINK_NAMES})

    for i in ${!ORIG_ARR[*]}; do
        ORIG=ORIG_ARR[i]
        SYMLINK=SYMLINK_ARR[i]


        mv ${D}/$ORIG ${D}/${PERSIST_DIR}/$SYMLINK
        ln -sr ${D}/${PERSIST_DIR}/$SYMLINK ${D}/$ORIG
    done
}

FILES_${PN}_append_mender-image += " ${SYMLINK_NAMES}"

addtask symlink_to_data after do_install




-- 
Tim Froehlich
Embedded Linux Engineer
tfroehlich at archsys.io
215-218-8955
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20190321/dc78f045/attachment.html>


More information about the yocto mailing list