Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install directory structure recursively in OpenEmbedded BitBake recipe?

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.

like image 620
user5071535 Avatar asked Aug 04 '15 19:08

user5071535


2 Answers

We used to do it in that way:

do_install() {
find ${WORKDIR}/ -type f -exec 'install -m 0755 "{}" ${D}/var/www/' \;
}
like image 134
Tobias Bystricky Avatar answered Nov 01 '22 10:11

Tobias Bystricky


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)

like image 23
LetoThe2nd Avatar answered Nov 01 '22 11:11

LetoThe2nd