How do I write a yocto/bitbake recipe to copy a directory to the target root file system

Ben Turner picture Ben Turner · Nov 21, 2016 · Viewed 20.7k times · Source

I have a directory of 'binary' (i.e. not to be compiled) files and just want them to be installed onto my target root file system.

I have looked at several articles, none of which seem to work for me.

The desired functionality of this recipe is:

myRecipe/myFiles/ --> myRootFs/dir/to/install

My current attempt is:

SRC_URI += "file://myDir"

do_install() {
         install -d ${D}/path/to/dir/on/fs
         install -m ${WORKDIR}/myDir ${D}/path/to/dir/on/fs
}

I can't complain about the Yocto documentation overall, it's really good! Just can't find an example of something like this!

Answer

john madieu picture john madieu · Nov 21, 2016

You just have to copy these files into your target rootfs. Do not forget to pakage them if they are not installed in standard locations.

SRC_URI += "file://myDir"

do_install() {
    install -d ${D}/path/to/dir/on/fs
    cp -r ${WORKDIR}/myDir ${D}/path/to/dir/on/fs
}
FILES_${PN} += "/path/to/dir/on/fs"