Lines Matching +full:sub +full:- +full:modules
1 --
2 -- SPDX-License-Identifier: BSD-2-Clause
3 --
4 -- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5 -- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6 -- All rights reserved.
7 --
8 -- Redistribution and use in source and binary forms, with or without
9 -- modification, are permitted provided that the following conditions
10 -- are met:
11 -- 1. Redistributions of source code must retain the above copyright
12 -- notice, this list of conditions and the following disclaimer.
13 -- 2. Redistributions in binary form must reproduce the above copyright
14 -- notice, this list of conditions and the following disclaimer in the
15 -- documentation and/or other materials provided with the distribution.
16 --
17 -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 -- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 -- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 -- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 -- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 -- SUCH DAMAGE.
28 --
33 local modules = {}
35 -- Which variables we changed
37 -- Values to restore env to (nil to unset)
56 local MSG_MODLOADING = "Loading configured modules..."
64 -- MODULEEXPR should more or less allow the exact same set of characters as the
65 -- env_var entries in the pattern table. This is perhaps a good target for a
66 -- little refactoring.
67 local MODULEEXPR = '([%w%d-_.]+)'
70 local WORDEXPR = "([-%w%d][-%w%d_.]*)"
73 -- Entries that should never make it into the environment; each one should have
74 -- a documented reason for its existence, and these should all be implementation
75 -- details of the config module.
77 -- loader_conf_files should be considered write-only, and consumers
78 -- should not rely on any particular value; it's a loader implementation
79 -- detail. Moreover, it's not a particularly useful variable to have in
80 -- the kenv. Save the overhead, let it get fetched other ways.
85 -- Examine changed environment variables
89 -- This one doesn't need restored for some reason
94 -- This was overwritten by some action taken on the menu
95 -- most likely; we'll leave it be.
111 -- XXX This getEnv/setEnv should likely be exported at some point. We can save
112 -- the call back into loader.getenv for any variable that's been set or
113 -- overridden by any loader.conf using this implementation with little overhead
114 -- since we're already tracking the values.
131 -- Track the original value for this if we haven't already
139 -- name here is one of 'name', 'type', flags', 'before', 'after', or 'error.'
140 -- These are set from lines in loader.conf(5): ${key}_${name}="${value}" where
141 -- ${key} is a module name.
143 if modules[key] == nil then
144 modules[key] = {}
146 modules[key][name] = value
149 -- Escapes the named value for use as a literal in a replacement pattern.
150 -- e.g. dhcp.host-name gets turned into dhcp%.host%-name to remove the special
151 -- meaning.
165 local c = value:sub(i, i)
171 pval = pval .. value:sub(i + 1, i + 1)
178 if value:sub(i + 1, i + 1) == "{" then
179 -- Skip ${
184 -- Skip the $
187 vpat = "^([%w][-%w%d_.]*)"
229 -- str in this table is a regex pattern. It will automatically be anchored to
230 -- the beginning of a line and any preceding whitespace will be skipped. The
231 -- pattern should have no more than two captures patterns, which correspond to
232 -- the two parameters (usually 'key' and 'value') that are passed to the
233 -- process function. All trailing characters will be validated. Any $VALUE
234 -- token included in a pattern will be tried first with a quoted value capture
235 -- group, then a single-word value capture group. This is our kludge for Lua
236 -- regex not supporting branching.
237 --
238 -- We have two special entries in this table: the first is the first entry,
239 -- a full-line comment. The second is for 'exec' handling. Both have a single
240 -- capture group, but the difference is that the full-line comment pattern will
241 -- match the entire line. This does not run afoul of the later end of line
242 -- validation that we'll do after a match. However, the 'exec' pattern will.
243 -- We document the exceptions with a special 'groups' index that indicates
244 -- the number of capture groups, if not two. We'll use this later to do
245 -- validation on the proper entry.
246 --
254 -- module_load="value"
259 if modules[k] == nil then
260 modules[k] = {}
262 modules[k].load = v:upper()
266 -- module_name="value"
275 -- module_type="value"
284 -- module_flags="value"
293 -- module_before="value"
302 -- module_after="value"
311 -- module_error="value"
320 -- exec="command"
332 -- env_var="value" or env_var=[word|num]
334 name = "([%w][%w%d-_.]*)%s*",
371 for mod in blacklist_str:gmatch("[;, ]?([-%w_]+)[;, ]?") do
395 str = str .. "-t " .. v.type .. " "
410 -- XXX Temporary shim: don't break the boot if
411 -- loader hadn't been recompiled with this
412 -- function exposed.
450 -- We might have read in the whole file, this won't be needed any more.
467 -- is nextboot_enable set in nvstore?
479 -- We're done; nextboot is not enabled
487 -- Attempt to rewrite the first line and only the first line of the
488 -- nextboot_file. We overwrite it with nextboot_enable="NO", then
489 -- check for that on load.
490 -- It's worth noting that this won't work on every filesystem, so we
491 -- won't do anything notable if we have any errors in this process.
494 -- We need the trailing space here to account for the extra
495 -- character taken up by the string nextboot_enable="YES"
496 -- Or new end quotation mark lands on the S, and we want to
497 -- rewrite the entirety of the first line.
516 -- Module exports
519 -- The first item in every carousel is always the default item.
528 -- Returns true if we processed the file successfully, false if we did not.
529 -- If 'silent' is true, being unable to read the file is not considered a
530 -- failure.
557 -- Give local modules a chance to populate the config
558 -- environment.
584 -- silent runs will not return false if we fail to open the file
599 -- Offset by one, drats
633 local top_level = next(loaded_files) == nil -- Are we the top-level readConf?
636 -- The final value of loader_conf_files is not important, so just
637 -- clobber it here. We'll later check if it's no longer nil and process
638 -- the new value for files to read.
641 -- These may or may not exist, and that's ok. Do a
642 -- silent parse so that we complain on parse errors but
643 -- not for them simply not existing.
650 -- Going to process "loader_conf_files" extra-files
661 -- If product_vars is set, it must be a list of environment variable names
662 -- to walk through to guess product information. The order matters as
663 -- reading a config files override the previously defined values.
664 --
665 -- If product information can be guessed, for each product information
666 -- found, also read config files found in /boot/loader.conf.d/PRODUCT/.
684 -- Process "loader_conf_dirs" extra-directories
704 -- Always allow overriding with local config files, e.g.,
705 -- /boot/loader.conf.local.
715 -- other_kernel is optionally the name of a kernel to load, if not the default
716 -- or autoloaded default from the module_path
740 -- Strip the loaded kernel path from module_path. This currently assumes
741 -- that the kernel path will be prepended to the module_path when it's
742 -- found.
750 -- append default kernel name
760 -- kernel not set, try load from default module_path
765 -- Default kernel is loaded
773 -- Use our cached module_path, so we don't end up with multiple
774 -- automatically added kernel paths to our final module_path
781 -- first try load kernel with module_path = /boot/${kernel}
782 -- then try load with module_path=${kernel}
789 -- succeeded, add path to module_path
801 -- failed to load with ${kernel} as a directory
802 -- try as a file
834 -- Reload configuration
836 modules = {}
861 status = loadModule(modules, not config.verbose)
862 hook.runAll("modules.loaded")
867 if modules[modname] == nil then
868 modules[modname] = {}
869 elseif modules[modname].load == "YES" then
870 modules[modname].force = true
874 modules[modname].load = "YES"
875 modules[modname].force = true
880 if modules[modname] == nil then
882 elseif modules[modname].load ~= "YES" then
886 modules[modname].load = "NO"
887 modules[modname].force = nil
892 local mod = modules[modname]
907 modules = modules,
916 hook.registerType("modules.loaded")