scripts/oe-setup-builddir: migrate build/conf/templateconf.cfg to new template locations
PATCH 1/1 scripts/oe-setup-builddir: migrate build/conf/templateconf.cfg to new template locations
This is done only for default oe-core/poky templates; for anything else the locations themselves need to be migrated first, and there is no way to tell where they would be.
--- scripts/oe-setup-builddir | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/oe-setup-builddir +6 -0
@@ -40,6 +40,12 @@ cd "$BUILDDIR" if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") + # The following two are no longer valid; unsetting them will automatically get them replaced + # with correct ones. + if [ $TEMPLATECONF = "meta/conf" -o $TEMPLATECONF = "meta-poky/conf" ]; then + unset TEMPLATECONF + rm $BUILDDIR/conf/templateconf.cfg + fi fi . "$OEROOT"/.templateconf
Signature · 1 line
2.30.2
Quoted 21 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Alexander Kanavin
Sent: den 1 september 2022 16:23
To: [email protected]
Cc: Alexander Kanavin <[email protected]>
Subject: [OE-core] [PATCH]scripts/oe-setup-builddir: migrate build/conf/templateconf.cfg to new template locationsThis is done only for default oe-core/poky templates; for anything else the locations themselves need to be migrated first, and there is no way to tell where they would be.
Signed-off-by Alexander Kanavin <[email protected]>--- scripts/oe-setup-builddir | 6 ++++++ 1 file changed, 6 insertions(+)scripts/oe-setup-builddir +0
-0
scripts/oe-setup-builddir cd "$BUILDDIR" · line 48
Quoted 9 lines
scripts/oe-setup-builddir +6
-0@@ -40,6 +40,12 @@ cd "$BUILDDIR" if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") + # The following two are no longer valid; unsetting them will automatically get them replaced + # with correct ones. + if [ $TEMPLATECONF = "meta/conf" -o $TEMPLATECONF = "meta-poky/conf" ]; then + unset TEMPLATECONF + rm $BUILDDIR/conf/templateconf.cfg + fi
Since the test you added previously now requires that the path contains "/templates/", we might as well do this for any faulty configuration. I.e.:
# The path in $TEMPLATECONF must contain "/templates/". If it doesn't,
# unset it to have it replaced by a (hopefully) correct path.
case $TEMPLATECONF in
*/templates/*)
;;
*)
unset TEMPLATECONF
rm "$BUILDDIR/conf/templateconf.cfg"
;;
esacIf .templateconf hasn't been updated to comply with the new rules, the test later will point this out. But if it has been updated, the case statement above will avoid the problem of an old, non-complying configuration regardless of which layer it comes from.
Quoted 5 lines
scripts/oe-setup-builddir +0
-1fi . "$OEROOT"/.templateconf --2.30.2
//Peter
Quoted 14 lines · Peter Kjellerstedt
Since the test you added previously now requires that the path contains "/templates/", we might as well do this for any faulty configuration. I.e.:
# The path in $TEMPLATECONF must contain "/templates/". If it doesn't, # unset it to have it replaced by a (hopefully) correct path. case $TEMPLATECONF in */templates/*) ;; *) unset TEMPLATECONF rm "$BUILDDIR/conf/templateconf.cfg" ;; esac
Quoted 4 lines
If .templateconf hasn't been updated to comply with the new rules, the test later will point this out. But if it has been updated, the case statement above will avoid the problem of an old, non-complying configuration regardless of which layer it comes from.
.templateconf is not a universal file that can be placed into any layer, it is specific to poky/oe-core, as it is read from $OEROOT, which in turn is defined as location of oe-init-build-env.
So if the fixing up is made generic as suggested, it will only replace incorrect but at least helpful value of the original custom template location with the generic default template location in poky/core.
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Alex
Quoted 26 lines
-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: den 2 september 2022 06:32
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]; Alexander Kanavin <[email protected]>
Subject: Re: [OE-core] [PATCH]scripts/oe-setup-builddir: migrate build/conf/templateconf.cfg to new template locationsQuoted 2 lines · Peter Kjellerstedt
Since the test you added previously now requires that the path contains "/templates/", we might as well do this for any faulty configuration.
I.e.:
Quoted 12 lines
# The path in $TEMPLATECONF must contain "/templates/". If it doesn't, # unset it to have it replaced by a (hopefully) correct path. case $TEMPLATECONF in */templates/*) ;; *) unset TEMPLATECONF rm "$BUILDDIR/conf/templateconf.cfg" ;; esac
Quoted 8 lines
Quoted 4 lines
If .templateconf hasn't been updated to comply with the new rules, the test later will point this out. But if it has been updated, the case statement above will avoid the problem of an old, non-complying configuration regardless of which layer it comes from.
.templateconf is not a universal file that can be placed into any layer, it is specific to poky/oe-core, as it is read from $OEROOT, which in turn is defined as location of oe-init-build-env.
That assumption doesn't hold true. Our environment is set up to mimic Poky, but with extra layers and our own version of ".templateconf" (installed via a <copyfile> element in the repo manifest). So everything works and looks like Poky, except there are more layers available.
With my suggested change above the code just works, without any artificial limits such as only working for plain OE/Poky.
Quoted 3 lines
So if the fixing up is made generic as suggested, it will only replace incorrect but at least helpful value of the original custom template location with the generic default template location in poky/core.
The expectation is of course that if one has one's own .templateconf file, then it will of course have to be updated to match the changes in OE. Nothing unusual with that. But that is something I do as maintainer of our environment. For our developers it will then just work.
Quoted 8 lines
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Alex
//Peter
Quoted 5 lines · Peter Kjellerstedt
The expectation is of course that if one has one's own .templateconf file, then it will of course have to be updated to match the changes in OE. Nothing unusual with that. But that is something I do as maintainer of our environment. For our developers it will then just work.
Please consider that there are three different ways to obtain the location of the template, and they must all work. For those who have created a build/conf by supplying TEMPLATECONF on the command line or templateconf.cfg (which I would say is everyone, except you) the suggested code will only make things worse, not better. It would take wrong but helpful value in templateconf.cfg that points to a custom template, and replace it with meta/conf/templates/default, because that is what they have in .templateconf. Then all trace of where the template came from is lost.
And as discussed previously, you don't even need to jump through the extra hoops with generated template configurations to begin with, and can write the dynamically generated configs directly into build/conf.
Alex
Quoted 18 lines
-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: den 2 september 2022 17:09
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]; Alexander Kanavin <[email protected]>
Subject: Re: [OE-core] [PATCH]scripts/oe-setup-builddir: migrate build/conf/templateconf.cfg to new template locationsQuoted 5 lines · Peter Kjellerstedt
The expectation is of course that if one has one's own .templateconf file, then it will of course have to be updated to match the changes in OE. Nothing unusual with that. But that is something I do as maintainer of our environment. For our developers it will then just work.
Quoted 9 lines
Please consider that there are three different ways to obtain the location of the template, and they must all work. For those who have created a build/conf by supplying TEMPLATECONF on the command line or templateconf.cfg (which I would say is everyone, except you) the suggested code will only make things worse, not better. It would take wrong but helpful value in templateconf.cfg that points to a custom template, and replace it with meta/conf/templates/default, because that is what they have in .templateconf. Then all trace of where the template came from is lost.
Actually, that does not correspond to what the documentation says. The way we do things (i.e., modify .templateconf to define a default TEMPLATECONF) _is_ what the documentation says one should do. See:
https://docs.yoctoproject.org/dev/singleindex.html#creating-a-custom-template-configuration-directory
Also note that templateconf.cfg is not documented at all. My guess (based on the current code) is that it is only supposed to be used internally as a way to store the value of a previous build where TEMPLATECONF was explicitly set.
So based on the documentation, the officially supported ways to configure the template directory is to either specify TEMPLATECONF explicitly or by modifying .templateconf to set a default value.
That said, I do agree with your suggested change to prefer an explicitly set TEMPLATECONF before a value from templateconf.cfg, which also agrees with the idea that templateconf.cfg is only an internal way of storing the last TEMPLATECONF used.
Quoted 6 lines
And as discussed previously, you don't even need to jump through the extra hoops with generated template configurations to begin with, and can write the dynamically generated configs directly into build/conf.
Alex
//Peter
Quoted 3 lines · Peter Kjellerstedt
So based on the documentation, the officially supported ways to configure the template directory is to either specify TEMPLATECONF explicitly or by modifying .templateconf to set a default value.
Okay, I read that section, and I still think the requirement to have .templateconf next to oe-init-build-env makes it altogether impractical as a way to change the default from what poky/oe-core prescribes, unless you want to maintain yet another custom script doing non-standard magic before a build can start. I'm going to modify the section so that TEMPLATECONF passed in explicitly is emphasized as the standard method to set the template, and .templateconf is described as primarily a fallback to the standard core/poky template.
Maybe we can decouple .templateconf from oe-init-build-env but I don't know how.
Alex
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Alexander Kanavin via lists.openembedded.org
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Ok, the more I think about this, the more I'm convinced that oe-setup-builddir needs a complete refactor. Specifically:
1. Let's rewrite it in python; shell just isn't expressive or readable enough for what it needs to do.
2. Let's have a clear, logical priority order: TEMPLATECONF env var, build/conf/templateconf.cfg, dirname('oe-init-build-env') + '/.templateconf'
3. build/conf/templateconf.cfg becomes read-only; the final selected value for TEMPLATECONF is written into a separate file (for having a reference to where the configs came from).
4. oe-setup-builddir can also later be extended to support 'configuration fragments' management, see my email to oe-archtecture from yesterday.
It's just too late to do this in this release cycle, but worth looking into afterwards.
Alex
Quoted 11 lines · Alexander Kanavin
Quoted 5 lines · Alexander Kanavin via lists.openembedded.org
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Ok, the more I think about this, the more I'm convinced that oe-setup-builddir needs a complete refactor.
That script is meant to be really really simple and push any heavy lifting off to bitbake or other tools. Ideally we were never even meant to need such a script and the tools would "just work". I'd prefer it went away, not rewrite and grow it.
Cheers,
Richard
Quoted 6 lines · Richard Purdie
Quoted 6 lines
Quoted 5 lines
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Quoted 7 lines
Quoted 2 lines
Ok, the more I think about this, the more I'm convinced that oe-setup-builddir needs a complete refactor.
That script is meant to be really really simple and push any heavy lifting off to bitbake or other tools. Ideally we were never even meant to need such a script and the tools would "just work". I'd prefer it went away, not rewrite and grow it.
Rewriting it in python will make it twice (or more) shorter, and the order of templateconfs does need clarity and logic. We can leave the 'config fragments' or anything more advanced out.
Alex
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ok, I think I overstated things :) a couple of small targeted fixes incoming, no python rewrite.
Alex
Quoted 33 lines · Alexander Kanavin via lists.openembedded.org
Quoted 6 lines · Richard Purdie
Quoted 6 lines
Quoted 5 lines
We can however add a hint to check what is in build/conf/templateconf.cfg if the test fails, as it is not obvious that TEMPLATECONF obtained from there takes priority over other sources (which are, in order, TEMPLATECONF passed via environment, then .templateconf next to oe-init-build-env).
Quoted 7 lines
Quoted 2 lines
Ok, the more I think about this, the more I'm convinced that oe-setup-builddir needs a complete refactor.
That script is meant to be really really simple and push any heavy lifting off to bitbake or other tools. Ideally we were never even meant to need such a script and the tools would "just work". I'd prefer it went away, not rewrite and grow it.
Rewriting it in python will make it twice (or more) shorter, and the order of templateconfs does need clarity and logic. We can leave the 'config fragments' or anything more advanced out.
Alex
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#170238):
https://lists.openembedded.org/g/openembedded-core/message/170238
Mute This Topic: https://lists.openembedded.org/mt/93396426/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-