Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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!

like image 479
Ben Turner Avatar asked Nov 21 '16 14:11

Ben Turner


People also ask

How do you add a recipe to yocto?

Adding new recipes to the build system One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.

What is Workdir in Bitbake?

The default value of ${WORKDIR} is defined in bitbake variables. But you can change it in the recipe. It points toward the directory where bitbake unpacks the package. You can get the value of ${WORKDIR} from the bitbake environment bitbake -e <recipe-name> | grep ^WORKDIR=

What is files _${ PN in yocto?

FILES_${PN} The base package, this includes everything needed to actually run the application on the target system.


2 Answers

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"
like image 160
john madieu Avatar answered Nov 25 '22 00:11

john madieu


Take care that with a simple recursive copy, you will end up having host contamination warnings so you would need to copy with the following parameters:

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

As other recipes in poky do, or just follow the official recommendations to avoid problems with ownership and permissions.

like image 28
urnenfeld Avatar answered Nov 25 '22 00:11

urnenfeld