aboutsummaryrefslogtreecommitdiff
path: root/stand/lua
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-10-04 22:41:43 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-10-04 22:41:43 +0000
commit546f18f3dadc50e6978e02b1479bc55cfa677094 (patch)
tree1864d146a41099c3745e2af8f2b9eb56bd40aed8 /stand/lua
parent3331a1d1737fb61f7026daf162bbbfd0d4a756d1 (diff)
downloadsrc-546f18f3dadc50e6978e02b1479bc55cfa677094.tar.gz
src-546f18f3dadc50e6978e02b1479bc55cfa677094.zip
lualoader: improve the design of the brand-/logo- mechanism
In the previous world order, any brand/logo was forced to pull in the drawer and call drawer.add{Brand,Logo} with the name their brand/logo is taking and a table describing it. In the new world order, these files just need to return a table that maps out graphics types to a table of the exact same format as what was previously being passed back into the drawer. The appeal here is not needing to grab a reference back to the drawer module and having a cleaner data-driven looking format for these. The format has been renamed to 'gfx-*' prefixes and each one can provide a logo and a brand. drawer.addBrand/drawer.addLogo will remain in place until FreeBSD 13, as there's no overhead to them and it's not yet worth the break in compatibility with any pre-existing brands and logos. Reviewed by: freqlabs MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24966
Notes
Notes: svn path=/head/; revision=366435
Diffstat (limited to 'stand/lua')
-rw-r--r--stand/lua/Makefile10
-rw-r--r--stand/lua/drawer.lua57
-rw-r--r--stand/lua/gfx-beastie.lua (renamed from stand/lua/logo-beastie.lua)54
-rw-r--r--stand/lua/gfx-beastiebw.lua (renamed from stand/lua/logo-beastiebw.lua)52
-rw-r--r--stand/lua/gfx-fbsdbw.lua (renamed from stand/lua/logo-fbsdbw.lua)42
-rw-r--r--stand/lua/gfx-orb.lua (renamed from stand/lua/logo-orb.lua)48
-rw-r--r--stand/lua/gfx-orbbw.lua (renamed from stand/lua/logo-orbbw.lua)46
7 files changed, 171 insertions, 138 deletions
diff --git a/stand/lua/Makefile b/stand/lua/Makefile
index 7bdcc3fee056..fe6fd6f63c8e 100644
--- a/stand/lua/Makefile
+++ b/stand/lua/Makefile
@@ -20,11 +20,11 @@ FILES= cli.lua \
drawer.lua \
hook.lua \
loader.lua \
- logo-beastie.lua \
- logo-beastiebw.lua \
- logo-fbsdbw.lua \
- logo-orb.lua \
- logo-orbbw.lua \
+ gfx-beastie.lua \
+ gfx-beastiebw.lua \
+ gfx-fbsdbw.lua \
+ gfx-orb.lua \
+ gfx-orbbw.lua \
menu.lua \
password.lua \
screen.lua
diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua
index 12a27bfda233..32483f1b424e 100644
--- a/stand/lua/drawer.lua
+++ b/stand/lua/drawer.lua
@@ -61,6 +61,35 @@ local function menuEntryName(drawing_menu, entry)
return entry.name
end
+local function processFile(gfxname)
+ if gfxname == nil then
+ return false, "Missing filename"
+ end
+
+ local ret = try_include('gfx-' .. gfxname)
+ if ret == nil then
+ return false, "Failed to include gfx-" .. gfxname
+ end
+
+ -- Legacy format
+ if type(ret) ~= "table" then
+ return true
+ end
+
+ for gfxtype, def in pairs(ret) do
+ if gfxtype == "brand" then
+ drawer.addBrand(gfxname, def)
+ elseif gfxtype == "logo" then
+ drawer.addLogo(gfxname, def)
+ else
+ return false, "Unknown graphics type '" .. gfxtype ..
+ "'"
+ end
+ end
+
+ return true
+end
+
local function getBranddef(brand)
if brand == nil then
return nil
@@ -70,7 +99,18 @@ local function getBranddef(brand)
-- Try to pull it in
if branddef == nil then
- try_include('brand-' .. brand)
+ local res, err = processFile(brand)
+ if not res then
+ -- This fallback should go away after FreeBSD 13.
+ try_include('brand-' .. brand)
+ -- If the fallback also failed, print whatever error
+ -- we encountered in the original processing.
+ if branddefs[brand] == nil then
+ print(err)
+ return nil
+ end
+ end
+
branddef = branddefs[brand]
end
@@ -86,7 +126,18 @@ local function getLogodef(logo)
-- Try to pull it in
if logodef == nil then
- try_include('logo-' .. logo)
+ local res, err = processFile(logo)
+ if not res then
+ -- This fallback should go away after FreeBSD 13.
+ try_include('logo-' .. logo)
+ -- If the fallback also failed, print whatever error
+ -- we encountered in the original processing.
+ if logodefs[logo] == nil then
+ print(err)
+ return nil
+ end
+ end
+
logodef = logodefs[logo]
end
@@ -364,6 +415,8 @@ drawer.default_bw_logodef = 'orbbw'
-- drawer module in case it's a filesystem issue.
drawer.default_fallback_logodef = 'none'
+-- These should go away after FreeBSD 13; only available for backwards
+-- compatibility with old logo- files.
function drawer.addBrand(name, def)
branddefs[name] = def
end
diff --git a/stand/lua/logo-beastie.lua b/stand/lua/gfx-beastie.lua
index 758cec4e91de..f88f8c8dd306 100644
--- a/stand/lua/logo-beastie.lua
+++ b/stand/lua/gfx-beastie.lua
@@ -27,33 +27,29 @@
-- $FreeBSD$
--
-local drawer = require("drawer")
-
-local beastie_color = {
-" \027[31m, ,",
-" /( )`",
-" \\ \\___ / |",
-" /- \027[37m_\027[31m `-/ '",
-" (\027[37m/\\/ \\\027[31m \\ /\\",
-" \027[37m/ / |\027[31m ` \\",
-" \027[34mO O \027[37m) \027[31m/ |",
-" \027[37m`-^--'\027[31m`< '",
-" (_.) _ ) /",
-" `.___/` /",
-" `-----' /",
-" \027[33m<----.\027[31m __ / __ \\",
-" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|",
-" \027[33m<----'\027[31m `--' `.__,' \\",
-" | |",
-" \\ / /\\",
-" \027[36m______\027[31m( (_ / \\______/",
-" \027[36m,' ,-----' |",
-" `--{__________)\027[m"
+return {
+ logo = {
+ graphic = {
+ " \027[31m, ,",
+ " /( )`",
+ " \\ \\___ / |",
+ " /- \027[37m_\027[31m `-/ '",
+ " (\027[37m/\\/ \\\027[31m \\ /\\",
+ " \027[37m/ / |\027[31m ` \\",
+ " \027[34mO O \027[37m) \027[31m/ |",
+ " \027[37m`-^--'\027[31m`< '",
+ " (_.) _ ) /",
+ " `.___/` /",
+ " `-----' /",
+ " \027[33m<----.\027[31m __ / __ \\",
+ " \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|",
+ " \027[33m<----'\027[31m `--' `.__,' \\",
+ " | |",
+ " \\ / /\\",
+ " \027[36m______\027[31m( (_ / \\______/",
+ " \027[36m,' ,-----' |",
+ " `--{__________)\027[m",
+ },
+ requires_color = true,
+ }
}
-
-drawer.addLogo("beastie", {
- requires_color = true,
- graphic = beastie_color,
-})
-
-return true
diff --git a/stand/lua/logo-beastiebw.lua b/stand/lua/gfx-beastiebw.lua
index 9e8f1310ef89..5895b2436542 100644
--- a/stand/lua/logo-beastiebw.lua
+++ b/stand/lua/gfx-beastiebw.lua
@@ -27,32 +27,28 @@
-- $FreeBSD$
--
-local drawer = require("drawer")
-
-local beastiebw = {
-" , ,",
-" /( )`",
-" \\ \\___ / |",
-" /- _ `-/ '",
-" (/\\/ \\ \\ /\\",
-" / / | ` \\",
-" O O ) / |",
-" `-^--'`< '",
-" (_.) _ ) /",
-" `.___/` /",
-" `-----' /",
-" <----. __ / __ \\",
-" <----|====O)))==) \\) /====|",
-" <----' `--' `.__,' \\",
-" | |",
-" \\ / /\\",
-" ______( (_ / \\______/",
-" ,' ,-----' |",
-" `--{__________)"
+return {
+ logo = {
+ graphic = {
+ " , ,",
+ " /( )`",
+ " \\ \\___ / |",
+ " /- _ `-/ '",
+ " (/\\/ \\ \\ /\\",
+ " / / | ` \\",
+ " O O ) / |",
+ " `-^--'`< '",
+ " (_.) _ ) /",
+ " `.___/` /",
+ " `-----' /",
+ " <----. __ / __ \\",
+ " <----|====O)))==) \\) /====|",
+ " <----' `--' `.__,' \\",
+ " | |",
+ " \\ / /\\",
+ " ______( (_ / \\______/",
+ " ,' ,-----' |",
+ " `--{__________)",
+ },
+ }
}
-
-drawer.addLogo("beastiebw", {
- graphic = beastiebw,
-})
-
-return true
diff --git a/stand/lua/logo-fbsdbw.lua b/stand/lua/gfx-fbsdbw.lua
index 46bfa2767a9f..c219934b4ad6 100644
--- a/stand/lua/logo-fbsdbw.lua
+++ b/stand/lua/gfx-fbsdbw.lua
@@ -27,27 +27,23 @@
-- $FreeBSD$
--
-local drawer = require("drawer")
-
-local fbsd_logo = {
-" ______",
-" | ____| __ ___ ___ ",
-" | |__ | '__/ _ \\/ _ \\",
-" | __|| | | __/ __/",
-" | | | | | | |",
-" |_| |_| \\___|\\___|",
-" ____ _____ _____",
-" | _ \\ / ____| __ \\",
-" | |_) | (___ | | | |",
-" | _ < \\___ \\| | | |",
-" | |_) |____) | |__| |",
-" | | | |",
-" |____/|_____/|_____/"
+return {
+ logo = {
+ graphic = {
+ " ______",
+ " | ____| __ ___ ___ ",
+ " | |__ | '__/ _ \\/ _ \\",
+ " | __|| | | __/ __/",
+ " | | | | | | |",
+ " |_| |_| \\___|\\___|",
+ " ____ _____ _____",
+ " | _ \\ / ____| __ \\",
+ " | |_) | (___ | | | |",
+ " | _ < \\___ \\| | | |",
+ " | |_) |____) | |__| |",
+ " | | | |",
+ " |____/|_____/|_____/",
+ },
+ shift = {x = 5, y = 4},
+ }
}
-
-drawer.addLogo("fbsdbw", {
- graphic = fbsd_logo,
- shift = {x = 5, y = 4},
-})
-
-return true
diff --git a/stand/lua/logo-orb.lua b/stand/lua/gfx-orb.lua
index 3fe265a31e43..1af8f9f96072 100644
--- a/stand/lua/logo-orb.lua
+++ b/stand/lua/gfx-orb.lua
@@ -27,30 +27,26 @@
-- $FreeBSD$
--
-local drawer = require("drawer")
-
-local orb_color = {
-" \027[31m``` \027[31;1m`\027[31m",
-" s` `.....---...\027[31;1m....--.``` -/\027[31m",
-" +o .--` \027[31;1m/y:` +.\027[31m",
-" yo`:. \027[31;1m:o `+-\027[31m",
-" y/ \027[31;1m-/` -o/\027[31m",
-" .- \027[31;1m::/sy+:.\027[31m",
-" / \027[31;1m`-- /\027[31m",
-" `: \027[31;1m:`\027[31m",
-" `: \027[31;1m:`\027[31m",
-" / \027[31;1m/\027[31m",
-" .- \027[31;1m-.\027[31m",
-" -- \027[31;1m-.\027[31m",
-" `:` \027[31;1m`:`",
-" \027[31;1m.-- `--.",
-" .---.....----.\027[m"
+return {
+ logo = {
+ graphic = {
+ " \027[31m``` \027[31;1m`\027[31m",
+ " s` `.....---...\027[31;1m....--.``` -/\027[31m",
+ " +o .--` \027[31;1m/y:` +.\027[31m",
+ " yo`:. \027[31;1m:o `+-\027[31m",
+ " y/ \027[31;1m-/` -o/\027[31m",
+ " .- \027[31;1m::/sy+:.\027[31m",
+ " / \027[31;1m`-- /\027[31m",
+ " `: \027[31;1m:`\027[31m",
+ " `: \027[31;1m:`\027[31m",
+ " / \027[31;1m/\027[31m",
+ " .- \027[31;1m-.\027[31m",
+ " -- \027[31;1m-.\027[31m",
+ " `:` \027[31;1m`:`",
+ " \027[31;1m.-- `--.",
+ " .---.....----.\027[m",
+ },
+ requires_color = true,
+ shift = {x = 2, y = 4},
+ }
}
-
-drawer.addLogo("orb", {
- requires_color = true,
- graphic = orb_color,
- shift = {x = 2, y = 4},
-})
-
-return true
diff --git a/stand/lua/logo-orbbw.lua b/stand/lua/gfx-orbbw.lua
index 0a8f6b832943..7cc8b1919b03 100644
--- a/stand/lua/logo-orbbw.lua
+++ b/stand/lua/gfx-orbbw.lua
@@ -27,29 +27,25 @@
-- $FreeBSD$
--
-local drawer = require("drawer")
-
-local orbbw = {
-" ``` `",
-" s` `.....---.......--.``` -/",
-" +o .--` /y:` +.",
-" yo`:. :o `+-",
-" y/ -/` -o/",
-" .- ::/sy+:.",
-" / `-- /",
-" `: :`",
-" `: :`",
-" / /",
-" .- -.",
-" -- -.",
-" `:` `:`",
-" .-- `--.",
-" .---.....----."
+return {
+ logo = {
+ graphic = {
+ " ``` `",
+ " s` `.....---.......--.``` -/",
+ " +o .--` /y:` +.",
+ " yo`:. :o `+-",
+ " y/ -/` -o/",
+ " .- ::/sy+:.",
+ " / `-- /",
+ " `: :`",
+ " `: :`",
+ " / /",
+ " .- -.",
+ " -- -.",
+ " `:` `:`",
+ " .-- `--.",
+ " .---.....----.",
+ },
+ shift = {x = 2, y = 4},
+ }
}
-
-drawer.addLogo("orbbw", {
- graphic = orbbw,
- shift = {x = 2, y = 4},
-})
-
-return true