mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-25 12:42:10 -05:00
Compare commits
No commits in common. "ff7ec50a94cfa036d1472a9bbb3b8e77d96e60b5" and "c2bbd7d2cad5c89a36a8abeb2f2c4feac68601c7" have entirely different histories.
ff7ec50a94
...
c2bbd7d2ca
@ -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)) or ""
|
||||
local rb = stream:read(math.min(n,remain))
|
||||
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","fsmanager"}
|
||||
cfg.enabled = {"getty","minitel"}
|
||||
|
||||
local function loadConfig()
|
||||
local f = io.open("/boot/cfg/rc.cfg","rb")
|
||||
@ -37,6 +37,26 @@ 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,9 +12,6 @@ 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,3 +1,4 @@
|
||||
--#includepkglib "diskpart" "lib/part/mtpt.lua" "part/mtpt"
|
||||
--#includepkglib "diskpart" "lib/diskpart.lua" "diskpart"
|
||||
--#includepkglib "rtfs" "lib/rtfs.lua" "rtfs"
|
||||
do
|
||||
|
@ -1,3 +1,4 @@
|
||||
--#include "module/ocelot-debug.lua"
|
||||
do
|
||||
syslog = {}
|
||||
syslog.emergency = 0
|
||||
|
31
preproc.lua
31
preproc.lua
@ -82,40 +82,11 @@ 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
|
||||
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:write(preproc.preproc(table.unpack(tA)))
|
||||
f:close()
|
||||
end})
|
||||
|
Loading…
Reference in New Issue
Block a user