[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}


    for i in ${!ORIG_ARR[*]}; do

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

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

addtask symlink_to_data after do_install

Tim Froehlich
Embedded Linux Engineer
tfroehlich at archsys.io
-------------- 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