mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-21 11:35:44 -05:00
Compare commits
6 Commits
c2bbd7d2ca
...
ff7ec50a94
Author | SHA1 | Date | |
---|---|---|---|
|
ff7ec50a94 | ||
|
ad99c438b3 | ||
|
2e021ff6d5 | ||
|
e9e824b42d | ||
|
c0f8b9b900 | ||
|
a33476cf00 |
@ -1,4 +1,4 @@
|
||||
local preproc = require "preproc"
|
||||
--local tA = {...}
|
||||
|
||||
preproc.minify = true
|
||||
preproc(...)
|
||||
|
@ -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
|
||||
|
22
lib/rc.lua
22
lib/rc.lua
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,3 @@
|
||||
--#include "module/ocelot-debug.lua"
|
||||
do
|
||||
syslog = {}
|
||||
syslog.emergency = 0
|
||||
|
31
preproc.lua
31
preproc.lua
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user