Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the yocto bblayers.conf file use absolute paths?

The yocto project allows the use of relative path in most of its configuration files but not within the ./build/conf/bblayers.conf file. What is the reason for blocking the use of anything but absolute paths for the BBLAYERS and BBLAYERS_NON_REMOVABLE variables?

I have looked at the BitBake user manual for yocto version 2.0 (current release) but that does not explain the reasoning. I also checked some of the older manual versions but they do not seem to mention the reasoning when talking of the bblayers.conf file or the BBLAYERS variable. The same file also contains BBPATH = "${TOPDIR}" which is at least dynamically assigned and not that far away from the root yotco directory.

My best guess is that the bblayers.conf file is specific to the system it is being run on. That would make it unsuitable for sharing between developers via source control and the absolute paths would force people to edit the file whenever they received a copy. That did not seem like a very good reason though, hence the question.

like image 455
TafT Avatar asked Aug 11 '16 08:08

TafT


People also ask

What is bblayers conf?

conf file tells bitbake what layers you want to be considered during the build. By default, the layers listed in this file include layers minimally needed by the build system. However, you must manually add any custom layers you have created. E.g: BBLAYERS = "\ /home/jamal/poky/meta \

What is local conf file?

local. conf . It is a modified INI format file that introduces a meta-section header to carry additional information regarding the configuration files to be changed. A sample is provided in devstack/samples. The new header is similar to a normal INI section header but with double brackets ( [[ ...


4 Answers

I found a way to use relative paths.

You can use inline python to traverse the file system. The following script uses the provided TOPDIR variable and then navigates to its parent via python's os.path api.

# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "6"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

YOCTOROOT = "${@os.path.abspath(os.path.join("${TOPDIR}", os.pardir))}"

BBLAYERS ?= " \
  ${YOCTOROOT}/poky/meta \
  ${YOCTOROOT}/poky/meta-yocto \
  ${YOCTOROOT}/poky/meta-yocto-bsp \
"

BBLAYERS_NON_REMOVABLE ?= " \
  ${YOCTOROOT}/poky/meta \
  ${YOCTOROOT}/poky/meta-yocto \
"

References

  • OpenEmbedded's bitbake.conf
  • Advanced functionality with python
  • How do I get the parent directory in Python?
like image 106
Mario Tacke Avatar answered Nov 17 '22 06:11

Mario Tacke


I have managed to get "relative paths" in bblayers.conf files working by replacing

BBLAYERS ?= " \
  /home/username/poky/meta \
  ...

with

BBLAYERS ?= " \
  ${TOPDIR}/../meta \
  ...

I guess one caveat with this approach is that I'm relying on the meta-XXX layer directories always being in the parent folder of TOPDIR. This seems to be the case with the default way of using yocto, but might not be so for more customized build setups.

like image 27
gbmhunter Avatar answered Nov 17 '22 05:11

gbmhunter


All the existing answers are answering "how to use relative paths" but the question is "why are absolute paths used". As far as I know the "why" is simple, it is done that way so that the build directory can be moved anywhere on the filesystem. Think about it: you can source poky/oe-init-build-env from anywhere on the filesystem and the build directory will be created there, so relying on paths relative to the build directory is very fragile.

Edit:

maybe this is clearer, I think you are assuming that the file bblayers.conf is always in poky/build/conf/bblayers.conf and that you can therefore use a path like ../../meta-layer-foo to refer so some layer which would be in poky/meta-layer-foo, but the layer will not be found if I instantiate "build" in another path poky/foo/bar:

etienne@ubuntu:~/repos/poky-tx2$ mkdir -p foo/bar
etienne@ubuntu:~/repos/poky-tx2$ cd foo/bar/
etienne@ubuntu:~/repos/poky-tx2/foo/bar$ ls
etienne@ubuntu:~/repos/poky-tx2/foo/bar$ source ../../oe-init-build-env 
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/


### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'
etienne@ubuntu:~/repos/poky-tx2/foo/bar/build$ ls
conf
like image 3
Étienne Avatar answered Nov 17 '22 06:11

Étienne


You can use relative paths in bblayers.conf.

There is probably this line in your bblayers.conf:

BBPATH = "${TOPDIR}"

When you want to find out this variable's content, you will probably find the top-level directory of your build directory:

bitbake -e | grep ^TOPDIR
# searches for bitbake variables

Inside this directory you could create a layer meta-test and add it in bblayers.conf with a relative path:

BBLAYERS ?= " \
  meta-test \
  [...]
  "

So the answer on your question why there are absolute paths in bblayers.conf is that you can place your build directory anywhere on the system and not dependant from Yocto.

Relative Paths to Layers must always be relative to the build directory.

like image 3
h0ch5tr4355 Avatar answered Nov 17 '22 05:11

h0ch5tr4355