[yocto] How to write a distro layer?

Vincent Prince vincent.prince.fr at gmail.com
Fri Aug 3 02:44:12 PDT 2018


Hi Uwe,

2018-08-03 10:39 GMT+02:00 Uwe Geuder <jrswdnan22 at snkmail.com>:

> Hi!
>
> [Disclaimer: I have posted a similar message months ago. There were no
> replies. Let's try whether I can express myself clearer this time.]
>
> One of the few informations I could find about how to create my own
> layer was something like
> https://www.openembedded.org/wiki/Creating_a_new_Layer
>


Did you check
https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#creating-a-general-layer-using-the-bitbake-layers-script



> Especially for creating a distro layer that does not give much guidance.
>
> I could not find any examples of distro layers (except poky of course)
> on the net. Can somebody give me pointers?
>
> The auto-generated local.conf mentions subclassing
> poky. Is that concept explained anywhere?
>
> I inherited a distro layer, which sets a lot of its policy (selection of
> systemd and other feature/package selection) in layer.conf. From reading
> the documentation and other layer.conf files I understand that is NOT
> the way to do it. I would expect those settings in distro/<distro>.conf.
>
> The yocto reference manual says for many variables: "Set it in your
> local.conf". For me they are policy, so why shouldn't I set them in
> distro/<distro>.conf?
>
>
Did you also check
https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#creating-your-own-distribution

You can look some Freescale example here:
https://github.com/Freescale/meta-freescale-distro

In fact, when Yocto manual refers to adding something to local.conf, it is
the minimal way to do it,
but the cleanest is indeed to set it in machine/distro config file.


> Well, basically there is only one configuration in bitbake. So often it
> does not matter in what configuration file a variable is set. The
> setting will end up in the environment of the tasks. However, especially
> when the ?= operator is used order becomes significant.
>
> Particularly tricky I found the DISTRO variable.
>
> Our distro layer does
>
> 1.) set the DISTRO variable in layer.conf (according to the manual it
> should be done in local.conf)
> 2.) from distro/<distro>.conf include (well, require) poky.conf. Is
> that a big no-no??? Of course I could copy all settings I want to keep from
> poky (and all those I don't understand what they do...), but copying code
> is generally not good SW engineering, including sounds better.
> 3.) set DISTRO again after having included poky.conf . According to
> the yocto-check-layer script a distro must not set its own
> name. However, poky does not follow that rule and sets its name, so our
> code has to violate the rule once more and revert poky's wrongdoing.
>
>
1.) DISTRO is local to build folder, so it should be in local.conf, and you
can use a wrapper script to help creating this local.conf file,
see
https://github.com/Freescale/fsl-community-bsp-base/blob/master/setup-environment
for instance.


> In an attempt to make our code more in line with what I understand to be
> correct style, I tried to move all policy settings to
> distro/<distro>.conf and the DISTRO setting to local.conf.
>
> However that created a couple of problems:
>
> 1. If I set DISTRO in local.conf before adding all needed layers, my own
> distro layer last, bitbake-layers fails in a sanity check that the
> distro does not exist. Fair enough, it doesn't know about before it has
> been added.
>
> 2. If I first modify my local.conf with all my settings except DISTRO,
> then run all the add-layer operations and finally modify local.conf a
> 2nd time to set DISTRO correctly the build works. However, all recipes
> are reparsed when the build starts. I guess this is caused by the config
> change.
>
> So in the end having the DISTRO setting in layer.conf seems to work
> best. All add-layer commands succeed and recipes can be used from the
> cache when the build starts. Best, except that I don't think that's the
> way it's documented.
>
Any thoughts what I might be missing?
>

You can use git submodule, or google repo to create Yocto environment, you
don't need to create your layer each time and you don't have to compile
before using bitbake-layers.


>

Regards,
>
> Uwe
>
>
> Uwe Geuder
> Neuro Event Labs Oy
> Tampere, Finland
> uwe.gexder at neuroeventlabs.com (Bot check: fix one obvious typo)
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20180803/51287673/attachment.html>


More information about the yocto mailing list