简体   繁体   English

如何编写 yocto/bitbake 配方以将目录复制到目标根文件系统

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

I have a directory of 'binary' (ie 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 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!总的来说,我不能抱怨 Yocto 文档,它真的很棒! Just can't find an example of something like this!只是找不到这样的例子!

You just have to copy these files into your target rootfs.您只需要将这些文件复制到您的目标 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"

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.就像 poky 中的其他食谱一样,或者只是遵循官方建议以避免所有权和权限问题。

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:您可以使用以下方法将其安装到 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/* "

I think it did not work for you becuase you forgot to add mode value, after "install -m",我认为它对您不起作用,因为您在“安装 -m”之后忘记添加模式值,

see man page of install command: https://linux.die.net/man/1/install请参阅安装命令的手册页: https : //linux.die.net/man/1/install

install -m [mode] src destination

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM