From a42d34f3afa113f759d386b0388ba99bcfa5d337 Mon Sep 17 00:00:00 2001 From: Alexander Hill Date: Fri, 30 Jan 2026 01:06:32 -0500 Subject: [PATCH] Converted mapleconf to Lua --- docs/SOFTWARE.md | 9 +- docs/STATUS.md | 7 +- docs/licensebar.svg | 12 +-- scripts/bootstrap.sh | 6 +- scripts/mapleconf | 149 +++++++++++++++++++++++++-------- scripts/rootbuild.sh | 4 +- sources/libffi/libffi.spec | 13 --- sources/libyaml/libyaml.spec | 13 --- sources/liquid/liquid.spec | 19 ----- sources/lua/lua.spec | 22 +++++ sources/luaposix/luaposix.spec | 19 +++++ sources/ruby/ruby.spec | 16 ---- sources/tinytoml/tinytoml.spec | 14 ++++ 13 files changed, 189 insertions(+), 114 deletions(-) delete mode 100644 sources/libffi/libffi.spec delete mode 100644 sources/libyaml/libyaml.spec delete mode 100644 sources/liquid/liquid.spec create mode 100644 sources/lua/lua.spec create mode 100644 sources/luaposix/luaposix.spec delete mode 100644 sources/ruby/ruby.spec create mode 100644 sources/tinytoml/tinytoml.spec diff --git a/docs/SOFTWARE.md b/docs/SOFTWARE.md index 779e325..8a410da 100644 --- a/docs/SOFTWARE.md +++ b/docs/SOFTWARE.md @@ -24,14 +24,13 @@ | 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 | -| libffi | Anthony Green, Red Hat, Inc and others | MIT License | Free | | LibreSSL | Various | Various | Free | -| libyaml | Ingy döt Net and Kirill Simonov | MIT License | 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 | | Linux | Linus Torvalds and Contributors | Mostly GNU General Public License version 2 with Linux Syscall Note | Copyleft | -| Liquid template engine | Tobias Luetke | MIT License | Free | | LLVM | Various | Mostly Apache License version 2.0 with LLVM exceptions | Free | +| Lua | Lua.org, PUC-Rio | 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 | | Maple Linux Bootstrap Scripts | Alexander Hill, Nicholas McDaniel, and Contributors | ISC License | Free | @@ -46,11 +45,11 @@ | Perl | Larry Wall and others | GNU General Public License version 1 | Copyleft | | pkgconf | Various | ISC License | Free | | Python | Python Software Foundation, BeOpen, and CWI | Python Software Foundation License Version 2 | Copyleft | -| Ruby | Various | Various | Mixed | | 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 | | Zlib | Jean-loup Gailly and Mark Adler | Zlib License | Free | | Zsh | The Zsh development group | Mostly MIT License (Modern Variant) | Slightly Copyleft | -If any of the information listed above is inaccurate, please send me an e-mail or submit a patch and it will be corrected. ~ahill \ No newline at end of file +If any of the information listed above is inaccurate, please send me an e-mail or submit a patch and it will be corrected. ~ahill diff --git a/docs/STATUS.md b/docs/STATUS.md index eea05a5..063062f 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -38,16 +38,15 @@ Definitions: | `libarchive` | Yes | Yes | | `libcap2` | Yes | Yes | | `libelf` | Yes | Yes | -| `libffi` | Yes | Yes | | `libmnl` | | `libnftnl` | | `libressl` | Yes | Yes | | `libtool` | Yes | Yes | -| `libyaml` | Yes | Yes | | `limine` | Yes | Yes | | `linux` | Yes | Yes | -| `liquid` | Yes | Yes | | `llvm` | Yes | Yes | +| `lua` | Yes | Yes | +| `luaposix` | Yes | Yes | | `m4` | Yes | Yes | | `make` | Yes | Yes | | `mawk` | Yes | Yes | @@ -64,10 +63,10 @@ Definitions: | `pkgconf` | Yes | Yes | | `pipewire` | | `python` | Yes | Yes | -| `ruby` | Yes | Yes | | `sed` | Yes | Yes | | `shadow` | | `tar` | Yes | Yes | +| `tinytoml` | | `xlibre-xserver` | | `xz` | Yes | Yes | | `zlib` | Yes | Yes | diff --git a/docs/licensebar.svg b/docs/licensebar.svg index 5aea0f6..55e06ff 100644 --- a/docs/licensebar.svg +++ b/docs/licensebar.svg @@ -1,9 +1,9 @@ - - - - - - + + + + + + diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 51e660b..108b292 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -232,7 +232,8 @@ for name in $SOURCES; do $TREETAP install $($TREETAP variable $SPEC/$name/$name.spec TT_PACKAGE) $BOOTSTRAP/root done -# Install Treetap +# Install Maple Linux Tools +cp $BOOTSTRAP/../scripts/mapleconf $BOOTSTRAP/root/bin/ cp $TREETAP $BOOTSTRAP/root/bin/ # Prepare for chroot build @@ -269,6 +270,8 @@ SOURCES=( limine linux llvm + lua + luaposix m4 make mawk @@ -284,6 +287,7 @@ SOURCES=( python sed tar + tinytoml xz zlib zsh diff --git a/scripts/mapleconf b/scripts/mapleconf index 68f6843..158bfe6 100755 --- a/scripts/mapleconf +++ b/scripts/mapleconf @@ -1,48 +1,129 @@ -#!/bin/ruby +#!/bin/lua -# Copyright (c) 2026 Alexander Hill +--[[ Copyright (c) 2026 Alexander Hill -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# 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. +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +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. ]] -require "liquid" -require "psych" +local posix = require("posix") +local tinytoml = require("tinytoml") -# TODO: Tie these variables to command line arguments. ~ahill -$config = Psych.safe_load_file "/etc/maple.yml" -$sysroot = "/" -$templates = "/usr/share/mapleconf" +-- TODO: Tie these variables to command line arguments. ~ahill +local config = tinytoml.parse("/etc/maple.toml") +local sysroot = "/" +local templates = "/usr/share/mapleconf" -def render_directory(stack) - path = stack.empty? ? "/" : "/#{stack.join "/"}/" +local function render_template(source, target) + -- Symbol Reference: + -- {"literal", string} - Writes `string` to the target + -- {"value", name} - Writes `config[name]` to the target + local raw = source:read("*all") + local result = "" + local template = {} - Dir.foreach $templates + path do |entry| - next if entry =~ /^\.+$/ - fullpath = path + entry + -- Tokenize the given template for easy processing later on ~ahill + local current = 0 + local last = 0 + local literal = true - if File.directory? $templates + fullpath - Dir.mkdir $sysroot + fullpath unless File.exist? $sysroot + fullpath - render_directory stack + [entry] + while current do + current = string.find(raw, "@", current + 1) - elsif File.file? $templates + fullpath - puts fullpath - template = Liquid::Template.parse(File.read $templates + fullpath) - File.write $sysroot + fullpath, template.render($config) + if current then + if literal then + table.insert(template, { "literal", string.sub(raw, last + 1, current - 1) }) + literal = false - else - puts "What even is #{fullpath}? If you know, yell at Alex." + else + if current - last == 1 then + table.insert(template, { "literal", "@" }) + else + table.insert(template, { "value", string.sub(raw, last + 1, current - 1) }) + end + literal = true + end + + else + table.insert(template, { "literal", string.sub(raw, last + 1) }) + end + + last = current end - end + + for _, v in ipairs(template) do + if v[1] == "literal" 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 value \"" .. v[2] .. "\"") + return + end + else + print("BUG: Symbol type " .. v[1] .. " was not recognized!") + return + end + end + + target:write(result) end -render_directory [] +local function render_directory(stack) + local path + if #stack == 0 then + path = "/" + else + path = "/" .. table.concat(stack, "/") .. "/" + end + + local files = posix.dir(templates .. path) + for _, entry in ipairs(files) do + if not string.match(entry, "^%.+$") then + local fullpath = path .. entry + + local stat = posix.stat(templates .. fullpath) + if stat.type == "directory" then + if not posix.access(sysroot .. fullpath) then + posix.mkdir(sysroot .. fullpath) + end + + local newstack = {} + -- Why does Lua lack the ability to copy tables? ~ahill + for _, v in ipairs(stack) do + table.insert(newstack, v) + end + table.insert(newstack, entry) + render_directory(newstack) + + elseif stat.type == "regular" then + print("Updating " .. fullpath) + + local template = io.open(templates .. fullpath, "r") + if template then + local target = io.open(sysroot .. fullpath, "w") + if target then + render_template(template, target) + target:close() + end + template:close() + end + + else + print("BUG: Directory entry type " .. stat.type .. " not recognized.") + end + end + end +end + +render_directory{} diff --git a/scripts/rootbuild.sh b/scripts/rootbuild.sh index 3233a66..b403397 100755 --- a/scripts/rootbuild.sh +++ b/scripts/rootbuild.sh @@ -64,10 +64,8 @@ echo "Done!" # NOTE: git requires curl, expat, and gettext to build. ~ahill # NOTE: Python requires bzip2, expat, LibreSSL, ncurses, xz, and zlib to build. ~ahill # NOTE: LLVM requires CMake and Python to build. ~ahill -# NOTE: Ruby requires autoconf, libffi, and libyaml to build. ~ahill -# NOTE: Liquid requires Ruby to build. ~ahill cd /maple -LAYER0="bc byacc bzip2 coreutils diffutils expat findutils grep gzip initramfs-tools libressl m4 make mawk muon musl ncurses patch perl pkgconf sed tar xz zlib zsh" +LAYER0="bc byacc bzip2 coreutils diffutils expat findutils grep gzip initramfs-tools libressl lua luaposix m4 make mawk muon musl ncurses patch perl pkgconf sed tar tinytoml xz zlib zsh" LAYER1="autoconf automake curl flex gettext groff libarchive libcap2 libelf libtool nano openrc python" LAYER2="cmake dash fortune-mod git kmod llvm nasm" LAYER3="limine linux" diff --git a/sources/libffi/libffi.spec b/sources/libffi/libffi.spec deleted file mode 100644 index 43a129b..0000000 --- a/sources/libffi/libffi.spec +++ /dev/null @@ -1,13 +0,0 @@ -# Maintainer: Alexander Hill -SRC_HASH="f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc" -SRC_NAME="libffi" -SRC_URL="https://github.com/libffi/libffi/releases/download/v3.5.2/libffi-3.5.2.tar.gz" -SRC_VERSION="3.5.2" - -build() { - tar xf ../$SRC_FILENAME - cd libffi-$SRC_VERSION/ - ./configure $TT_AUTOCONF_COMMON --disable-static - make -O -j $TT_PROCS - make -O -j $TT_PROCS install DESTDIR=$TT_INSTALLDIR -} \ No newline at end of file diff --git a/sources/libyaml/libyaml.spec b/sources/libyaml/libyaml.spec deleted file mode 100644 index 28ded2b..0000000 --- a/sources/libyaml/libyaml.spec +++ /dev/null @@ -1,13 +0,0 @@ -# Maintainer: Alexander Hill -SRC_HASH="c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4" -SRC_NAME="libyaml" -SRC_URL="https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz" -SRC_VERSION="0.2.5" - -build() { - tar xf ../$SRC_FILENAME - cd yaml-$SRC_VERSION/ - ./configure $TT_AUTOCONF_COMMON --disable-static - make -O -j $TT_PROCS - make -O -j $TT_PROCS install DESTDIR=$TT_INSTALLDIR -} \ No newline at end of file diff --git a/sources/liquid/liquid.spec b/sources/liquid/liquid.spec deleted file mode 100644 index 27eef11..0000000 --- a/sources/liquid/liquid.spec +++ /dev/null @@ -1,19 +0,0 @@ -# Maintainer: Alexander Hill -SRC_HASH="f3314240c846140d7be742e405882302f01dbecc51b8dd44d97cdad62d978f03" -SRC_NAME="liquid" -SRC_URL="https://github.com/Shopify/liquid/archive/refs/tags/v5.11.0.tar.gz" -SRC_VERSION="5.11.0" - -SRC_FILENAME="$SRC_NAME-$SRC_VERSION.tar.gz" - -build() { - tar xf ../$SRC_FILENAME - cd liquid-$SRC_VERSION/ - gem build liquid.gemspec - gem install \ - --install-dir $TT_INSTALLDIR/lib/ruby/gems/4.0.0 \ - --local \ - --ignore-dependencies \ - --verbose \ - ./liquid-$SRC_VERSION.gem -} \ No newline at end of file diff --git a/sources/lua/lua.spec b/sources/lua/lua.spec new file mode 100644 index 0000000..d4a1160 --- /dev/null +++ b/sources/lua/lua.spec @@ -0,0 +1,22 @@ +# Maintainer: Alexander Hill +SRC_HASH="57ccc32bbbd005cab75bcc52444052535af691789dba2b9016d5c50640d68b3d" +SRC_NAME="lua" +SRC_URL="https://lua.org/ftp/lua-5.5.0.tar.gz" +SRC_VERSION="5.5.0" + +build() { + tar xf ../$SRC_FILENAME + cd lua-$SRC_VERSION/ + # NOTE: Lua automatically assumes that GCC is installed, which is not the + # case here. CC is manually defined as a result. ~ahill + # TODO: Tweak luaconf.h to contain the correct directories. ~ahill + make -O -j $TT_PROCS CC=$CC + make -O -j $TT_PROCS install \ + INSTALL_BIN=$TT_INSTALLDIR$TT_BINDIR \ + INSTALL_CMOD=$TT_INSTALLDIR$TT_LIBDIR/lua/5.5 \ + INSTALL_INC=$TT_INSTALLDIR$TT_INCLUDEDIR \ + INSTALL_LIB=$TT_INSTALLDIR$TT_LIBDIR \ + INSTALL_LMOD=$TT_INSTALLDIR$TT_DATADIR/lua/5.5 \ + INSTALL_MAN=$TT_INSTALLDIR$TT_DATADIR/man/man1 \ + INSTALL_TOP=$TT_INSTALLDIR$TT_PREFIX +} diff --git a/sources/luaposix/luaposix.spec b/sources/luaposix/luaposix.spec new file mode 100644 index 0000000..f6cd681 --- /dev/null +++ b/sources/luaposix/luaposix.spec @@ -0,0 +1,19 @@ +# Maintainer: Alexander Hill +SRC_HASH="82cd9a96c41a4a3205c050206f0564ff4456f773a8f9ffc9235ff8f1907ca5e6" +SRC_NAME="luaposix" +SRC_URL="https://github.com/luaposix/luaposix/archive/refs/tags/v36.3.tar.gz" +SRC_VERSION="36.3" + +SRC_FILENAME="luaposix-$SRC_VERSION.tar.gz" + +build() { + tar xf ../$SRC_FILENAME + cd luaposix-$SRC_VERSION/ + ./build-aux/luke + ./build-aux/luke install PREFIX=$TT_INSTALLDIR + # NOTE: I may be wrong since I've never used it before, but it seems that + # "luke" doesn't install the library to the correct path, nor does it + # have an option to correct it. ~ahill + mkdir -p $TT_INSTALLDIR/usr + mv $TT_INSTALLDIR/share $TT_INSTALLDIR/usr/ +} diff --git a/sources/ruby/ruby.spec b/sources/ruby/ruby.spec deleted file mode 100644 index bdef6e7..0000000 --- a/sources/ruby/ruby.spec +++ /dev/null @@ -1,16 +0,0 @@ -# Maintainer: Alexander Hill -SRC_HASH="3924be2d05db30f4e35f859bf028be85f4b7dd01714142fd823e4af5de2faf9d" -SRC_NAME="ruby" -SRC_URL="https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.1.tar.gz" -SRC_VERSION="4.0.1" - -build() { - tar xf ../$SRC_FILENAME - cd ruby-$SRC_VERSION/ - # NOTE: Yes, Ruby has a configuration script already, but it lacks the - # --enable-year2038 option, so we rebuild it. ~ahill - ./autogen.sh - ./configure $TT_AUTOCONF_COMMON --enable-year2038 --without-gcc - make -O -j $TT_PROCS - make -O -j $TT_PROCS install DESTDIR=$TT_INSTALLDIR -} \ No newline at end of file diff --git a/sources/tinytoml/tinytoml.spec b/sources/tinytoml/tinytoml.spec new file mode 100644 index 0000000..d668eca --- /dev/null +++ b/sources/tinytoml/tinytoml.spec @@ -0,0 +1,14 @@ +# Maintainer: Alexander Hill +SRC_HASH="b806637ce2f79f80cc7a1920a13ba3fe8e6ed51202bcf54f90738d0ce808b201" +SRC_NAME="tinytoml" +SRC_URL="https://github.com/FourierTransformer/tinytoml/archive/refs/tags/1.0.0.tar.gz" +SRC_VERSION="1.0.0" + +SRC_FILENAME="tinytoml-$SRC_VERSION.tar.gz" + +build() { + tar xf ../$SRC_FILENAME + cd tinytoml-$SRC_VERSION/ + mkdir -p $TT_INSTALLDIR$TT_DATADIR/lua/5.5 + cp tinytoml.lua $TT_INSTALLDIR$TT_DATADIR/lua/5.5/ +}