[PATCH v3] libkas: check the layers availability when looking for init script

1 view
Skip to first unread message

Jose Quaresma

unread,
Sep 25, 2025, 11:40:02 AM (23 hours ago) Sep 25
to kas-...@googlegroups.com, Jose Quaresma
From: Jose Quaresma <jose.q...@oss.qualcomm.com>

We need to take into account whether the layers are disabled when we search
for the oe-init-build-env script.
If for some reason the layers are disabled it is because the user did it
explicitly and it is not possible to use the repository since without this
layers the present script doesn't make sense to use.

An example where this is necessary is when we use the nodistro as the base
configuration and want to override it with another configuration to use the poky.
Or vice versa.

nodistro.yml
bitbake:
layers:
.: disabled
oe-core:
layers:
meta:

poky.yml
oe-core:
layers:
meta: disabled
poky:
layers:
meta:
meta-poky:

- To build the nodistro the user uses the nodistro.yml which also contains the
remaining defined configuration.
- To use the poky distro the user will use the nodistro.yml:poky.yml which explicitly
disables the layer meta from the oe-core repo in the poky.yml and adds the poky layers.

In this case, with the configuration nodistro.yml:poky.yml, we have two repositories
providing the init script but in one of them all the layers were explicitly turned off.
We must use the script from the other repo, that does not have the all the layers turned off,
which in this case is poky repo.

Signed-off-by: Jose Quaresma <jose.q...@oss.qualcomm.com>
---

V3:
- check for any layer active to use the script of the repo
- log all founded scripts at debug level

kas/libkas.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kas/libkas.py b/kas/libkas.py
index 5327efb..753af72 100644
--- a/kas/libkas.py
+++ b/kas/libkas.py
@@ -285,8 +285,13 @@ def get_build_environ(build_system):
f'({repo.name} vs. {init_repo.name}). '
'Resolve ambiguity by removing one of the repos')

- init_repo = repo
- init_script = script
+ if repo._layers:
+ init_repo = repo
+ init_script = script
+ skip = ''
+ else:
+ skip = ', skipping it given that there are no active layers'
+ logging.debug(f'The init scripts "{script}" found on repo "{repo.name}"{skip}')
if not init_repo:
raise InitBuildEnvError('Did not find any init-build-env script')

--
2.51.0

Jan Kiszka

unread,
Sep 25, 2025, 12:10:06 PM (22 hours ago) Sep 25
to Jose Quaresma, kas-...@googlegroups.com, Jose Quaresma
Did you have a look at our test cases if we could enhance some of them
to cover something similar there, i.e. a repo with an init script but
now configured to not use it?
The logic looks good to me. But we should also document this behavior,
probably close to where we already describe the init script search
(build_system key), maybe with a reference from layers key description.

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Jose Quaresma

unread,
5:57 AM (5 hours ago) 5:57 AM
to Jan Kiszka, kas-...@googlegroups.com, Jose Quaresma
I can try to add something on the tests.
I added something for the documentation but I didn't fully understand what you
want in the "maybe with a reference from layers key description".
Can you please explain a little more what you mean?

Jose


Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center


--
Best regards,

José Quaresma

Jan Kiszka

unread,
7:01 AM (4 hours ago) 7:01 AM
to Jose Quaresma, kas-...@googlegroups.com, Jose Quaresma
On 26.09.25 11:56, Jose Quaresma wrote:
>
>
> Jan Kiszka <jan.k...@siemens.com <mailto:jan.k...@siemens.com>>
> escreveu (quinta, 25/09/2025 à(s) 17:10):
>
> On 25.09.25 17:38, Jose Quaresma wrote:
> > From: Jose Quaresma <jose.q...@oss.qualcomm.com
> <mailto:jose.q...@oss.qualcomm.com>>
> <mailto:jose.q...@oss.qualcomm.com>>
> > ---
> >
> > V3:
> > - check for any layer active to use the script of the repo
> > - log all founded scripts at debug level
> >
> >  kas/libkas.py | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/kas/libkas.py b/kas/libkas.py
> > index 5327efb..753af72 100644
> > --- a/kas/libkas.py
> > +++ b/kas/libkas.py
> > @@ -285,8 +285,13 @@ def get_build_environ(build_system):
> >                      f'({repo.name <http://repo.name>} vs.
> {init_repo.name <http://init_repo.name>}). '
> >                      'Resolve ambiguity by removing one of the repos')
> > 
> > -            init_repo = repo
> > -            init_script = script
> > +            if repo._layers:
> > +                init_repo = repo
> > +                init_script = script
> > +                skip = ''
> > +            else:
> > +                skip = ', skipping it given that there are no
> active layers'
> > +            logging.debug(f'The init scripts "{script}" found on
> repo "{repo.name <http://repo.name>}"{skip}')
> >      if not init_repo:
> >          raise InitBuildEnvError('Did not find any init-build-env
> script')
> > 
>
> The logic looks good to me. But we should also document this behavior,
> probably close to where we already describe the init script search
> (build_system key), maybe with a reference from layers key description.
>
>
> I added something for the documentation but I didn't fully understand
> what you
> want in the "maybe with a reference from layers key description".
> Can you please explain a little more what you mean?
>

The main description can go to "build_system" in
https://kas.readthedocs.io/en/latest/userguide/project-configuration.html#configuration-reference.
But the part about the "layers" dict, specifically "<layer-path>" should
point out again the impact of disabling all layers in a repo. Or set
some "see build_system" reference
Reply all
Reply to author
Forward
0 new messages