Index: stand/defaults/loader.conf =================================================================== --- stand/defaults/loader.conf +++ stand/defaults/loader.conf @@ -96,7 +96,7 @@ # 480p, 720p, 1080p, 2160p/4k, 5k, or specify # WidthxHeight (e.g. 1920x1080) #kernels="kernel kernel.old" # Kernels to display in the boot menu -kernels_autodetect="YES" # Auto-detect kernel directories in /boot +kernels_autodetect="strict" # Auto-detect kernel directories in /boot #loader_logo="orbbw" # Desired logo: orbbw, orb, fbsdbw, beastiebw, beastie, none #comconsole_speed="9600" # Set the current serial console speed #console="vidconsole" # A comma separated list of console(s) Index: stand/defaults/loader.conf.5 =================================================================== --- stand/defaults/loader.conf.5 +++ stand/defaults/loader.conf.5 @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 29, 2020 +.Dd December 10, 2020 .Dt LOADER.CONF 5 .Os .Sh NAME @@ -339,8 +339,13 @@ .Dq YES , attempt to auto-detect kernels installed in .Pa /boot . +If set to +.Dq STRICT , +loader will only attempt to auto-detect kernels in directory names starting +with +.Dq kernel . This is an option specific to the Lua-based loader. -It is not available in the default Forth-based loader. +It is not available in the Forth-based loader. .El .Sh FILES .Bl -tag -width /boot/defaults/loader.conf -compact Index: stand/lua/core.lua =================================================================== --- stand/lua/core.lua +++ stand/lua/core.lua @@ -201,6 +201,12 @@ core.cached_kernels = nil end +function core.doAutodetect() + local val = loader.getenv("kernels_autodetect") or "" + val = val:lower() + return val:match("yes") or val:match("strict") +end + function core.kernelList() if core.cached_kernels ~= nil then return core.cached_kernels @@ -208,7 +214,7 @@ local k = loader.getenv("kernel") local v = loader.getenv("kernels") - local autodetect = loader.getenv("kernels_autodetect") or "" + local autodetect = core.doAutodetect() local kernels = {} local unique = {} @@ -230,9 +236,9 @@ end -- Base whether we autodetect kernels or not on a loader.conf(5) - -- setting, kernels_autodetect. If it's set to 'yes', we'll add - -- any kernels we detect based on the criteria described. - if autodetect:lower() ~= "yes" then + -- setting, kernels_autodetect. If it's set to 'yes' or 'strict', we'll + -- add any kernels we detect based on the criteria described. + if not autodetect then core.cached_kernels = kernels return core.cached_kernels end @@ -247,6 +253,10 @@ goto continue end + if autodetect == "strict" and not file:match("^kernel.*") then + goto continue + end + if lfs.attributes(fname, "mode") ~= "directory" then goto continue end