Page MenuHomeFreeBSD

D50963.diff
No OneTemporary

D50963.diff

diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua
--- a/stand/lua/drawer.lua
+++ b/stand/lua/drawer.lua
@@ -134,7 +134,14 @@
return def
end
-local function getBranddef(brand)
+function drawer.brands()
+ return next, branddefs, nil
+end
+function drawer.logos()
+ return next, logodefs, nil
+end
+
+function drawer.getBranddef(brand)
if brand == nil then
return nil
end
@@ -163,7 +170,7 @@
return branddef
end
-local function getLogodef(logo)
+function drawer.getLogodef(logo)
if logo == nil then
return nil
end
@@ -361,10 +368,10 @@
local y = tonumber(loader.getenv("loader_brand_y")) or
brand_position.y
- local branddef = getBranddef(loader.getenv("loader_brand"))
+ local branddef = drawer.getBranddef(loader.getenv("loader_brand"))
if branddef == nil then
- branddef = getBranddef(drawer.default_brand)
+ branddef = drawer.getBranddef(drawer.default_brand)
end
local graphic = branddef.ascii.image
@@ -397,20 +404,20 @@
local logo = loader.getenv("loader_logo")
local colored = color.isEnabled()
- local logodef = getLogodef(logo)
+ local logodef = drawer.getLogodef(logo)
if logodef == nil or logodef.ascii == nil or
(not colored and logodef.ascii.requires_color) then
-- Choose a sensible default
if colored then
- logodef = getLogodef(drawer.default_color_logodef)
+ logodef = drawer.getLogodef(drawer.default_color_logodef)
else
- logodef = getLogodef(drawer.default_bw_logodef)
+ logodef = drawer.getLogodef(drawer.default_bw_logodef)
end
-- Something has gone terribly wrong.
if logodef == nil then
- logodef = getLogodef(drawer.default_fallback_logodef)
+ logodef = drawer.getLogodef(drawer.default_fallback_logodef)
end
end
diff --git a/tools/boot/local.lua b/tools/boot/local.lua
new file mode 100644
--- /dev/null
+++ b/tools/boot/local.lua
@@ -0,0 +1,109 @@
+--
+-- Copyright (c) 2025 Kyle Evans <kevans@FreeBSD.org>
+--
+-- SPDX-License-Identifier: BSD-2-Clause
+--
+
+local drawer = require('drawer')
+local color = require('color')
+local core = require('core')
+local hook = require('hook')
+local menu = require('menu')
+
+for file, ftype in lfs.dir("/boot/lua") do
+ if ftype == lfs.DT_DIR or not file:match(".lua$") then
+ goto skip
+ end
+
+ if file:match("^logo-") then
+ file = file:sub(#"logo-" + 1)
+ file = file:sub(1, #file - #".lua")
+
+ assert(drawer.getLogodef(file))
+ elseif file:match("^brand-") then
+ file = file:sub(#"brand-" + 1)
+ file = file:sub(1, #file - #".lua")
+
+ assert(drawer.getBranddef(file))
+ elseif file:match("^gfx-") then
+ file = file:sub(#"gfx-" + 1)
+ file = file:sub(1, #file - #".lua")
+
+ print("Try: " .. file)
+
+ -- For gfx files, we'll try to get just one of them. We won't
+ -- assert because one's not required to specify both a brand and
+ -- a logo, but we'll assert that *something* was loaded.
+ local res, err = drawer.getLogodef(file)
+ if not res then
+ res = drawer.getBranddef(file)
+ end
+ if not res then
+ assert(false, err)
+ end
+ end
+
+ ::skip::
+end
+
+local known_brands = {}
+local known_logos = {}
+
+for name, def in drawer.brands() do
+ known_brands[#known_brands + 1] = name
+end
+for name, def in drawer.logos() do
+ known_logos[#known_logos + 1] = name
+end
+
+loader.setenv("loader_brand", known_brands[1])
+loader.setenv("loader_logo", known_logos[1])
+
+local dev_menu = {
+ entries = {
+ {
+ entry_type = core.MENU_RETURN,
+ name = "Back to main menu" .. color.highlight(" [Backspace]"),
+ },
+ {
+ entry_type = core.MENU_CAROUSEL_ENTRY,
+ carousel_id = "brands",
+ items = known_brands,
+ name = function(idx, choice, all_choices)
+ local ename = "Brand: "
+
+ ename = ename .. color.escapefg(color.GREEN) ..
+ choice .. color.resetfg()
+ return ename .. " (" .. idx .. " of " ..
+ #all_choices .. ")"
+ end,
+ func = function(_, choice)
+ loader.setenv("loader_brand", choice)
+ end,
+ },
+ {
+ entry_type = core.MENU_CAROUSEL_ENTRY,
+ carousel_id = "logos",
+ items = known_logos,
+ name = function(idx, choice, all_choices)
+ local ename = "Logo: "
+
+ ename = ename .. color.escapefg(color.GREEN) ..
+ choice .. color.resetfg()
+ return ename .. " (" .. idx .. " of " ..
+ #all_choices .. ")"
+ end,
+ func = function(_, choice)
+ loader.setenv("loader_logo", choice)
+ end,
+ },
+ },
+}
+
+-- Hijack the single user entry entirely, we won't be needing it.
+menu.welcome.all_entries.single_user = {
+ entry_type = core.MENU_SUBMENU,
+ name = color.highlight("D") .. "evelopment Menu",
+ submenu = dev_menu,
+ alias = {"d", "D"},
+}
diff --git a/tools/boot/lua-img.sh b/tools/boot/lua-img.sh
--- a/tools/boot/lua-img.sh
+++ b/tools/boot/lua-img.sh
@@ -8,6 +8,7 @@
exit 1
}
+scriptdir=$(realpath $(dirname "$0"))
dir=$1
cd $(make -V SRCTOP)
@@ -21,5 +22,6 @@
mtree -deUW -f etc/mtree/BSD.usr.dist -p ${dir}/usr
cd stand
make -j4 all install DESTDIR=${dir} NO_ROOT=t MK_LOADER_LUA=yes MK_FORTH=no MK_INSTALL_AS_USER=yes
+cp ${scriptdir}/local.lua ${dir}/boot/lua
mkdir -p ${dir}/boot/kernel
cp /boot/kernel/kernel ${dir}/boot/kernel

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 19, 1:16 AM (3 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36913617
Default Alt Text
D50963.diff (5 KB)

Event Timeline