[PATCH v8 4/8] env: Allow U-Boot scripts to be placed in a .env file

Tom Rini trini at konsulko.com
Tue Oct 19 16:25:29 CEST 2021


On Tue, Oct 19, 2021 at 08:11:08AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Tue, 19 Oct 2021 at 08:07, Tom Rini <trini at konsulko.com> wrote:
> >
> > On Mon, Oct 18, 2021 at 12:13:18PM -0600, Simon Glass wrote:
> >
> > > At present U-Boot environment variables, and thus scripts, are defined
> > > by CONFIG_EXTRA_ENV_SETTINGS. It is painful to add large amounts of text
> > > to this file and dealing with quoting and newlines is harder than it
> > > should be. It would be better if we could just type the script into a
> > > text file and have it included by U-Boot.
> > >
> > > Add a feature that brings in a .env file associated with the board
> > > config, if present. To use it, create a file in a board/<vendor>
> > > directory, typically called <board>.env and controlled by the
> > > CONFIG_ENV_SOURCE_FILE option.
> > >
> > > The environment variables should be of the form "var=value". Values can
> > > extend to multiple lines. See the README under 'Environment Variables:'
> > > for more information and an example. Note that environment variables may
> > > not end in + but can start with other strange characters, including
> > > underscore, comma and slash.
> > >
> > > In many cases environment variables need access to the U-Boot CONFIG
> > > variables to select different options. Enable this so that the environment
> > > scripts can be as useful as the ones currently in the board config files.
> > > This uses the C preprocessor, means that comments can be included in the
> > > environment using /* ... */
> > >
> > > Also support += to allow variables to be appended to. This is needed when
> > > using the preprocessor.
> > >
> > > Signed-off-by: Simon Glass <sjg at chromium.org>
> >
> > As much as I and others appreciate that you've written the parser here
> > in a classic UNIX tool, awk, since a lot of the problems also seem to
> > stem from having the parser be able to handle previously valid
> > environment variables, if this was written in Python say, would we have
> > this problem?
> 
> Well ideally I'd like to avoid Python in this case as it is in the
> compilation path. I am not sure yet what Wolfgang actually wants,
> apart from variable names ending with + which I would like to
> disallow.
> 
> So if we can clearly understand the goal, then we might be able to do
> it in awk, but, again, can we just disallow '+' in var names ?

If we say that everything that's valid in the environment today needs to
continue to be valid, so that includes '+' and only disallowing '=' and
NUL as Wolfgang has said, can you update the awk parser to handle it?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20211019/bc8405e4/attachment.sig>


More information about the U-Boot mailing list