Date   

Overrides conversion plan

Richard Purdie
 

Hi All,

I've spent quite a bit of time seeing how to progress things. I now
have a script which can convert layers and seems to have reasonable success
on OE-Core, bitbake, yocto-docs, meta-yocto, meta-gplv2 and meta-mingw. I've
proposed this for OE-Core along with an example conversion patch for OE-Core.

The current patch status is I have conversions (including to bitbake's core)
in master-next branches. This nearly has q-quick builds passing on the 
autobuilder, there are a handful of oe-selftest cases which don't pass yet.

Things do get a little more complex than I'd hoped. We use OVERRIDES
in a number of interesting places, including within multilib configurations
for the tune-XXX variable suffixes. I did try making the code do "fallback"
variable lookups instead of expansion for tune- but I quickly gave up due
to the nesting. My view is that they are being used as overrides and we should 
therefore recognise them as such. Over time I think the tune code can be
improved to take explicit advantage of that.

As such, I'm proposing we make the package variables and tune variables
explicit overrides and the conversion scripts and patches above assume this.

I think the challenge is going to be the flag day issue for master branches.
For example, there is code in devtool and other places which knows about the
override character. If we allow mixing the different syntax for master then
those tools need to complicate things by referencing both characters. To try
and preserve what is left of my sanity, I'm starting to think we just require
layers to migrate to the new syntax to continue to work with master. The good
news is that those converted layers should work with dunfell and older releases
where the layer already does that with the backported bitbake syntax update.

If we accept that we need to have a flag day for master use, the question is 
when. We could pick some data well in the future or even post 3.4 however I'm
not sure this buys much and we probably may as well get on and do it.

Given these things, I therefore propose that we should start these changes 
and require it for master, probably relatively quickly within a couple of 
weeks?

Cheers,

Richard


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Denys Dmytriyenko
 

On Tue, Jul 27, 2021 at 05:40:32PM +0100, Richard Purdie wrote:
On Tue, 2021-07-27 at 12:38 -0400, Denys Dmytriyenko wrote:
On Tue, Jul 27, 2021 at 08:18:13AM +0100, Richard Purdie wrote:
On Mon, 2021-07-26 at 23:51 -0400, Denys Dmytriyenko wrote:
All,

The layer has been updated and moved to git.yoctoproject.org under a central
mixin repo called "meta-lts-mixins", branch "dunfell/kernel":
http://git.yoctoproject.org/cgit/cgit.cgi/meta-lts-mixins/

The naming is in accordance with the LTS mixin layer guidelines:
https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories

Other mixin layers are also welcome!
Should the layer be called kernel-5.10 since there potentially may be other
versions?
Either that, or it can hold multiple versions...
I think that defeats the idea of specific purpose layers?
Not necessarily. Providing latest LTS kernels for Dunfell also seems very
specific. For every extra year of official support for Dunfell, this can
offer a new LTS kernel version, that can be selected by PREFERRED_VERSION.
Creating a new branch for each kernel version seems wasteful. But I can do
that as well, if needed.

--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Richard Purdie
 

On Tue, 2021-07-27 at 12:38 -0400, Denys Dmytriyenko wrote:
On Tue, Jul 27, 2021 at 08:18:13AM +0100, Richard Purdie wrote:
On Mon, 2021-07-26 at 23:51 -0400, Denys Dmytriyenko wrote:
All,

The layer has been updated and moved to git.yoctoproject.org under a central
mixin repo called "meta-lts-mixins", branch "dunfell/kernel":
http://git.yoctoproject.org/cgit/cgit.cgi/meta-lts-mixins/

The naming is in accordance with the LTS mixin layer guidelines:
https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories

Other mixin layers are also welcome!
Should the layer be called kernel-5.10 since there potentially may be other
versions?
Either that, or it can hold multiple versions...
I think that defeats the idea of specific purpose layers?

Cheers,

Richard


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Denys Dmytriyenko
 

On Tue, Jul 27, 2021 at 08:18:13AM +0100, Richard Purdie wrote:
On Mon, 2021-07-26 at 23:51 -0400, Denys Dmytriyenko wrote:
All,

The layer has been updated and moved to git.yoctoproject.org under a central
mixin repo called "meta-lts-mixins", branch "dunfell/kernel":
http://git.yoctoproject.org/cgit/cgit.cgi/meta-lts-mixins/

The naming is in accordance with the LTS mixin layer guidelines:
https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories

Other mixin layers are also welcome!
Should the layer be called kernel-5.10 since there potentially may be other
versions?
Either that, or it can hold multiple versions...

--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Richard Purdie
 

On Mon, 2021-07-26 at 23:51 -0400, Denys Dmytriyenko wrote:
All,

The layer has been updated and moved to git.yoctoproject.org under a central
mixin repo called "meta-lts-mixins", branch "dunfell/kernel":
http://git.yoctoproject.org/cgit/cgit.cgi/meta-lts-mixins/

The naming is in accordance with the LTS mixin layer guidelines:
https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories

Other mixin layers are also welcome!
Should the layer be called kernel-5.10 since there potentially may be other
versions?

Cheers,

Richard


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Denys Dmytriyenko
 

All,

The layer has been updated and moved to git.yoctoproject.org under a central
mixin repo called "meta-lts-mixins", branch "dunfell/kernel":
http://git.yoctoproject.org/cgit/cgit.cgi/meta-lts-mixins/

The naming is in accordance with the LTS mixin layer guidelines:
https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories

Other mixin layers are also welcome!

On Mon, Jul 19, 2021 at 01:55:42PM -0400, Denys Dmytriyenko wrote:
All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!
--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


OpenEmbedded Happy Hour July 28 5pm/1700 UTC

Denys Dmytriyenko
 

Hi,

Just a reminder about our upcoming OpenEmbedded Happy Hour on July 28 for
Europe/Americas timezones @ 1700/5pm UTC (1pm ET / 10am PT):

https://www.openembedded.org/wiki/Calendar
https://www.timeanddate.com/worldclock/fixedtime.html?msg=OpenEmbedded+Happy+Hour+July+28&iso=20210728T17

--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Denys Dmytriyenko
 

On Tue, Jul 20, 2021 at 08:38:05AM +0100, Paul Barker wrote:
On Mon, 19 Jul 2021 13:55:42 -0400
"Denys Dmytriyenko" <denis@...> wrote:

All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!

[1] https://kernel.org/
[2] https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories
[3] https://github.com/denix0/meta-lts-kernel-mixin
Hi Denys,
Paul,

Thanks for the review!


This looks like a good initiative. A couple of initial comments:

layer.conf contains `PREFERRED_VERSION_linux-yocto ?= "5.10%"`. It'd
be better to leave that out and in the readme say that users need to
add this in their distro or local conf. That would bring the layer in
line with best practices and what's needed for Yocto Project Compatible
status as adding simply a layer to a build should not result in changes
to the images you build.
Right, good point. I put it there for testing and totally forgot about it.


The layer needs a COPYING or LICENSE file.
Sure, will add a standard MIT one.


It'd be good to explicitly say how contributions to the layer can be
made - should this be by GitHub pull request or via a mailing list?
Yeah, it was missing because GitHub is a temporary location for this layer.
Most probably contribution model will be via a mailing list - will have to
update it after the move.

--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Steve Sakoman
 

On Mon, Jul 19, 2021 at 2:34 PM Mark Hatle
<mark.hatle@...> wrote:

Did someone already backport the change to Dunfell to fix the module.lds for out
of tree kernel builds?

Master commit 596b0474d3d?
Yes, see https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=dunfell&id=5981a05525442f1a0db1c4e710b319dbf1fbba8b

For gatesgarth, we ended up porting a copy of this into our distribution branch,
as it was rejected for a backport.

Also there was a necessary change for kernel-devsrc as well, I believe the
oe-core commit was: cb940d8af359fa370254bd4c2b36ba26708bb54b
I missed that one, but it seems safe enough so I'll add it to my next
review series.

Steve


See:

https://github.com/Xilinx/meta-petalinux/tree/rel-v2021.1/oe-core/meta

classes/kernel.bbclass and recipes-kernel/linux

this was the best way we could find to override these files for gatesgarth.

--Mark


On 7/19/21 12:55 PM, Denys Dmytriyenko wrote:
All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!

[1] https://kernel.org/
[2] https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories
[3] https://github.com/denix0/meta-lts-kernel-mixin






Re: Linux 5.10 LTS "mixin" layer for Dunfell

 

On Mon, 19 Jul 2021 13:55:42 -0400
"Denys Dmytriyenko" <denis@...> wrote:

All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!

[1] https://kernel.org/
[2] https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories
[3] https://github.com/denix0/meta-lts-kernel-mixin
Hi Denys,

This looks like a good initiative. A couple of initial comments:

layer.conf contains `PREFERRED_VERSION_linux-yocto ?= "5.10%"`. It'd
be better to leave that out and in the readme say that users need to
add this in their distro or local conf. That would bring the layer in
line with best practices and what's needed for Yocto Project Compatible
status as adding simply a layer to a build should not result in changes
to the images you build.

The layer needs a COPYING or LICENSE file.

It'd be good to explicitly say how contributions to the layer can be
made - should this be by GitHub pull request or via a mailing list?

Thanks,

--
Paul Barker
https://pbarker.dev/


Re: Linux 5.10 LTS "mixin" layer for Dunfell

Mark Hatle
 

Did someone already backport the change to Dunfell to fix the module.lds for out
of tree kernel builds?

Master commit 596b0474d3d?

For gatesgarth, we ended up porting a copy of this into our distribution branch,
as it was rejected for a backport.

Also there was a necessary change for kernel-devsrc as well, I believe the
oe-core commit was: cb940d8af359fa370254bd4c2b36ba26708bb54b

See:

https://github.com/Xilinx/meta-petalinux/tree/rel-v2021.1/oe-core/meta

classes/kernel.bbclass and recipes-kernel/linux

this was the best way we could find to override these files for gatesgarth.

--Mark

On 7/19/21 12:55 PM, Denys Dmytriyenko wrote:
All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!

[1] https://kernel.org/
[2] https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories
[3] https://github.com/denix0/meta-lts-kernel-mixin





Linux 5.10 LTS "mixin" layer for Dunfell

Denys Dmytriyenko
 

All,

Recently several Yocto Project members have expressed interest in being able
to upgrade the Linux kernel in Dunfell LTS release from 5.4 to 5.10. Both of
those Linux kernel versions are designated "longterm"[1], but at the time
Dunfell was released in April 2020, 5.10 was not out yet.

Recommended way to add new features or upgrade components in Yocto LTS
releases is with the so called "mixin" layers[2]. After discussing some of
the details of such layer among the Yocto Project TSC and other interested
developers, as well as testing the concept for few weeks, I'd like to make
this open to a wider consumption in hopes it would be useful to others.

This Linux kernel "mixin" layer is currently hosted on GitHub under my
name[3], but can be moved to a more public space, like Yocto Project git
server, if it gets traction and is found useful to others. Please feel free
to try it and provide feedback. Thanks!

[1] https://kernel.org/
[2] https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#LTS_.E2.80.9CMixin.E2.80.9D_repositories
[3] https://github.com/denix0/meta-lts-kernel-mixin

--
Regards,
Denys Dmytriyenko <denis@...>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186 6D76 4209 0272 9A92 C964


Override syntax change proposal

Richard Purdie
 

Hi All,

I now have an actual proposed plan for changing override syntax which I hope
will mitigate the issues raised in the previous discussion as far a is possible
whilst still letting the project move forward.

Firstly, I'd like to merge a patch I sent to the bitbake list:

https://lists.openembedded.org/g/bitbake-devel/topic/patch_data_smart_parse/84285770

This patch allows bitbake to accept ":" in variable/function names. It is designed
to be simple and could be easily backported to previous bitbake versions. At the
very least I'd like to do that for master, allowing at least OE-Core master branch 
to start using an explicit override syntax.

I'd like to go further and suggest we backport to older bitbake versions (back to 
dunfell?) so that anyone using metadata over multiple versions could continue to
do so.

I'm hoping the above isn't too controversial and would at least let us move forward
to trying to improve.

The next steps beyond that are a little trickier as they start to require the change.
The next logical move is to require ":" as the separator for current master branches.
I believe it is reasonable to do this if we can show how layers can be converted and 
have a way for older layers to continue to work with master.

There is a script I wrote and linked to (~100 lines of python) which with some
priming about the overrides in use in a layer (which a layer maintainer should know), 
is able to automatically convert a layer. For oe-core+meta-yocto+docs+bitbake, that
is 9000+ changes but the script seems reliable if not very nice code. I did end up
adding a handful of manual fixes but that was for python code manipulating variables
which most layers wouldn't have, in general the core is way more complex than most
layers.

This means that people with older layers trying to work with master now have two
options:

a) they convert to use ":" and update to a version of bitbake with the above tweak
to allow it to accept that (no behaviour change)
b) they dynamically translate their layer with a script when testing with master

Given those options two options both being shown to be viable, I think this
is enough to allow us to proceed and update the syntax on shorter timescales such
as during this release, ready for the next LTS.

In working out compatibility pieces, I don't have any optimisations using the
new syntax yet, or a plan worked out for what we can do beyond this other that ideas
and my previous experiments. Some changes "feel" right and this one definitely does 
as a good move in it's own right regardless of whether we ultimately can improve 
syntax or not. I'm therefore keen to proceed.

Cheers.

Richard


Re: Should we change variable override formatting?

Richard Purdie
 

On Fri, 2021-07-16 at 17:46 +0100, Richard Purdie via lists.openembedded.org wrote:
Just to update, I have an experiment:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=rpurdie/overrides-convert

This contains a conversion script which can convert poky to use ":" 
instead of "_" as the override character (i.e. all of oe-core, meta-yocto, 
docs and bitbake inc. tests). I had to add in only two special hand cases
to the conversion code which is better than I expected (so far).

There is also a quick hack to make bitbake use the new override format 
(but no optimisation to the code) and a commit showing the result of the 
conversion.

Right now, this will successfully "bitbake -p", i.e. it parses. It will
even run a build but crashes out in gcc-cross do_compile.
Branch updated, it now lets a core-image-sato build successfully.

Cheers,

Richard


Re: Should we change variable override formatting?

Mark Hatle
 

On 7/16/21 11:56 AM, Richard Purdie wrote:
On Fri, 2021-07-16 at 11:44 -0500, Mark Hatle wrote:

On 7/16/21 4:22 AM, Richard Purdie wrote:
On Thu, 2021-07-15 at 09:26 -0500, Mark Hatle wrote:

On 7/15/21 8:56 AM, Richard Purdie wrote:
Breaking things down a bit, one thing I keep running into with our current 
codebase and metadata is that overrides are not clear. In my previous email,
the example was:

do_configure_class-native

A human can usually spot "class-native" is and "configure" or 
"configure_class-native" is not. Bitbake's parser struggles. It has huge 
internal lists including variables like x86_64 where it has to track 
whether "64" in an override.

One way of fixing this is to be explicit about overrides and use a different 
separator. See an example patch below I made to the quilt recipe using ":" 
instead to see how it looks. Personally, I think this looks like an improvement.

There are two challenges:

a) The work of migration. Do we migrate piecemeal or with a flag day? I'm not
   sure piecemeal is even possible unfortunately.

b) Some of the packaging code (at the very least) needs rewriting as it accesses
   both RDEPENDS_${PN} and puts ${PN} in OVERRIDES and accesses RDEPENDS. I'm not
   sure what else may be assuming this works.
Ya, this is all over the packaging code. Should be trivial to move to treating
it as a variable (and not override). I can help with this if you want.
I've been pondering this a bit more and my preference is to move this to use 
overrides more explicitly.
The part of the code I worked on, the override was used as an optimization to avoid:

d.getVar("RDEPENDS_%s" % package) or d.getVar("RDEPENDS")

(and similar for all of the other variables that could be package specific.)

Overrides (at least to me) are system (or at least recipe) wide settings that
allow you to 'override' key things. The package items, based on that definitely
really aren't overrides -- they're package specific variables. (This is also
why I suggested RDEPENDS[package] might actually be a better syntax.)
Overrides are one of the key things which make OE function as an architecture and 
how a lot of the "magic" in our metadata happens. There is a hierarchy of overrides,
some are system wide some are local to specific functional areas but using them for
packaging is a natural fit.

As such, I'm very strongly in favour of explicitly exposing that rather than hiding
it.

FWIW the image class code also does something similar for IMAGE_CMD and image types.

I'm all for making override usage more clear to people. But in this ONE case, I
don't think these are really overrides -- and worse they could cause confusion
because they are ONLY overrides when packaging. So if you use the override
chunk in something that doesn't affect a package specific setting it won't do
anything. It also won't do anything on the functions (I think), as those are
run before the override is loaded.

Specific code I'm talking about BTW is:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/package_rpm.bbclass

starting at line 287. (srcname is PN-src BTW)

then the loop starting at 328. Iterates over PACKAGES and sets the override one
at a time to the package name to get (conffiles, dirnames, summary/description,
pkgv, pkgr, pkge, license, section, description, rdepends, rrecommends,
rsuggests, rprovides, rreplaces, rconflicts, and I suspect a few others...)

Note, I could make the above changes pretty quickly and just submit this as an
implementation change in a few hours. I'd be happy to do that and look for
other 'in-place' usages of d.setVar("OVERRIDE"... to see if there are other
things like this.
As above, I'm very much of the opposite view, I think we want to promote this,
not remove it. Yes, you can emulate overrides with other forms of variable access
but that really isn't how the system was designed to be used.
The view I've also had and used to explain to others. There are two scopes of
variables in OE. global and recipe specific. Adding an override anywhere else,
really adds additional (hidden) scopes to the system.

I guess this metal model of scopes is influenced by 'bitbake -e'. I can run it
against the global system, or a specific recipe. But there is no way for me to
run it on a 'package' scope.

Additional mental issue I have with PACKAGE being a scope, is the limited nature
of the scope. The majority of variables in the system are not modified or used
when in this scope, only a VERY limited amount.. (Now this limited amount can
reference variables in the recipe scope.. But would you ever do:

PACKAGES = "${PN} ${PN}-dev ${PN}-src"

FILES_${PN} = "/foo/${MYFILE}"

MYFILE = "bar"
MYFILE_${PN} = "foo"

Current implementation, /foo/foo would be selected, only during package
processing -- but if you use bitbake -e recipe you can /foo/bar...


So back to what I offered before, from a quicker survey of poky the following
are the only non-global/recipe specific scopes that I was able to find.

'PACKAGE' specific overrides:
package_*.bbclass
update-rc.d.bbclass
insane.bbclass
buildhistory.bbclass

The variables allowed to work in the current form of VAR_pkg is very specific
and tailored.


uboot/syslinux/grub have a concept of 'labels', they each implement it slightly
differently but it's the same idea:
uboot-extlinux-config.bbclass
syslinux.bbclass
grub-efi-cfg.bbclass

Again, the list appears to be very specific and minimal from what I could tell.
Unlike the package side, I don't have a lot of experience here. (Variables are
specific to each of those three classes though, but still a limited set.)


'debugfs' usage for images. This appears to be how the debugfs stuff is
implemented:
image.bbclass

I'm not completely sure the range of variables used here. But again it looks
somewhat limited in scope... but this scope could quickly expand if you end up
nesting things variables, but I'm unsure that it would work based on the manual
processing of vardeps that I see.

Cheers,

Richard


Re: Should we change variable override formatting?

Richard Purdie
 

On Fri, 2021-07-16 at 11:44 -0500, Mark Hatle wrote:

On 7/16/21 4:22 AM, Richard Purdie wrote:
On Thu, 2021-07-15 at 09:26 -0500, Mark Hatle wrote:

On 7/15/21 8:56 AM, Richard Purdie wrote:
Breaking things down a bit, one thing I keep running into with our current 
codebase and metadata is that overrides are not clear. In my previous email,
the example was:

do_configure_class-native

A human can usually spot "class-native" is and "configure" or 
"configure_class-native" is not. Bitbake's parser struggles. It has huge 
internal lists including variables like x86_64 where it has to track 
whether "64" in an override.

One way of fixing this is to be explicit about overrides and use a different 
separator. See an example patch below I made to the quilt recipe using ":" 
instead to see how it looks. Personally, I think this looks like an improvement.

There are two challenges:

a) The work of migration. Do we migrate piecemeal or with a flag day? I'm not
   sure piecemeal is even possible unfortunately.

b) Some of the packaging code (at the very least) needs rewriting as it accesses
   both RDEPENDS_${PN} and puts ${PN} in OVERRIDES and accesses RDEPENDS. I'm not
   sure what else may be assuming this works.
Ya, this is all over the packaging code. Should be trivial to move to treating
it as a variable (and not override). I can help with this if you want.
I've been pondering this a bit more and my preference is to move this to use 
overrides more explicitly.
The part of the code I worked on, the override was used as an optimization to avoid:

d.getVar("RDEPENDS_%s" % package) or d.getVar("RDEPENDS")

(and similar for all of the other variables that could be package specific.)

Overrides (at least to me) are system (or at least recipe) wide settings that
allow you to 'override' key things. The package items, based on that definitely
really aren't overrides -- they're package specific variables. (This is also
why I suggested RDEPENDS[package] might actually be a better syntax.)
Overrides are one of the key things which make OE function as an architecture and 
how a lot of the "magic" in our metadata happens. There is a hierarchy of overrides,
some are system wide some are local to specific functional areas but using them for
packaging is a natural fit.

As such, I'm very strongly in favour of explicitly exposing that rather than hiding
it.

FWIW the image class code also does something similar for IMAGE_CMD and image types.

I'm all for making override usage more clear to people. But in this ONE case, I
don't think these are really overrides -- and worse they could cause confusion
because they are ONLY overrides when packaging. So if you use the override
chunk in something that doesn't affect a package specific setting it won't do
anything. It also won't do anything on the functions (I think), as those are
run before the override is loaded.

Specific code I'm talking about BTW is:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/package_rpm.bbclass

starting at line 287. (srcname is PN-src BTW)

then the loop starting at 328. Iterates over PACKAGES and sets the override one
at a time to the package name to get (conffiles, dirnames, summary/description,
pkgv, pkgr, pkge, license, section, description, rdepends, rrecommends,
rsuggests, rprovides, rreplaces, rconflicts, and I suspect a few others...)

Note, I could make the above changes pretty quickly and just submit this as an
implementation change in a few hours. I'd be happy to do that and look for
other 'in-place' usages of d.setVar("OVERRIDE"... to see if there are other
things like this.
As above, I'm very much of the opposite view, I think we want to promote this,
not remove it. Yes, you can emulate overrides with other forms of variable access
but that really isn't how the system was designed to be used.

Cheers,

Richard


Re: Should we change variable override formatting?

Mark Hatle
 

On 7/16/21 11:28 AM, Richard Purdie wrote:
On Fri, 2021-07-16 at 14:35 +0000, Peter Kjellerstedt wrote:
(trimmed to add a minor comment)

As to RDEPENDS_${PN} & co, wouldn't it make sense to use RDEPENDS_pn-${PN},
since "pn-<package name>" already exists as an override? 
PN is really badly named since it is effectively the recipe name in many 
contexts. We're specifying one single thing in overrides with it rather than
a suite of packages a recipe generates. I can't see how using pn- like that
would work for the use cases we have for the package name override.
In this case ${PN} is just a name. It's because PACKAGES contains ${PN} by default.

Really it's RDEPENDS_<package>. Which is distinctly different then
RDEPENDS_pn-${PN} which is 'RDEPENDS' when evaluated.

I know minor distinction, but this is why I don't advocate treating RDEPENDS
(and other package specific variables) as overrides, but instead think of this
as RDEPENDS_<package>_<operation/override>...

So with proposed syntax becomes RDEPENDS_<package>:operation/override

On that note,
I would like to see overrides being prefixed more (maybe even as a
requirement). Some suggestions:

pn- - Package name
df- - Distro feature
mf- - Machine feature
pf- - Package feature (can we rename/alias PACKAGECONFIG to
          PACKAGE_FEATURES while at it, for consistency?)
arch- - Architecture
dist- - Distribution

That way it would be more obvious what an override does. Especially the
use of the distro name as an override can have some unforeseen consequences
if the name is somewhat common).
We have tried to do this with newer overrides where it makes sense. It is 
a tradeoff between longer names and usability. I don't think adding something
for the package name would help. Having "distro-" and "machine-" could
help in some cases but it comes at the price of more complicated conversions
and it becomes a question of whether things become more readable. Worth thinking
about but the above list doesn't really make sense since features are in overrides.
I've definitely run into problems where distro name or machine name collided
with a different override in the past and took a long time for me to realize the
clash was happening and thus the wrong variables were being evaluated.

--Mark

(PACKAGECONFIG should really be RECIPE_FEATURES if we're going to talk names!)

Cheers,

Richard








Re: Should we change variable override formatting?

Richard Purdie
 

Just to update, I have an experiment:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=rpurdie/overrides-convert

This contains a conversion script which can convert poky to use ":" 
instead of "_" as the override character (i.e. all of oe-core, meta-yocto, 
docs and bitbake inc. tests). I had to add in only two special hand cases
to the conversion code which is better than I expected (so far).

There is also a quick hack to make bitbake use the new override format 
(but no optimisation to the code) and a commit showing the result of the 
conversion.

Right now, this will successfully "bitbake -p", i.e. it parses. It will
even run a build but crashes out in gcc-cross do_compile.

You can see from the diff it generates, it isn't perfect and there are 
issues. At this point I should probably step back and finish the "diff"
tool I started a while ago so that we can compare to different builds,
see if (well, where!) the resulting output as parsed is different.

The point of this is to:

a) see if automated conversion is viable
b) see if the proposed syntax looks/feels better
c) allow experiments on things like performance to be made if I can
figure out where the differences are in the conversion and get builds working
d) if it can work, we could experiment further and see if there are follow
up improvements that can be based on this such as my previous experiments
with defval

So this is known to be rather rough and ready, it is very much experimental 
and brainstorming but probably worth sharing for anyone wanting to experiment.

Cheers,

Richard


Re: Should we change variable override formatting?

Mark Hatle
 

On 7/16/21 4:22 AM, Richard Purdie wrote:
On Thu, 2021-07-15 at 09:26 -0500, Mark Hatle wrote:

On 7/15/21 8:56 AM, Richard Purdie wrote:
Breaking things down a bit, one thing I keep running into with our current 
codebase and metadata is that overrides are not clear. In my previous email,
the example was:

do_configure_class-native

A human can usually spot "class-native" is and "configure" or 
"configure_class-native" is not. Bitbake's parser struggles. It has huge 
internal lists including variables like x86_64 where it has to track 
whether "64" in an override.

One way of fixing this is to be explicit about overrides and use a different 
separator. See an example patch below I made to the quilt recipe using ":" 
instead to see how it looks. Personally, I think this looks like an improvement.

There are two challenges:

a) The work of migration. Do we migrate piecemeal or with a flag day? I'm not
   sure piecemeal is even possible unfortunately.

b) Some of the packaging code (at the very least) needs rewriting as it accesses
   both RDEPENDS_${PN} and puts ${PN} in OVERRIDES and accesses RDEPENDS. I'm not
   sure what else may be assuming this works.
Ya, this is all over the packaging code. Should be trivial to move to treating
it as a variable (and not override). I can help with this if you want.
I've been pondering this a bit more and my preference is to move this to use 
overrides more explicitly.
The part of the code I worked on, the override was used as an optimization to avoid:

d.getVar("RDEPENDS_%s" % package) or d.getVar("RDEPENDS")

(and similar for all of the other variables that could be package specific.)

Overrides (at least to me) are system (or at least recipe) wide settings that
allow you to 'override' key things. The package items, based on that definitely
really aren't overrides -- they're package specific variables. (This is also
why I suggested RDEPENDS[package] might actually be a better syntax.)

What I did realise is that d.getVar("RDEPENDS:${PN}") can actually split out
the override itself and apply it so I think the existing code can be made to
work just with the character change if we teach getVar how to handle it which
should be possible.

(It can of course also be moved to overrides, but that won't be as obvious to a
recipe creator, since they're not used to the package name being an 'override'.)
Whilst the instinct is to "hide" that, perhaps it could also make overrides more
obvious since people could see them in a different setting more clearly? I think
that is where I'm leaning right now.
I'm all for making override usage more clear to people. But in this ONE case, I
don't think these are really overrides -- and worse they could cause confusion
because they are ONLY overrides when packaging. So if you use the override
chunk in something that doesn't affect a package specific setting it won't do
anything. It also won't do anything on the functions (I think), as those are
run before the override is loaded.

Specific code I'm talking about BTW is:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/package_rpm.bbclass

starting at line 287. (srcname is PN-src BTW)

then the loop starting at 328. Iterates over PACKAGES and sets the override one
at a time to the package name to get (conffiles, dirnames, summary/description,
pkgv, pkgr, pkge, license, section, description, rdepends, rrecommends,
rsuggests, rprovides, rreplaces, rconflicts, and I suspect a few others...)

Note, I could make the above changes pretty quickly and just submit this as an
implementation change in a few hours. I'd be happy to do that and look for
other 'in-place' usages of d.setVar("OVERRIDE"... to see if there are other
things like this.

This change does buy us cleaner looking metadata and ultimately, a faster
and cleaner internal bitbake that at least would use less memory. It could set
the stage to allow the defval idea I mentioned in a previous mail to happen.

It is a huge change and would need a lot of work to make it happen. Is it worth 
doing? Not sure. I'm putting it out there for discussion.
Is this something we do in parallel with master, and then flag day it? I could
easily see this work take a few weeks (if a bunch of people help).
I think we might be able to block convert much of the metadata with some kind of 
script. If that is possible, we'd have a flag day and a bunch of code tested in 
parallel before a final semi-automated conversion.
Agreed. I'd expect a 90+% success rate on a conversion.

It is also going to be tempting that "if we're breaking things, lets break lots".
I want to be mindful that tempting as that may be, if users can't convert clearly,
it will be worlds of pain. The benefit of this change is that at least in the
general case, the transition should be clear. Taking steps rather than changing the
world may therefore be a better idea...
One of those things (variable syntax) I'm not sure 'steps' make sense. If we're
changing a fundamental syntax, it really becomes a new major version of bitbake
and thus a new version of OE.
Having lots of things change at once may make things much harder for layer maintainers
than having a controlled change to handle though?
(been reading the other replies)

I don't have a great answer to this except for personal experience. I greatly
prefer [when things pass a compatibility point] to maintain multiple layers. If
we make the conversion script? available to layer maintainers, then it becomes
easier for them to transition. Yes, there is absolutely still work if they have
to maintain multiple branches.


 EXTRA_OECONF = "--with-perl='${USRBINPATH}/env perl' --with-patch=patch"
-EXTRA_OECONF_append_class-native = " --disable-nls"
+EXTRA_OECONF:append:class-native = " --disable-nls"
So operations (append) and overrides would both be delimited by ':'? It keeps
the ordering and makes it easier to read for sure, but I'm wondering if we need
to deliminate the operation differently. (No I have no suggestions, just a
thought. I don't object to the proposal at all.)
I wondered but this kind of felt neatest to me and it does work nicely with
the code backend handling it...



-RDEPENDS_${PN}-ptest = "make file sed gawk diffutils findutils ed perl \
+RDEPENDS:${PN}-ptest = "make file sed gawk diffutils findutils ed perl \
                         perl-module-filehandle perl-module-getopt-std \
                         perl-module-posix perl-module-file-temp \
                         perl-module-text-parsewords perl-module-overloading \
The above would work without code changes to the packaging class, but maybe we
really should make the change for readability. (I've often wondered if it
really should use 'flag' syntax instead, but lack of overrides make flag syntax
difficult to use.)

i.e.:

-FILES_${PN} = "${sysconfdir} ${datadir}/quilt \
+FILES[${PN}] = "${sysconfdir} ${datadir}/quilt \

or maybe something like? (This is a larger syntax change though)

-RDEPENDS_${PN} = "bash patch diffstat bzip2 util-linux less"
-RDEPENDS_${PN}_class-native = "diffstat-native patch-native bzip2-native"
+RDEPENDS[${PN}] = "bash patch diffstat bzip2 util-linux less"
+RDEPENDS[${PN}]:class-native = "diffstat-native patch-native bzip2-native"
'flags' in bitbake are really a poor cousin to the main variables and behave 
quite differently. Whether flags should have override support is a different 
question. It would hugely complicate the datastore code and I'm not sure the
above is more readable compared to the simpler ":". I've always seen flags as
supplemental data for a variable rather than anything like the above.
This change would certainly allow flags to more easily have overrides as you
avoid the multiple "_" is it a literal _ or an override deliminator. But
supporting future override of flags would be possible -- I the more I think
about this, the more I agree that is a bad idea for a first pass at this.

So I amend what I said above to say, avoid flags and my suggestion would be
(because I don't like package name as an override):

-RDEPENDS_${PN} = "bash patch diffstat bzip2 util-linux less"
-RDEPENDS_${PN}_class-native = "diffstat-native patch-native bzip2-native"
+RDEPENDS_${PN} = "bash patch diffstat bzip2 util-linux less"
+RDEPENDS_${PN}:class-native = "diffstat-native patch-native bzip2-native"

With the limited number of variables that are used by "package" implementation
today, it should be easy to teach the conversion script to NOT convert
RDEPENDS_first_second_third_fourth to RDEPENDS:first, unless first is an
operation (append, prepend, etc.. which it really shouldn't be!)

--Mark

Cheers,

Richard


Re: Should we change variable override formatting?

Richard Purdie
 

On Fri, 2021-07-16 at 14:35 +0000, Peter Kjellerstedt wrote:

This is a long answer, and responding to multiple subjects that have been
brought up in the different threads, so please bear with me.

I would love to see improvements to the bitbake syntax when it comes to
overrides. Unfortunately, I do not see how I would be able to ever update
to said version if it is done as a flag day release. The way we work is
to have our layers compatible with the version of bitbake we are using
(currently Hardknott). Then I (who basically do all work to build our
layers with master of Poky) have a special adaptation layer where I add
bbappends and some occasional backported bbclass to make our layers work
with Poky master. This work runs in parallel with the normal recipe updates
that the developers do so that when a new major release of Poky is ready,
so are we. However, if we would have to use a whole different version of
all our recipes, there is no way this process would work, and I can't stop
the normal development for a flag day upgrade of Poky. :(

The way I see it can be done would involve supporting both syntaxes in
one LTS-release. In the next non-LTS release, the support for the old
syntax can be dropped. That way there is always an intermediate release
that one can update to, update one's own recipes and then proceed to the
latest release. This of course means that the Yocto Project cannot reap
the benefits of the new and improved syntax immediately, but would have
to hold off for one release. On the other hand, this would mean the
transitioning path for all users of the Yocto Project would be trivial
(for some definition of trivial), compared to a major PITA.

Now, I don't know if supporting both syntaxes at once is feasible given
some of the comments given in the thread. However, most of them seem
related to being able to drop support for the old syntax and thereby
gaining the expected improvements to the internal data, which would not
be a goal for the release that actually has to support both syntaxes.
Its goal is compatibility and a way forward.
I'm not sure it is going to be feasible to take two years to make this kind
of transition. I've been looking for alternatives and one possibility may be
semi-automated translation.

By that, I mean that if you have a script with some knowledge of the layer
it is translating, it appears from some quick tests locally that you can
automate translation of a layer. My test was with poky (so bitbake, oe-core, 
meta-yocto and even the docs).

The kind of knowledge a script needs is the names of the overrides in use
and also function names or named parameter which contain keywords like
"prepend", "append" and "remove". Once you prime it with that infomation,
which a layer maintainer should have a good idea of, the script seems to
be able to handle the bulk of translation.

Code speaks volumes so:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=rpurdie/overrides-convert

which has a script to translate poky, a commit of the translated content
and a patch to bitbake to make it use ":" instead of "_" for overrides.

I appreciate that translation like this isn't ideal, but it might just work
well enough for people to work with to allow us to move forward.

As to the actual syntax changes, one thing I would like to se is the
_append/_prepend/_remove operators actually turn into real operators.
I definitely do not want to see the same syntax for the operators as
for overrides (that is one of the most confusing things with the
current solution).
I very much want to improve things. The trouble is if we try and do too much 
at once, we'll lose the support of our users. There are several things we're
effectively trying to do:

a) Add more information to the metadata (which text *is* an override?)
b) Change the syntax to be more readable
c) Remove certain syntax/operations
d) Potentially change the behaviour of some of the syntax

In the original thread, I was mixing up several of these things. I've
tried to step back and try and just solve a) in a way we can agree on
as a first step. If we can't even do that...

Here is one suggestion:

PACKAGECONFIG_append = "foo" => PACKAGECONFIG{} .= "foo"
PACKAGECONFIG_append = " foo" => PACKAGECONFIG{} += "foo"
PACKAGECONFIG_prepend = "foo " => PACKAGECONFIG{} =. "foo"
PACKAGECONFIG_prepend = " foo " => PACKAGECONFIG{} =+ "foo"
PACKAGECONFIG_remove = "foo " => PACKAGECONFIG{} -= "foo"
How do you explain

PACKAGECONFIG{} += "foo"
vs
PACKAGECONFIG += "foo"

to a user? I suspect that is the kind of thing which will cause 
us problems.

[Just to be clear to everyone reading this, the problem is that .= and 
_append are not equivalent since the former applies to the default value, 
the latter to all possible values including overrides.]


PACKAGECONFIG_append_bar = "foo" => PACKAGECONFIG{bar} .= "foo"
PACKAGECONFIG_append_bar = " foo" => PACKAGECONFIG{bar} += "foo"
PACKAGECONFIG_prepend_bar = "foo " => PACKAGECONFIG{bar} =. "foo"
PACKAGECONFIG_prepend_bar = " foo " => PACKAGECONFIG{bar} =+ "foo"
PACKAGECONFIG_remove_bar = "foo " => PACKAGECONFIG{bar} -= "foo"

PACKAGECONFIG_append_bar_foo = "foo" => PACKAGECONFIG{bar&foo} .= "foo"
PACKAGECONFIG_append_bar_foo = " foo" => PACKAGECONFIG{bar&foo} += "foo"
PACKAGECONFIG_prepend_bar_foo = "foo " => PACKAGECONFIG{bar&foo} =. "foo"
PACKAGECONFIG_prepend_bar_foo = " foo " => PACKAGECONFIG{bar&foo} =+ "foo"
PACKAGECONFIG_remove_bar_foo = "foo " => PACKAGECONFIG{bar&foo} -= "foo"

This would not have a corresponding solution for, e.g.,
PACKAGECONFIG_bar_foo_append, but I actually think that is good.
Right, I think elsewhere I said this form was usually error prone 
and not correct. I was considering dropping it, *if* we can get to a point
where the parser can reliably detect it.

This would also allow for clearing out the pending appends for a
given override by doing:

PACKAGECONFIG{} = ""
I like this idea.

or:

PACKAGECONFIG{bar} = ""
However:

PACKAGECONFIG = "X"
PACKAGECONFIG_bar = ""

is a common usage.

And a totally different solution (and probably more controversial) would
be to add a more programmatical way to handle overrides, e.g.:

PACKAGECONFIG += "foo" if overrides("foo bar")

or:

if override("foo") && override("bar"): PACKAGECONFIG += "foo"

It doesn't help with whether the update to the variable is immediate or
deferred though.
I think these are getting too clever and steps too far beyond what
we can cope with both in bitbake and with the developers we have. I can't 
begin to think how these would work in the code :(.

As to RDEPENDS_${PN} & co, wouldn't it make sense to use RDEPENDS_pn-${PN},
since "pn-<package name>" already exists as an override? 
PN is really badly named since it is effectively the recipe name in many 
contexts. We're specifying one single thing in overrides with it rather than
a suite of packages a recipe generates. I can't see how using pn- like that
would work for the use cases we have for the package name override.

On that note,
I would like to see overrides being prefixed more (maybe even as a
requirement). Some suggestions:

pn- - Package name
df- - Distro feature
mf- - Machine feature
pf- - Package feature (can we rename/alias PACKAGECONFIG to
          PACKAGE_FEATURES while at it, for consistency?)
arch- - Architecture
dist- - Distribution

That way it would be more obvious what an override does. Especially the
use of the distro name as an override can have some unforeseen consequences
if the name is somewhat common).
We have tried to do this with newer overrides where it makes sense. It is 
a tradeoff between longer names and usability. I don't think adding something
for the package name would help. Having "distro-" and "machine-" could
help in some cases but it comes at the price of more complicated conversions
and it becomes a question of whether things become more readable. Worth thinking
about but the above list doesn't really make sense since features are in overrides.

(PACKAGECONFIG should really be RECIPE_FEATURES if we're going to talk names!)

Cheers,

Richard

361 - 380 of 1651