How to write a yocto / bitbake recipe to copy a directory to the targe root file system

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

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

Desired functionality of this recipe:

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

My current attempt:

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 as a whole, it's really good! I just can’t find an example of something like this!

+10
source share
4 answers

You just need to copy these files to the target rootfs. Remember to trick them if they are not installed in standard places.

 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" 
+9
source

Make sure that with a simple recursive copy you have warnings about host contamination , so you will need to copy with the following parameters:

 do_install() { [...] cp --preserve=mode,timestamps -R ${S}${anydir}/Data/* ${D}${anyotherdir}/Data [...] } 

Like other poky style recipes, or just follow the official recommendations

+1
source

For a recipe folder, for example:

 . β”œβ”€β”€ files β”‚  β”œβ”€β”€ a.txt β”‚  β”œβ”€β”€ bc β”‚  └── Makefile └── myrecipe.bb 

You can use the following recipe to install it in a specific folder in your rootfs:

 SRC_URI = " file://*" do_install() { install -d ${WORKDIR}/my/dir/on/rootfs install -m 0755 ${S}/* ${WORKDIR}/my/dir/on/rootfs/* } FILES_${PN} = "/my/dir/on/rootfs/* " 
0
source

I think this did not work for you because you forgot to add the mode value after "install -m",

see the install command man page: https://linux.die.net/man/1/install

 install -m [mode] src destination 
0
source

Source: https://habr.com/ru/post/1260082/


All Articles