The mechanism used by BitBake to fetch source code is internally called the fetcher backend. There are several fetcher backends supported, which can be configured to align user requirements and optimize source code fetching.
BitBake supports several protocols for remote file downloads. The most commonly used are http://
, https://
, and git://
. When BitBake executes the do_fetch
task in a recipe, it checks the contents of SRC_URI
. We will discover, through the various fetchers, how to proceed based on our need.
The local file fetcher submodule handles URLs that begin with file://
. The filename you specify within the URL can either be an absolute or relative path to a file. For example, with a file called my_source_file.c
, we must write the SRC_URI
attribute's content like this:
SRC_URI = "file://my_source_file.c"
The HTTP fetcher obtains files from web servers. Internally, the fetcher uses the wget utility.
In this example, we will use the bcm2835
library. With this submodule, we will retrieve the tar.gz
file of this library:
SRC_URI = "http://www.open.com.au/mikem/bcm2835/bcm2835-${PV}.tar.gz"
One of the most commonly used source control management systems in use is Git. BitBake has solid support for it, and the Git backend is used when the do_fetch
task is run and finds a git:// URL
at the SRC_URI
variable. Here is an example featuring a utility developed by Christophe Blaess. It is a simple command-line tool to help with the use of Linux spidev devices.
SRCREV = "cc6a41fdcec60610703ba6db488c621c64952898"
This variable contains the reference to the commit that the version control system will use as a basis. In the case of Git, it is the the commit hash.
SRC_URI = "git://github.com/cpb-/spi-tools.git;protocol=git"
When the SRCREV
variable points to a hash not available in the master branch, we need to use the branch=<branch name>
parameter, as follows: SRC_URI = git://myserver/myrepo.git;branch=mybranch
. In the cases when the hash used points to a tag that is not available in a branch, we need to use the nobranch=1
option, as follows: SRC_URI = "git://myserver/myrepo.git;nobranch=1"
.
For further information about the SRC_URI
parameter's values, go to
http://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html#var-SRC_URI
for some examples.
18.219.189.247