svn commit: r331563 - head/stand/lua

Devin Teske dteske at freebsd.org
Tue Mar 27 00:25:39 UTC 2018


Woot!

That is all.
-- 
Devin

> On Mar 26, 2018, at 12:01 PM, Kyle Evans <kevans at FreeBSD.org> wrote:
> 
> Author: kevans
> Date: Mon Mar 26 19:01:22 2018
> New Revision: 331563
> URL: https://svnweb.freebsd.org/changeset/base/331563
> 
> Log:
>  lualoader: Implement try_include and use it for including the local module
> 
>  This provides a way to optionally include a module without having to wrap it
>  in filesystem checks. try_include is a little more robust, using the lua
>  search path instead of forcing us to explicitly consider all of the places
>  we could want to include a module. Errors are still generally raised from
>  trying to load the module, but ENOENT will not get raised unless we're doing
>  a verbose load.
> 
>  This will also be used to split out logo/brand graphics into their own files
>  so that we can safely scale up the number of graphics included without
>  worrying about the extra memory consumption- opting to lazily load graphics
>  instead.
> 
>  Reviewed by:	cem
>  Differential Revision:	https://reviews.freebsd.org/D14658
> 
> Modified:
>  head/stand/lua/core.lua
>  head/stand/lua/loader.lua
> 
> Modified: head/stand/lua/core.lua
> ==============================================================================
> --- head/stand/lua/core.lua	Mon Mar 26 18:39:38 2018	(r331562)
> +++ head/stand/lua/core.lua	Mon Mar 26 19:01:22 2018	(r331563)
> @@ -41,6 +41,26 @@ local function composeLoaderCmd(cmd_name, argstr)
> 	return cmd_name
> end
> 
> +-- Globals
> +-- try_include will return the loaded module on success, or nil on failure.
> +-- A message will also be printed on failure, with one exception: non-verbose
> +-- loading will suppress 'module not found' errors.
> +function try_include(module)
> +	local status, ret = pcall(require, module)
> +	-- ret is the module if we succeeded.
> +	if status then
> +		return ret
> +	end
> +	-- Otherwise, ret is just a message; filter out ENOENT unless we're
> +	-- doing a verbose load. As a consequence, try_include prior to loading
> +	-- configuration will not display 'module not found'. All other errors
> +	-- in loading will be printed.
> +	if config.verbose or ret:match("^module .+ not found") == nil then
> +		print(ret)
> +	end
> +	return nil
> +end
> +
> -- Module exports
> -- Commonly appearing constants
> core.KEY_BACKSPACE	= 8
> 
> Modified: head/stand/lua/loader.lua
> ==============================================================================
> --- head/stand/lua/loader.lua	Mon Mar 26 18:39:38 2018	(r331562)
> +++ head/stand/lua/loader.lua	Mon Mar 26 19:01:22 2018	(r331563)
> @@ -43,11 +43,7 @@ if not core.isMenuSkipped() then
> end
> local password = require("password")
> 
> -local result = lfs.attributes("/boot/lua/local.lua")
> --- Effectively discard any errors; we'll just act if it succeeds.
> -if result ~= nil then
> -	require("local")
> -end
> +try_include("local")
> 
> config.load()
> if core.isUEFIBoot() then
> 



More information about the svn-src-all mailing list