mirror of
https://linux.maple.camp/git/ahill/maplelinux-bootstrap.git
synced 2026-02-11 02:03:37 +00:00
Rewrote a good chunk of mapleconf to use liquid
This commit is contained in:
@@ -4,16 +4,16 @@
|
||||
| Automake | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| GNU bc | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| Berkeley Yacc | Public Domain | Public Domain | Free |
|
||||
| bzip2 | Julian R. Seward | Modified Zlib license | Free |
|
||||
| CMake | Kitware, Inc. and Contributors | BSD 3-Clause license | Free |
|
||||
| bzip2 | Julian R. Seward | Modified Zlib License | Free |
|
||||
| CMake | Kitware, Inc. and Contributors | BSD 3-Clause License | Free |
|
||||
| Coreutils | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| curl | Daniel Stenberg and many contributors | The curl license | Free |
|
||||
| Debian Almquist Shell | Various | Modified BSD 3-Clause license(?) *and* GNU General Public License version 3 | Slightly Copyleft |
|
||||
| curl | Daniel Stenberg and many contributors | The curl License | Free |
|
||||
| Debian Almquist Shell | Various | Modified BSD 3-Clause License(?) *and* GNU General Public License version 3 | Slightly Copyleft |
|
||||
| GNU Diffutils | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| Expat | Various | MIT License | Free |
|
||||
| GNU Find Utilities | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| Flex | Various | BSD 2-Clause license | Free |
|
||||
| fortune-mod | Various | BSD 4-Clause license | Free |
|
||||
| Flex | Various | BSD 2-Clause License | Free |
|
||||
| fortune-mod | Various | BSD 4-Clause License | Free |
|
||||
| gettext | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| git | Linus Torvalds and Contributors | GNU General Public License version 2 | Copyleft |
|
||||
| GNU Grep | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
@@ -21,15 +21,18 @@
|
||||
| GNU Gzip | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| initramfs-tools | Various | GNU General Public License version 2 | Copyleft |
|
||||
| kmod | Various | GNU Lesser General Public License version 2.1 | Copyleft |
|
||||
| libarchive | Tim Kientzle | Mostly BSD 2-Clause license | Free |
|
||||
| libcap | Andrew G. Morgan | BSD 3-Clause license *or* GNU General Public License version 2 | Slightly Copyleft |
|
||||
| libarchive | Tim Kientzle | Mostly BSD 2-Clause License | Free |
|
||||
| libcap | Andrew G. Morgan | BSD 3-Clause License *or* GNU General Public License version 2 | Slightly Copyleft |
|
||||
| libelf | Various | GNU General Public License version 2 *and* GNU Lesser General Public License version 3 | Copyleft |
|
||||
| LibreSSL | Various | Various | Free |
|
||||
| The GNU Portable Library Tool | Free Software Foundation, Inc. | GNU General Public License version 2 | Copyleft |
|
||||
| Limine | Mintsuki and Contributors | BSD 2-Clause license | Free |
|
||||
| Limine | Mintsuki and Contributors | BSD 2-Clause License | Free |
|
||||
| Linux | Linus Torvalds and Contributors | Mostly GNU General Public License version 2 with Linux Syscall Note | Copyleft |
|
||||
| liquid-lua | @chenxianyu2015 | BSD 2-Clause License | Free |
|
||||
| LLVM | Various | Mostly Apache License version 2.0 with LLVM exceptions | Free |
|
||||
| Lua | Lua.org, PUC-Rio | MIT License | Free |
|
||||
| Lua CJSON | Mark Pulford | MIT License | Free |
|
||||
| LuaDate | Thijs Schreijer | MIT License | Free |
|
||||
| LuaPosix | luaposix authors | MIT License | Free |
|
||||
| GNU m4 | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| GNU Make | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
@@ -38,9 +41,9 @@
|
||||
| muon | Stone Tickle and Contributors | GNU General Public License version 3 | Copyleft |
|
||||
| musl | Rich Felker and Contributors | Mostly MIT License | Slightly Copyright |
|
||||
| GNU nano | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| The Netwide Assembler | "The NASM Authors" | BSD 2-Clause license | Free |
|
||||
| The Netwide Assembler | "The NASM Authors" | BSD 2-Clause License | Free |
|
||||
| New Curses | Thomas E. Dickey and Free Software Foundation, Inc. | Modified MIT License | Free |
|
||||
| OpenRC | Roy Marples and the OpenRC authors | BSD 2-Clause license | Free |
|
||||
| OpenRC | Roy Marples and the OpenRC authors | BSD 2-Clause License | Free |
|
||||
| GNU patch | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| Perl | Larry Wall and others | GNU General Public License version 1 | Copyleft |
|
||||
| pkgconf | Various | ISC License | Free |
|
||||
@@ -48,7 +51,7 @@
|
||||
| GNU sed | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| GNU tar | Free Software Foundation, Inc. | GNU General Public License version 3 | Copyleft |
|
||||
| tinytoml | Fourier Transformer | MIT License | Free |
|
||||
| xz | Various | Mostly BSD 0-Clause license | Slightly Copyleft |
|
||||
| xz | Various | Mostly BSD 0-Clause License | Slightly Copyleft |
|
||||
| Zlib | Jean-loup Gailly and Mark Adler | Zlib License | Free |
|
||||
| Zsh | The Zsh development group | Mostly MIT License (Modern Variant) | Slightly Copyleft |
|
||||
|
||||
|
||||
@@ -44,8 +44,11 @@ Definitions:
|
||||
| `libtool` | Yes | Yes |
|
||||
| `limine` | Yes | Yes |
|
||||
| `linux` | Yes | Yes |
|
||||
| `liquid-lua` | Yes | Yes |
|
||||
| `llvm` | Yes | Yes |
|
||||
| `lua` | Yes | Yes |
|
||||
| `lua-cjson` | Yes | Yes |
|
||||
| `lua-date` | Yes | Yes |
|
||||
| `luaposix` | Yes | Yes |
|
||||
| `m4` | Yes | Yes |
|
||||
| `make` | Yes | Yes |
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<svg height="16" version="1.1" width="1024" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="black" height="100%" width="100%" />
|
||||
<rect fill="blue" height="10" width="519" x="3" y="3" />
|
||||
<rect fill="cornflowerblue" height="10" width="80" x="522" y="3" />
|
||||
<rect fill="white" height="10" width="399" x="602" y="3" />
|
||||
<rect fill="mediumpurple" height="10" width="0" x="1001" y="3" />
|
||||
<rect fill="indianred" height="10" width="20" x="1001" y="3" />
|
||||
<rect fill="blue" height="10" width="490" x="3" y="3" />
|
||||
<rect fill="cornflowerblue" height="10" width="75" x="493" y="3" />
|
||||
<rect fill="white" height="10" width="434" x="568" y="3" />
|
||||
<rect fill="mediumpurple" height="10" width="0" x="1002" y="3" />
|
||||
<rect fill="indianred" height="10" width="19" x="1002" y="3" />
|
||||
<rect fill="crimson" height="10" width="0" x="1021" y="3" />
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 512 B After Width: | Height: | Size: 512 B |
@@ -14,6 +14,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE. ]]
|
||||
|
||||
local liquid = require("liquid")
|
||||
local posix = require("posix")
|
||||
local tinytoml = require("tinytoml")
|
||||
|
||||
@@ -22,150 +23,6 @@ local config_path = "/etc/maple.toml"
|
||||
local sysroot = "/"
|
||||
local templates = "/usr/share/mapleconf"
|
||||
|
||||
local function tokenize_block(inner)
|
||||
local buffer = ""
|
||||
local escaped = false
|
||||
local quoted = false
|
||||
local tokens = {}
|
||||
|
||||
for char in inner:gmatch(".") do
|
||||
if escaped then
|
||||
buffer = buffer .. char
|
||||
escaped = false
|
||||
|
||||
elseif char == "\\" then
|
||||
if quoted then
|
||||
buffer = buffer .. char
|
||||
end
|
||||
|
||||
escaped = true
|
||||
|
||||
elseif quoted then
|
||||
buffer = buffer .. char
|
||||
|
||||
if char == "\"" then
|
||||
quoted = false
|
||||
table.insert(tokens, buffer)
|
||||
buffer = ""
|
||||
end
|
||||
|
||||
else
|
||||
if char:match("%s") then
|
||||
if #buffer > 0 then
|
||||
table.insert(tokens, buffer)
|
||||
buffer = ""
|
||||
end
|
||||
|
||||
elseif char == "\"" then
|
||||
buffer = buffer .. char
|
||||
quoted = true
|
||||
|
||||
else
|
||||
buffer = buffer .. char
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if #buffer > 0 then
|
||||
table.insert(tokens, buffer)
|
||||
end
|
||||
|
||||
return tokens
|
||||
end
|
||||
|
||||
-- Symbol Reference:
|
||||
-- {"if", condition, true, false} - Executes true if condition is "truthy" and false otherwise
|
||||
-- {"literal", string} - Writes `string` to the target
|
||||
-- {"string", string} - Format and write string to the target
|
||||
-- {"value", identifier} - Returns the value of the identifier
|
||||
|
||||
local function tokenize_template(raw)
|
||||
local current = 0
|
||||
local last = 0
|
||||
local literal = true
|
||||
local template = {}
|
||||
|
||||
while current do
|
||||
current = string.find(raw, "@", current + 1)
|
||||
|
||||
if current then
|
||||
-- TODO: What happens when a line ends with a backslash? ~ahill
|
||||
if raw:sub(current - 1, current - 1) ~= "\\" then
|
||||
if literal then
|
||||
table.insert(template, { "literal", string.sub(raw, last + 1, current - 1) })
|
||||
literal = false
|
||||
|
||||
else
|
||||
if current - last == 1 then
|
||||
table.insert(template, { "literal", "@" })
|
||||
|
||||
else
|
||||
local inner = raw:sub(last + 1, current - 1)
|
||||
|
||||
if inner:sub(1, 1) ~= "-" then
|
||||
local tokens = tokenize_block(inner)
|
||||
|
||||
print(#tokens)
|
||||
for _, v in ipairs(tokens) do
|
||||
print(v)
|
||||
if v == "nil" then
|
||||
table.insert(template, { "literal", "" })
|
||||
|
||||
elseif v:sub(1, 1) == "\"" and v:sub(-1, -1) == "\"" then
|
||||
table.insert(template, { "string", v:sub(2, -2) })
|
||||
|
||||
else
|
||||
table.insert(template, {"value", v})
|
||||
end
|
||||
end
|
||||
|
||||
-- ...
|
||||
end
|
||||
end
|
||||
literal = true
|
||||
end
|
||||
|
||||
last = current
|
||||
end
|
||||
|
||||
else
|
||||
table.insert(template, { "literal", string.sub(raw, last + 1) })
|
||||
last = current
|
||||
end
|
||||
end
|
||||
|
||||
return template
|
||||
end
|
||||
|
||||
local function render_template(source, target)
|
||||
local raw = source:read("*all")
|
||||
local result = ""
|
||||
local template = tokenize_template(raw)
|
||||
|
||||
for _, v in ipairs(template) do
|
||||
if v[1] == "literal" then
|
||||
result = result .. v[2]
|
||||
|
||||
elseif v[1] == "string" then
|
||||
result = result .. v[2]
|
||||
|
||||
elseif v[1] == "value" then
|
||||
if config[v[2]] then
|
||||
result = result .. config[v[2]]
|
||||
else
|
||||
print("Unable to locate " .. v[2])
|
||||
return
|
||||
end
|
||||
|
||||
else
|
||||
print("BUG: Symbol type " .. v[1] .. " was not recognized!")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
target:write(result)
|
||||
end
|
||||
|
||||
local function render_directory(stack)
|
||||
local path
|
||||
if #stack == 0 then
|
||||
@@ -200,7 +57,9 @@ local function render_directory(stack)
|
||||
if template then
|
||||
local target = io.open(sysroot .. fullpath, "w")
|
||||
if target then
|
||||
render_template(template, target)
|
||||
local context = liquid.InterpreterContext:new(config)
|
||||
local engine = liquid.Template:parse(template:read("*all"))
|
||||
target:write(engine:render(context))
|
||||
target:close()
|
||||
end
|
||||
template:close()
|
||||
|
||||
14
sources/liquid-lua/liquid-lua.spec
Normal file
14
sources/liquid-lua/liquid-lua.spec
Normal file
@@ -0,0 +1,14 @@
|
||||
# Maintainer: Alexander Hill <ahill@breadpudding.dev>
|
||||
SRC_HASH="1e7c9639f279794f14a16ffd47b95a1020a2c19bf4dfc611c68197055da07b23"
|
||||
SRC_NAME="liquid-lua"
|
||||
SRC_URL="https://github.com/3scale/liquid-lua/archive/refs/tags/v0.2.0.tar.gz"
|
||||
SRC_VERSION="0.2.0"
|
||||
|
||||
SRC_FILENAME="liquid-lua-$SRC_VERSION.tar.gz"
|
||||
|
||||
build() {
|
||||
tar xf ../$SRC_FILENAME
|
||||
cd liquid-lua-$SRC_VERSION/
|
||||
mkdir -p $TT_INSTALLDIR$TT_DATADIR/lua/5.5
|
||||
cp lib/liquid.lua $TT_INSTALLDIR$TT_DATADIR/lua/5.5/
|
||||
}
|
||||
15
sources/lua-cjson/lua-cjson.spec
Normal file
15
sources/lua-cjson/lua-cjson.spec
Normal file
@@ -0,0 +1,15 @@
|
||||
# Maintainer: Alexander Hill <ahill@breadpudding.dev>
|
||||
SRC_HASH="9e1fd46eced543b149f2b08703b0c0165619524f92d350a453e8c11e4fd089b0"
|
||||
SRC_NAME="lua-cjson"
|
||||
SRC_URL="https://github.com/openresty/lua-cjson/archive/refs/tags/2.1.0.9.tar.gz"
|
||||
SRC_VERSION="2.1.0.9"
|
||||
|
||||
SRC_FILENAME="lua-cjson-$SRC_VERSION.tar.gz"
|
||||
|
||||
build() {
|
||||
tar xf ../$SRC_FILENAME
|
||||
cd lua-cjson-$SRC_VERSION/
|
||||
make -j $TT_PROCS
|
||||
mkdir -p $TT_INSTALLDIR$TT_LIBDIR/lua/5.5
|
||||
cp cjson.so $TT_INSTALLDIR$TT_LIBDIR/lua/5.5/
|
||||
}
|
||||
16
sources/lua-date/lua-date.spec
Normal file
16
sources/lua-date/lua-date.spec
Normal file
@@ -0,0 +1,16 @@
|
||||
# Maintainer: Alexander Hill <ahill@breadpudding.dev>
|
||||
SRC_HASH="2c6a21fbc30191c94a40549cb8dda2623c3a4457ae92370b0e6be827ea6845b0"
|
||||
SRC_NAME="lua-date"
|
||||
SRC_URL="https://github.com/Tieske/date/archive/refs/tags/version_2.2.1.tar.gz"
|
||||
SRC_VERSION="2.2.1"
|
||||
|
||||
SRC_FILENAME="lua-date-$SRC_VERSION.tar.gz"
|
||||
|
||||
# TODO: What is the best way to include documentation? ~ahill
|
||||
|
||||
build() {
|
||||
tar xf ../$SRC_FILENAME
|
||||
cd date-version_$SRC_VERSION/
|
||||
mkdir -p $TT_INSTALLDIR$TT_DATADIR/lua/5.5
|
||||
cp src/date.lua $TT_INSTALLDIR$TT_DATADIR/lua/5.5/
|
||||
}
|
||||
Reference in New Issue
Block a user