1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-21 11:35:44 -05:00

Compare commits

...

6 Commits

Author SHA1 Message Date
XeonSquared
ff7ec50a94 add some simple minification filters to preproc, which can shrink the kernel significantly 2023-08-04 20:32:42 +10:00
XeonSquared
ad99c438b3 I keep forgetting that's there >.> 2023-08-04 20:31:22 +10:00
XeonSquared
2e021ff6d5 remove old rc.load implementation 2023-08-04 20:29:09 +10:00
XeonSquared
e9e824b42d remove unused include 2023-08-04 20:28:53 +10:00
XeonSquared
c0f8b9b900 attempt to load pkgfs if there's a package archive directory 2023-08-04 20:28:26 +10:00
XeonSquared
a33476cf00 fix edge case where io.open(whatever):read() returns nil 2023-08-04 20:24:18 +10:00
7 changed files with 36 additions and 26 deletions

View File

@ -1,4 +1,4 @@
local preproc = require "preproc"
--local tA = {...}
preproc.minify = true
preproc(...)

View File

@ -24,7 +24,7 @@ end
function mtar.iter(stream) -- table -- function -- Given buffer *stream*, returns an iterator suitable for use with *for* that returns, for each iteration, the file name, a function to read from the file, and the length of the file.
local remain = 0
local function read(n)
local rb = stream:read(math.min(n,remain))
local rb = stream:read(math.min(n,remain)) or ""
remain = remain - rb:len()
return rb
end

View File

@ -5,7 +5,7 @@ rc.paths = "/boot/service\n/pkg/service"
rc.pids = {}
local service = {}
local cfg = {}
cfg.enabled = {"getty","minitel"}
cfg.enabled = {"getty","minitel","fsmanager"}
local function loadConfig()
local f = io.open("/boot/cfg/rc.cfg","rb")
@ -37,26 +37,6 @@ function rc.load(name,force) -- string boolean -- table -- Attempts to load serv
return false, "unable to load service "..name
end
--[[
function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance.
if force then
rc.stop(name)
service[name] = nil
end
if service[name] then return true end
service[name] = setmetatable({},{__index=_G})
local f
f = io.open("/boot/service/"..name..".lua","rb")
if not f then
pcall(require,"pkgfs")
f = io.open("/pkg/service/"..name..".lua","rb")
end
local res = load(f:read("*a"),name,"t",service[name])()
f:close()
return res
end
]]
function rc.stop(name,...) -- string -- boolean string -- Stops service *name*, supplying *...* to the stop function. Returns false and a reason if this fails.
if not service[name] then return false, "service not found" end
if service[name].stop then

View File

@ -12,6 +12,9 @@ os.spawn(function()
end
os.setenv("HOSTNAME",hostname)
syslog(string.format("Hostname set to %s",hostname))
if fs.exists("/boot/pkg") then
pcall(require,"pkgfs")
end
local pids = {}
local rc = require "rc"
for k,v in pairs(rc.cfg.enabled) do

View File

@ -1,4 +1,3 @@
--#includepkglib "diskpart" "lib/part/mtpt.lua" "part/mtpt"
--#includepkglib "diskpart" "lib/diskpart.lua" "diskpart"
--#includepkglib "rtfs" "lib/rtfs.lua" "rtfs"
do

View File

@ -1,4 +1,3 @@
--#include "module/ocelot-debug.lua"
do
syslog = {}
syslog.emergency = 0

View File

@ -82,11 +82,40 @@ function preproc.directives.includepkglib(package, file, name) -- string string
return string.format("package.loaded['%s'] = (function()\n%s\nend)()", name, preproc.directives.includepkgfile(package, file))
end
local minify = true
local minifyFilters = {
{"%-%-%[%[.-%]%]",""},
{"%-%-.-\n","\n"},
{"\n[ \t]+","\n"},
{"%s?%.%.%s?",".."},
{"%s?==%s?","=="},
{"%s?~=%s?","~="},
{"%s?>=%s?",">="},
{"%s?<=%s?","<="},
{"%s?>%s?",">"},
{"%s?<%s?","<"},
{"%s?=%s?","="},
{"%s?,%s?",","},
{",\n",","},
{"\n\n+","\n"},
{"[ \t]\n","\n"},
{"%{%s+","{"},
{"%s+%}","}"}
}
return setmetatable(preproc,{__call=function(_,...)
local tA = {...}
local out = table.remove(tA,#tA)
local f,e = io.open(out,"wb")
if not f then error("unable to open file "..out..": "..e) end
f:write(preproc.preproc(table.unpack(tA)))
local out = preproc.preproc(table.unpack(tA))
if preproc.minify then
local olen = #out
for k,v in ipairs(minifyFilters) do
out = out:gsub(v[1],v[2])
end
print(olen, #out)
end
f:write(out)
f:close()
end})