Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jan 2020 02:42:33 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r357191 - in stable: 11/stand/lua 12/stand/lua
Message-ID:  <202001280242.00S2gXOe046647@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Tue Jan 28 02:42:33 2020
New Revision: 357191
URL: https://svnweb.freebsd.org/changeset/base/357191

Log:
  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.

Modified:
  stable/11/stand/lua/config.lua
  stable/11/stand/lua/loader.lua
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/stand/lua/config.lua
  stable/12/stand/lua/loader.lua
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/stand/lua/config.lua
==============================================================================
--- stable/11/stand/lua/config.lua	Tue Jan 28 01:39:50 2020	(r357190)
+++ stable/11/stand/lua/config.lua	Tue Jan 28 02:42:33 2020	(r357191)
@@ -623,7 +623,7 @@ end
 function config.loadelf()
 	local xen_kernel = loader.getenv('xen_kernel')
 	local kernel = config.kernel_selected or config.kernel_loaded
-	local loaded
+	local loaded, status
 
 	if xen_kernel ~= nil then
 		print(MSG_XENKERNLOADING)
@@ -640,9 +640,12 @@ function config.loadelf()
 	end
 
 	print(MSG_MODLOADING)
-	return loadModule(modules, not config.verbose)
+	status = loadModule(modules, not config.verbose)
+	hook.runAll("modules.loaded")
+	return status
 end
 
 hook.registerType("config.loaded")
 hook.registerType("config.reloaded")
+hook.registerType("modules.loaded")
 return config

Modified: stable/11/stand/lua/loader.lua
==============================================================================
--- stable/11/stand/lua/loader.lua	Tue Jan 28 01:39:50 2020	(r357190)
+++ stable/11/stand/lua/loader.lua	Tue Jan 28 02:42:33 2020	(r357191)
@@ -42,14 +42,14 @@ local password = require("password")
 -- need it.
 local menu
 
-try_include("local")
-
 config.load()
+
 -- Our console may have been setup for a different color scheme before we get
 -- here, so make sure we set the default.
 if color.isEnabled() then
 	printc(color.default())
 end
+try_include("local")
 if not core.isMenuSkipped() then
 	menu = require("menu")
 end



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001280242.00S2gXOe046647>