Search code examples
yoctobitbakerecipeopenembedded

How to setup SRC_URI in bitbake recipes, such that they do not need modification when the git server URL changes?


I have a new meta layer which contains a number of recipes that fetch and build proprietary packages. At my end, the source for all these packages are hosted on a git server.

The recipes fetch the sources using the git fetcher, i.e., as follows:

SRC_URI = "git://<internal-server-url>/<project>

The <internal-server-url> is something that my customer cannot see (the server is internal and can't be reached from external world).

Instead, customer has their own git server. For customer the server

SRC_URI = "git://<customer-server-url>/<project>

Is it possible to have the SRC_URI in the recipes in such a manner that customers do not have to edit and change the URI in the SRC_URI variable?

P.S: Using yocto (Jethro)


Solution

  • Just use a variable in your layer to refer to the URL of the server.

    So layer.conf does something like?

    MY_PRODUCT_GIT_SERVER ?= "git://please.set.me/"
    

    Or if you're feeling really kind to throw an error if the variable isn't set correctly:

    MY_PRODUCT_GIT_SERVER ?= ""
    python() {
        if not d.getVar("MY_PRODUCT_GIT_SERVER", True):
            bb.error("Please set MY_PRODUCT_GIT_SERVER")
    }
    

    The recipes then do:

    SRC_URI = "${MY_PRODUCT_GIT_SERVER}/project"
    

    Then you can do this in your local.conf:

    MY_PRODUCT_GIT_SERVER="git://internal.server"
    

    And the customers do the same, but with the right URL.