All of lore.kernel.org
 help / color / mirror / Atom feed
* [yocto][bitbake] variable expansion in files
@ 2023-07-21  9:24 Yann CARDAILLAC Pro
  2023-07-21  9:39 ` [OE-core] " Ross Burton
  0 siblings, 1 reply; 3+ messages in thread
From: Yann CARDAILLAC Pro @ 2023-07-21  9:24 UTC (permalink / raw)
  To: openembedded-core; +Cc: mbadreau.ext, contact, ycardaillac.ext

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

Hi,

There's something that has always been missing in my experience of Yocto,
it's the ability to simply configure files with yocto variables.

Basically the idea is to have a class that will automatically sed all
variables from yocto inside a file using a delimiter, or to reuse the way
it is done with .wks.in with the ${var} syntax, even if I can already see
some limitations with shell scripts.

What I intend to do is to provide some variables to a recipe and then to
use them to complete a template.

For instance I'd like to put some stuff inside my machine.conf and want
those variables to be filled inside my templated script.

Is there any official way to do this?

As far as I can see there's not, the only examples I've found are using
hand made seds. But I might not be looking in the right place.

If I'm right, I'm wondering why this is not generalized inside a poky
class. I've found this meta :
https://github.com/coreycothrum/meta-bitbake-variable-substitution doing
exactly what I needed, but since it's not mainline I assume that as always
there's a good reason why it's not something you want to have in mainline.

If that's only because there wasn't any submission and If you're up for it
going mainline, I can work (with coreycothrum if he wants to?) it through
the patch submission process.

Best regards,

Yann CARDAILLAC,
--------------------------------------------------------------------------------------------------------------------
Embedded Linux Engineer
Embedded Systems, Computer Science & Electronics, @Polytech Sorbone
--------------------------------------------------------------------------------------------------------------------
Phone : +33669909858
--------------------------------------------------------------------------------------------------------------------
Linkedin : https://www.linkedin.com/in/yann-c-39b64012b/
Website: https://ycardaillac.fr

[-- Attachment #2: Type: text/html, Size: 2674 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OE-core] [yocto][bitbake] variable expansion in files
  2023-07-21  9:24 [yocto][bitbake] variable expansion in files Yann CARDAILLAC Pro
@ 2023-07-21  9:39 ` Ross Burton
       [not found]   ` <CALNokD5bzta0i9fy19hjAYi+1yNYm9wMn=w_Ngx4cgL5L5hZMw@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2023-07-21  9:39 UTC (permalink / raw)
  To: ycnakajsph; +Cc: OE-core, mbadreau.ext, contact, ycardaillac.ext

On 21 Jul 2023, at 10:24, Yann CARDAILLAC via lists.openembedded.org <ycnakajsph=gmail.com@lists.openembedded.org> wrote:
> There's something that has always been missing in my experience of Yocto, it's the ability to simply configure files with yocto variables.
> 
> Basically the idea is to have a class that will automatically sed all variables from yocto inside a file using a delimiter, or to reuse the way it is done with .wks.in with the ${var} syntax, even if I can already see some limitations with shell scripts.
> 
> What I intend to do is to provide some variables to a recipe and then to use them to complete a template. 
> 
> For instance I'd like to put some stuff inside my machine.conf and want those variables to be filled inside my templated script.
> 
> Is there any official way to do this?
> 
> As far as I can see there's not, the only examples I've found are using hand made seds. But I might not be looking in the right place.
> 
> If I'm right, I'm wondering why this is not generalized inside a poky class. I've found this meta : https://github.com/coreycothrum/meta-bitbake-variable-substitution doing exactly what I needed, but since it's not mainline I assume that as always there's a good reason why it's not something you want to have in mainline.
> 
> If that's only because there wasn't any submission and If you're up for it going mainline, I can work (with coreycothrum if he wants to?) it through the patch submission process.

There’s also a class that I hacked up a while ago that I never finished because I wanted to automatically handle variable dependencies, otherwise it’s no good:

https://github.com/rossburton/meta-ross/blob/master/classes/bbin.bbclass

I’d like to see something in core, but the scope should be relatively tight.  I don’t like the automatic expansion that meta-bitbake-variable-substitution does, I’m thinking of a pathological case where piglit wanted to use @@bindir@@ in a wrapper script: it would also attempt to process many gigabytes of installed files.

The bbin class _only_ works on files in SRC_URI, so foo.sh.bbin would be processed at do_unpack and end up in WORKDIR/foo.sh.  The scope is more limited but you know exactly what it’s doing.

Ross

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Fwd: [OE-core] [yocto][bitbake] variable expansion in files
       [not found]   ` <CALNokD5bzta0i9fy19hjAYi+1yNYm9wMn=w_Ngx4cgL5L5hZMw@mail.gmail.com>
@ 2023-07-21 11:12     ` Corey Cothrum
  0 siblings, 0 replies; 3+ messages in thread
From: Corey Cothrum @ 2023-07-21 11:12 UTC (permalink / raw)
  To: OE-core

[-- Attachment #1: Type: text/plain, Size: 3319 bytes --]

Can confirm that no attempt or submission was made to merge
meta-bitbake-variable-substitution into mainline/core. I'm happy if people
are finding it useful, but it was written very much for my use case(s). I
didn't spend much time designing it or thinking through how other people
may prefer it to work. Not to disparage it; I just mean to say there is
likely room for improvement.

Ross is also correct that automatic expansion shouldn't be the only mode of
operation. That's why meta-bitbake-variable-substitution has the option to
specify search and replace file paths:

${@bitbake_variables_search_and_sub("${PATH_OR_FILE_TO_PROCESS}",
r"${BITBAKE_VAR_SUB_DELIM}", d)}


I found cases where it was attempting variable substitution where I didn't
want it (e.g. when appending a recipe), and needed a method to be a bit
more surgical.

thanks,
Corey

On Fri, Jul 21, 2023 at 4:39 AM Ross Burton <Ross.Burton@arm.com> wrote:

> On 21 Jul 2023, at 10:24, Yann CARDAILLAC via lists.openembedded.org
> <ycnakajsph=gmail.com@lists.openembedded.org> wrote:
> > There's something that has always been missing in my experience of
> Yocto, it's the ability to simply configure files with yocto variables.
> >
> > Basically the idea is to have a class that will automatically sed all
> variables from yocto inside a file using a delimiter, or to reuse the way
> it is done with .wks.in with the ${var} syntax, even if I can already see
> some limitations with shell scripts.
> >
> > What I intend to do is to provide some variables to a recipe and then to
> use them to complete a template.
> >
> > For instance I'd like to put some stuff inside my machine.conf and want
> those variables to be filled inside my templated script.
> >
> > Is there any official way to do this?
> >
> > As far as I can see there's not, the only examples I've found are using
> hand made seds. But I might not be looking in the right place.
> >
> > If I'm right, I'm wondering why this is not generalized inside a poky
> class. I've found this meta :
> https://github.com/coreycothrum/meta-bitbake-variable-substitution doing
> exactly what I needed, but since it's not mainline I assume that as always
> there's a good reason why it's not something you want to have in mainline.
> >
> > If that's only because there wasn't any submission and If you're up for
> it going mainline, I can work (with coreycothrum if he wants to?) it
> through the patch submission process.
>
> There’s also a class that I hacked up a while ago that I never finished
> because I wanted to automatically handle variable dependencies, otherwise
> it’s no good:
>
> https://github.com/rossburton/meta-ross/blob/master/classes/bbin.bbclass
>
> I’d like to see something in core, but the scope should be relatively
> tight.  I don’t like the automatic expansion that
> meta-bitbake-variable-substitution does, I’m thinking of a pathological
> case where piglit wanted to use @@bindir@@ in a wrapper script: it would
> also attempt to process many gigabytes of installed files.
>
> The bbin class _only_ works on files in SRC_URI, so foo.sh.bbin would be
> processed at do_unpack and end up in WORKDIR/foo.sh.  The scope is more
> limited but you know exactly what it’s doing.
>
> Ross

[-- Attachment #2: Type: text/html, Size: 5260 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-21 11:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  9:24 [yocto][bitbake] variable expansion in files Yann CARDAILLAC Pro
2023-07-21  9:39 ` [OE-core] " Ross Burton
     [not found]   ` <CALNokD5bzta0i9fy19hjAYi+1yNYm9wMn=w_Ngx4cgL5L5hZMw@mail.gmail.com>
2023-07-21 11:12     ` Fwd: " Corey Cothrum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.