如何使用 bitbake 将文件夹或文件添加到食谱的根目录?

How can I add a folder or file to the root in a recipe with bitbake?

我正在尝试将文件夹放入文件系统的根目录。在文档中(例如 here),它们主要使用变量,因此来自 SRC_URI 的文件和文件夹导致存储在 /usr/bin 或其他目录下,但从不存储在 /.

这是我的食谱:

DESCRIPTION = "Example for adding files and folders to rootfs"

SRC_URI += "file://example_folder"
SRC_URI += "file://example_file"

LICENSE = [...]

do_install() {
    install -d ${D}/rootfolder
    cp -r ${WORKDIR}/example_folder ${D]/rootfolder/
    install -m 0755 ${WORKDIR}/example_file ${D}/rootfolder
}

这只是众多 do_install 变体之一,我 tried.Every 导致 Error: example not found in the base feeds [...] 或文件和文件夹未放置在根目录中,但/usr/bin 如上所述。

如果您遇到错误 "Error: example not found in the base feeds [...]",很可能您实际上已经成功构建了您的食谱 example.bb。当然,假设您在构建图像时遇到该错误,其中包含 IMAGE_INSTALL += "example"

如果您将文件安装到 /rootfolder,OE 本身没有任何东西知道如何将这些文件打包到 rpmipkdeb 包中.您需要通过添加以下行将其添加到您的食谱中:
FILES_${PN} += "/rootfolder"

这样做,您上面的示例应该可以工作。

根据您安装的文件,您可能希望将其中一些文件添加到其他包中,例如 ${PN}-dbg${PN}-dev