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

ぐ巨炮叔叔 提交于 2019-12-04 11:13:08

问题


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!


回答1:


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"



回答2:


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 recomendations




回答3:


For a recipe folder like this:

.
├── files
│   ├── a.txt
│   ├── b.c
│   └── Makefile
└── myrecipe.bb

You can use the following recipe to install it on a specific folder into 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/* "



回答4:


I think it did not work for you becuase you forgot to add mode value, after "install -m",

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

install -m [mode] src destination


来源:https://stackoverflow.com/questions/40722637/how-do-i-write-a-yocto-bitbake-recipe-to-copy-a-directory-to-the-targe-root-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!