How to install directory structure recursively in OpenEmbedded BitBake recipe?

百般思念 提交于 2020-01-03 18:26:18

问题


I'd like to simplify a BitBake recipe that installs a large directory structure by using some sort of recursive install routine rather than calling install many times. The source directory layout is frequently changing during development, which is causing far more recipe revisions than I want to deal with.

As an example, how would the following do_install() be simplified from this:

do_install() {
    install -d ${D}/foo
    install -m 0644 ${S}/foo/*.* ${D}/foo

    install -d ${D}/foo/a
    install -m 0644 ${S}/foo/a/*.* ${D}/foo/a

    install -d ${D}/foo/b
    install -m 0644 ${S}/foo/b/*.* ${D}/foo/b

    install -d ${D}/foo/c
    install -m 0644 ${S}/foo/c/*.* ${D}/foo/c

    install -d ${D}/bar
    install -m 0644 ${S}/bar/*.* ${D}/bar

    install -d ${D}/bar/a
    install -m 0644 ${S}/bar/a/*.* ${D}/bar/a

    install -d ${D}/bar/a/bananas
    install -m 0644 ${S}/bar/a/bananas/*.* ${D}/bar/a/bananas
}

To something more like this pseudocode:

do_install() {
    for each subdir in ${S}/foo/
        install subdir recursively to ${D}/foo/subdir
    end

    for each subdir in ${S}/bar/
        install subdir recursively to ${D}/bar/subdir
    end
}

The top-level directories in our source files (foo & bar in the above example) rarely change, so calling them out in the recipe is fine. It's the lower level directories that are frequently changing.

It may be that cp -r ends up being the way to go, but I believe I've read that it's frowned upon in BitBake recipes, so I'm wondering if BitBake provides some alternate mechanism, or if there's some other reasonably standardized way to do this.


回答1:


We used to do it in that way:

do_install() {
find ${WORKDIR}/ -type f -exec 'install -m 0755 "{}" ${D}/var/www/' \;
}



回答2:


The canonical form in OE is

cp -R --no-dereference --preserve=mode,links -v SOURCE DESTINATION

see the answer here (while they looks a bit different in code, the questions are semantically equivalent)



来源:https://stackoverflow.com/questions/31817222/how-to-install-directory-structure-recursively-in-openembedded-bitbake-recipe

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