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)
Fri, Nov 8, 4:33 AM
Unknown Object (File)
Tue, Nov 5, 9:55 AM
Unknown Object (File)
Tue, Oct 29, 12:49 PM
Unknown Object (File)
Mon, Oct 21, 8:21 PM
Unknown Object (File)
Fri, Oct 18, 8:02 AM
Unknown Object (File)
Thu, Oct 17, 7:55 AM
Unknown Object (File)
Wed, Oct 16, 2:13 AM
Unknown Object (File)
Tue, Oct 15, 11:03 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.