Page MenuHomeFreeBSD

lualoader: add support for .lua configuration files
ClosedPublic

Authored by kevans on Feb 1 2021, 7:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 2:11 PM
Unknown Object (File)
Thu, Apr 11, 1:46 PM
Unknown Object (File)
Apr 4 2024, 2:33 AM
Unknown Object (File)
Apr 3 2024, 10:01 PM
Unknown Object (File)
Mar 15 2024, 2:55 PM
Unknown Object (File)
Mar 14 2024, 8:14 PM
Unknown Object (File)
Mar 14 2024, 8:14 PM
Unknown Object (File)
Mar 14 2024, 8:14 PM

Details

Summary

If a file is specified in loader_conf_files that ends in '.lua', lualoader
will now load and execute that file. These may be used in place of a
traditional loader.conf to use more complicated logic, where some values
may be set based on others or based on the environment that the C bits has
left us with.

Lua scripts are run in a limited environment. In particular, it does not get
access to any modules or, in-fact, anything except environment variable.

A config.buildenv hook has been added so that a local module can add
whatever it may need to to the environment.

When a global var is set in the lua script, it does not immediately alter
the loader environment. Instead, the script's environment is initially
empty and processed only if the whole script executes successfully.
Effectively, a lua configuration file either takes effect or it does not,
an error will not leave it in a half-baked state.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Feb 1 2021, 7:08 PM
stand/lua/config.lua
505

Is this comment outdated? It looks like the name portion is split out in the pattern table now.

stand/lua/config.lua
505

Whoops, indeed. :-) Will fix

A question on the man page. I did not find anything else.

stand/lua/loader.conf.lua.5
62

Do you want to markup the filename in this sentence?

I generally like this, but my lua fu is too low to give a meaningful review.

Manpage looks good, we can do the filename markup in a followup commit.

Minor nits, fixable when committing.

stand/lua/loader.conf.lua.5
54
62

My lua fu is better.
I approve.

This revision is now accepted and ready to land.May 10 2023, 4:00 PM
This revision was automatically updated to reflect the committed changes.
kevans marked an inline comment as done.