]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r357103-r357104: unbreak local.lua, add a modules.loaded hook
authorKyle Evans <kevans@FreeBSD.org>
Tue, 28 Jan 2020 02:42:33 +0000 (02:42 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 28 Jan 2020 02:42:33 +0000 (02:42 +0000)
commitff9e3f3b9667ec418c7ef27c27328d2f732fb2bb
treede66a85c18d9a5f095fdcfc26ae2d810374f8c14
parent067ee48a3244ca29dcd84cc3b8660b772f9442fb
MFC r357103-r357104: unbreak local.lua, add a modules.loaded hook

r357103:
loader.lua: re-arrange to load local.lua *after* config loading

The major problem with the current ordering is that loader.conf may contain
all of the magic we need to actually setup the console, so loading local.lua
prior to that can make it excessively difficult and annoying to debug
(whoops, sorry Ravi & Warner).

The new ordering has some implications, but I suspect they are a non-issue.
The first is that it's no longer possible for the local module to inject any
logic prior to loading config -- I suspect no one has relied on this. The
second implication is that the config.loaded hook is now useless, as the
local module will always be included after that hook would have fired.

For config.loaded, I will opt to leave it in, just in case we add an early
point for local lua to get injected or in case one wants to schedule some
deferred logic in a custom loader.lua. The overhead of having it if no hooks
will be invoked is relatively minimal.

r357104:
lua: add modules.loaded hook

This may be used for the local module to hook in and load any additional
modules that it wants, since it can't modify the modules table internal to
config. We may consider adding API to do so at a later time, but I suspect
it will be more complicated to use with little return.

status is captured but ignored for the purpose of loading the hook. status
will be false if *any* module failed to load, but we typically don't let
that halt the boot so there's no reason to let it halt hooks. Some vendors
or setups may have expected fails that would be actively thwarted by
checking it.

We may, at a later date, consider adding an API for letting non-config
modules check which modules have successfully (or not) loaded in case an
unexpected failure *should* halt whatever they are doing.
stand/lua/config.lua
stand/lua/loader.lua