mirror of
https://github.com/Adorable-Catgirl/Zorya-NEO.git
synced 2024-11-23 10:48:06 +11:00
I've finally split up the BIOS a bit.
This commit is contained in:
parent
ea6e5da1c3
commit
3c18756141
@ -1,5 +0,0 @@
|
||||
os.execute("mkdir -p pkg")
|
||||
os.execute("rm -rf pkg/*")
|
||||
|
||||
os.execute("mkdir -p release")
|
||||
os.execute("rm -rf release/*")
|
92
.buildactions/02_lzss.lua
Normal file
92
.buildactions/02_lzss.lua
Normal file
@ -0,0 +1,92 @@
|
||||
local M = {}
|
||||
local string, table = string, table
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local POS_BITS = 12
|
||||
local LEN_BITS = 16 - POS_BITS
|
||||
local POS_SIZE = 1 << POS_BITS
|
||||
local LEN_SIZE = 1 << LEN_BITS
|
||||
local LEN_MIN = 3
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function M.compress(input)
|
||||
local offset, output = 1, {}
|
||||
local window = ''
|
||||
|
||||
local function search()
|
||||
for i = LEN_SIZE + LEN_MIN - 1, LEN_MIN, -1 do
|
||||
local str = string.sub(input, offset, offset + i - 1)
|
||||
local pos = string.find(window, str, 1, true)
|
||||
if pos then
|
||||
return pos, str
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
while offset <= #input do
|
||||
local flags, buffer = 0, {}
|
||||
|
||||
for i = 0, 7 do
|
||||
if offset <= #input then
|
||||
local pos, str = search()
|
||||
if pos and #str >= LEN_MIN then
|
||||
local tmp = ((pos - 1) << LEN_BITS) | (#str - LEN_MIN)
|
||||
buffer[#buffer + 1] = string.pack('>I2', tmp)
|
||||
else
|
||||
flags = flags | (1 << i)
|
||||
str = string.sub(input, offset, offset)
|
||||
buffer[#buffer + 1] = str
|
||||
end
|
||||
window = string.sub(window .. str, -POS_SIZE)
|
||||
offset = offset + #str
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if #buffer > 0 then
|
||||
output[#output + 1] = string.char(flags)
|
||||
output[#output + 1] = table.concat(buffer)
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(output)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function M.decompress(input)
|
||||
local offset, output = 1, {}
|
||||
local window = ''
|
||||
|
||||
while offset <= #input do
|
||||
local flags = string.byte(input, offset)
|
||||
offset = offset + 1
|
||||
|
||||
for i = 1, 8 do
|
||||
local str = nil
|
||||
if (flags & 1) ~= 0 then
|
||||
if offset <= #input then
|
||||
str = string.sub(input, offset, offset)
|
||||
offset = offset + 1
|
||||
end
|
||||
else
|
||||
if offset + 1 <= #input then
|
||||
local tmp = string.unpack('>I2', input, offset)
|
||||
offset = offset + 2
|
||||
local pos = (tmp >> LEN_BITS) + 1
|
||||
local len = (tmp & (LEN_SIZE - 1)) + LEN_MIN
|
||||
str = string.sub(window, pos, pos + len - 1)
|
||||
end
|
||||
end
|
||||
flags = flags >> 1
|
||||
if str then
|
||||
output[#output + 1] = str
|
||||
window = string.sub(window .. str, -POS_SIZE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return table.concat(output)
|
||||
end
|
||||
|
||||
local lzss = M
|
@ -1,20 +1,8 @@
|
||||
local function make_platform(plat)
|
||||
os.execute("mkdir -p pkg/bios")
|
||||
print("Making "..plat..".bios")
|
||||
os.execute("luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
|
||||
--os.execute("ZY_PLATFORM="..plat.." luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
|
||||
print("ZY_PLATFORM="..plat.."luacomp src/loader.lua -O pkg/bios/"..plat..".bios")
|
||||
print("[[ $".."(stat --printf=%s pkg/bios/"..plat..".bios) > 4096 ]]")
|
||||
if (os.execute("[[ $".."(stat --printf=%s pkg/bios/"..plat..".bios) > 4096 ]]")) then
|
||||
io.stderr:write("WARNING: "..plat.." bios is over 4KiB!\n")
|
||||
end
|
||||
end
|
||||
|
||||
local function mkplat(plat)
|
||||
local h = io.popen("luacomp src/loader.lua")
|
||||
local loader = h:read("*a")
|
||||
h:close()
|
||||
local h = io.popen("ZY_PLATFORM="..plat.." luacomp src/zy-neo/zinit.lua -mluamin | lua5.3 utils/makezbios.lua")
|
||||
local h = io.popen("ZY_PLATFORM="..plat.." luacomp src/zy-neo/neoinit.lua | lua5.3 utils/makezbios.lua")
|
||||
local dat = h:read("*a")
|
||||
h:close()
|
||||
os.execute("mkdir -p pkg/bios")
|
||||
@ -42,7 +30,26 @@ function actions.osdi_bios()
|
||||
mkplat("osdi")
|
||||
end
|
||||
|
||||
function actions.bootstrap()
|
||||
--os.execute("luacomp src/zy-neo/zinit.lua | lua5.3 utils/makezbios.lua > pkg/bios/bootstrap.bin")
|
||||
local h = io.popen("luacomp src/zy-neo/zinit.lua")
|
||||
local dat = h:read("*a")
|
||||
h:close()
|
||||
local h = io.open("pkg/bios/bootstrap.bin", "wb")
|
||||
h:write(lzss.compress(dat))
|
||||
h:close()
|
||||
end
|
||||
|
||||
function actions.bios()
|
||||
actions.managed_bios()
|
||||
actions.initramfs_bios()
|
||||
actions.prom_bios()
|
||||
actions.osdi_bios()
|
||||
actions.bootstrap()
|
||||
end
|
||||
|
||||
actions[#actions+1] = "managed_bios"
|
||||
actions[#actions+1] = "initramfs_bios"
|
||||
actions[#actions+1] = "prom_bios"
|
||||
actions[#actions+1] = "osdi_bios"
|
||||
actions[#actions+1] = "osdi_bios"
|
||||
actions[#actions+1] = "bootstrap"
|
@ -2,4 +2,10 @@ function actions.clean()
|
||||
print("Cleaning up...")
|
||||
--os.execute("rm -rf .docs")
|
||||
--os.execute("rm -rf .ktmp")
|
||||
os.execute("mkdir -p pkg")
|
||||
os.execute("rm -rf pkg/*")
|
||||
|
||||
os.execute("mkdir -p release")
|
||||
os.execute("rm -rf release/*")
|
||||
|
||||
end
|
@ -3,7 +3,8 @@ tty = {}
|
||||
do
|
||||
local gpu = component.proxy(component.list("gpu")())
|
||||
if not gpu.getScreen() then
|
||||
gpu.bind(component.list("screen")())
|
||||
local saddr = component.list("screen")()
|
||||
gpu.bind(saddr)
|
||||
end
|
||||
local gfg = -1
|
||||
local gbg = -1
|
||||
|
@ -1,2 +1,2 @@
|
||||
--#include "src/lzss.lua"
|
||||
return assert(load(lzss_decompress(%s), "=bios.lua"))(lzss_decompress)
|
||||
return assert(load(lzss_decompress(%s), "=BOOTSTRAP.lua"))(lzss_decompress)
|
@ -1,4 +1,4 @@
|
||||
function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
|
||||
local function lzss_decompress(a)local b,c,d,e,j,i,h,g=1,'',''while b<=#a do
|
||||
e=c.byte(a,b)b=b+1
|
||||
for k=0,7 do h=c.sub
|
||||
g=h(a,b,b)if e>>k&1<1 and b<#a then
|
||||
|
@ -23,7 +23,7 @@ local bootfs = cproxy(baddr)
|
||||
assert(bootfs.exists(".zy2/image.tsar"), "No boot image!")
|
||||
|
||||
local romfs_file = assert(bootfs.open(".zy2/image.tsar", "rb"))
|
||||
local rfs = utils.readfile(bootfs, romfs_file)
|
||||
local rfs = readfile(bootfs, romfs_file)
|
||||
|
||||
--[[local romfs_dev = tsar.read(function(a)
|
||||
local c = ""
|
||||
@ -65,7 +65,7 @@ end
|
||||
|
||||
function bfs.getcfg()
|
||||
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
|
||||
return utils.readfile(bootfs, h)
|
||||
return readfile(bootfs.address, h)
|
||||
end
|
||||
|
||||
bfs.addr = baddr
|
@ -53,7 +53,7 @@ end
|
||||
|
||||
function bfs.getcfg()
|
||||
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
|
||||
return utils.readfile(bootfs, h)
|
||||
return readfile(bootfs.address, h)
|
||||
end
|
||||
|
||||
bfs.addr = baddr
|
@ -8,7 +8,7 @@ local bootfs = cproxy(baddr)
|
||||
--find active partition
|
||||
local bs, p, t, ss = bootfs.readSector(1), "I4I4c8I3c13", {}
|
||||
for i=1, 15 do
|
||||
t = {p:unpack(bs:sub((i*32)+1, (i+1)*32))}
|
||||
t = {sunpack(p, bs:sub((i*32)+1, (i+1)*32))}
|
||||
if (t[4] & 0x200 and t[4] & 0x40) then
|
||||
ss = t[1]
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ end
|
||||
function romfs.read(read, seek, close)
|
||||
local sig = read(7)
|
||||
assert(sig, "Read error!")
|
||||
if sig ~= "romfs\1\0" then error(string.format("Invalid romfs (%.14x != %.14x)", string.unpack("i7", sig), string.unpack("i7", "romfs\1\0"))) end
|
||||
if sig ~= "romfs\1\0" then error(string.format("Invalid romfs (%.14x != %.14x)", sunpack("i7", sig), sunpack("i7", "romfs\1\0"))) end
|
||||
local tbl = {}
|
||||
local lname
|
||||
while lname ~= "TRAILER!!!" do
|
||||
|
@ -7,13 +7,14 @@ local function get_end(e)
|
||||
end
|
||||
local function read_header(dat)
|
||||
local e = get_end(en)
|
||||
local m = string.unpack(e.."I2", dat)
|
||||
local m = sunpack(e.."I2", dat)
|
||||
if m ~= magic and m ~= magic_rev then return nil, string.format("bad magic (%.4x)", m) end
|
||||
if m ~= magic then
|
||||
e = get_end(not en)
|
||||
end
|
||||
local ent = {}
|
||||
ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime = string.unpack(e..header_fmt, dat)
|
||||
ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime = sunpack(e..header_fmt, dat)
|
||||
ent.mtime = ent.mtime/1000
|
||||
return ent
|
||||
end
|
||||
|
||||
|
57
src/zy-neo/neoinit.lua
Normal file
57
src/zy-neo/neoinit.lua
Normal file
@ -0,0 +1,57 @@
|
||||
-- I am an idiot.
|
||||
local decompress = ...
|
||||
local krq = krequire
|
||||
local sunpack = string.unpack
|
||||
local ct, cr = component, computer
|
||||
|
||||
-- I now must debug every fucking thing.
|
||||
@[[if svar.get("DEBUG") then]]
|
||||
do
|
||||
local cinvoke, clist, cproxy = ct.invoke, ct.list, ct.proxy
|
||||
function component.invoke(addr, meth, ...)
|
||||
cinvoke(clist("ocemu")(), "log", addr, meth, ..., debug.getinfo(2).source, debug.getinfo(2).linedefined)
|
||||
return cinvoke(addr, meth, ...)
|
||||
end
|
||||
|
||||
function component.proxy(addr)
|
||||
local proxy = cproxy(addr)
|
||||
return setmetatable({}, {__index=function(_, i)
|
||||
if proxy[i] then
|
||||
return function(...)
|
||||
cinvoke(clist("ocemu")(), "log", addr, i, ..., debug.getinfo(3).source, debug.getinfo(3).linedefined)
|
||||
return proxy[i](...)
|
||||
end
|
||||
end
|
||||
end})
|
||||
end
|
||||
end
|
||||
@[[end]]
|
||||
local cinvoke, clist, cproxy = ct.invoke, ct.list, ct.proxy
|
||||
|
||||
local function readfile(f,h)
|
||||
local b=""
|
||||
local d,r=cinvoke(f,"read",h,math.huge)
|
||||
if not d and r then error(r)end
|
||||
b=d
|
||||
while d do
|
||||
local d,r=cinvoke(f,"read",h,math.huge)
|
||||
b=b..(d or "")
|
||||
if(not d)then break end
|
||||
end
|
||||
cinvoke(f,"close",h)
|
||||
return b
|
||||
end
|
||||
|
||||
--#include "src/zy-neo/builtins/util_tsar.lua"
|
||||
@[[if not svar.get("ZY_PLATFORM") then]]
|
||||
--#define "ZY_PLATFORM" "managed"
|
||||
@[[end]]
|
||||
--#include @[{"src/zy-neo/builtins/init_"..svar.get("ZY_PLATFORM").."/init.lua"}]
|
||||
--component.invoke(component.list("sandbox")(), "log", "test")
|
||||
if not bfs.exists("bootstrap.bin") then
|
||||
error("No bootstrap.bin!")
|
||||
end
|
||||
local raw = bfs.getfile("bootstrap.bin")
|
||||
local code = decompress(raw)
|
||||
--component.invoke(component.list("sandbox")(), "log", code or "<null>")
|
||||
assert(load(code, "=bootstrap.bin"))(decompress, tsar, bfs, readfile)
|
@ -1,8 +1,12 @@
|
||||
local utils = {}
|
||||
@[[if svar.get("DEBUG") then]]
|
||||
function utils.debug_log(...)
|
||||
local sb = clist("sandbox")() or clist("ocemu")()
|
||||
if (sb) then cinvoke(sb, "log", ...) end
|
||||
end
|
||||
@[[else]]
|
||||
function utils.debug_log()end
|
||||
@[[end]]
|
||||
|
||||
--[[function utils.baddr(address)
|
||||
local address = address:gsub("-", "", true)
|
||||
@ -13,19 +17,7 @@ end
|
||||
return b
|
||||
end]]
|
||||
|
||||
function utils.readfile(f,h)
|
||||
local b=""
|
||||
local d,r=cinvoke(f,"read",h,math.huge)
|
||||
if not d and r then error(r)end
|
||||
b=d
|
||||
while d do
|
||||
local d,r=cinvoke(f,"read",h,math.huge)
|
||||
b=b..(d or "")
|
||||
if(not d)then break end
|
||||
end
|
||||
cinvoke(f,"close",h)
|
||||
return b
|
||||
end
|
||||
utils.readfile = readfile
|
||||
|
||||
utils.load_lua = load_lua
|
||||
|
||||
@ -39,10 +31,10 @@ function utils.deepcopy(src, dest)
|
||||
local cout = {dest}
|
||||
while #cin > 0 do
|
||||
for k, v in pairs(cin[1]) do
|
||||
if (type(v) ~= "table") then
|
||||
if type(v) ~= "table" then
|
||||
cout[1][k] = v
|
||||
else
|
||||
if (coppied[v]) then
|
||||
if coppied[v] then
|
||||
cout[1][k] = coppied[v]
|
||||
else
|
||||
local t = {}
|
||||
@ -62,29 +54,29 @@ end
|
||||
local velx_header = "<c5BBBBc4I3I3I3I4"
|
||||
function utils.load_velx(read, seek, close, name)
|
||||
-- Load a VELX format library.
|
||||
local magic, fver, compression, lver, osid, arctype, psize, lsize, ssize, rsize = string.unpack(velx_header, read(string.packsize(velx_header)))
|
||||
if (magic ~= "\27VelX") then
|
||||
local magic, fver, compression, lver, osid, arctype, psize, lsize, ssize, rsize = sunpack(velx_header, read(string.packsize(velx_header)))
|
||||
if magic ~= "\27VelX" then
|
||||
return nil, "bad magic ("..magic..")"
|
||||
end
|
||||
if (osid & 0x7F ~= 0x5A) then
|
||||
if osid & 0x7F ~= 0x5A then
|
||||
return nil, string.format("wrong os (%x ~= 0x5A)", osid & 0x7F)
|
||||
end
|
||||
if (compression > 1) then
|
||||
if compression > 1 then
|
||||
return nil, "bad compression"
|
||||
end
|
||||
if ((arctype ~= "\0\0\0\0" and arctype ~= "tsar")) then
|
||||
if arctype ~= "\0\0\0\0" and arctype ~= "tsar" then
|
||||
return nil, "bad arctype ("..arctype..")"
|
||||
end
|
||||
if (fver ~= 1) then
|
||||
return nil, "wrong version"
|
||||
end
|
||||
local prog = read(psize)
|
||||
if (compression == 1) then
|
||||
if compression == 1 then
|
||||
prog = lzss_decompress(prog)
|
||||
end
|
||||
seek(lsize+ssize)
|
||||
local env = {}
|
||||
if (arctype == "tsar") then
|
||||
if arctype == "tsar" then
|
||||
env._ARCHIVE = tsar.read(read, seek, close)
|
||||
end
|
||||
setmetatable(env, {__index=_G, __newindex=function(_, i, v) _G[i] = v end})
|
||||
@ -103,15 +95,27 @@ function utils.make_env()
|
||||
end
|
||||
|
||||
function utils.console_panic(er)
|
||||
local con = krequire("zorya").loadmod("util_luaconsole")
|
||||
if (con) then
|
||||
local gpu = cproxy(clist("gpu")())
|
||||
if not gpu.getScreen() or gpu.getScreen() == "" then
|
||||
gpu.bind(clist("screen")())
|
||||
end
|
||||
con(string.format("tty.setcolor(0x4) print([[%s]])", er))
|
||||
local gaddr = clist("gpu")()
|
||||
local con, gpu = krq("zorya").loadmod("util_luaconsole"), cproxy(gaddr)
|
||||
if not gpu.getScreen() or gpu.getScreen() == "" then
|
||||
local saddr = clist("screen")()
|
||||
gpu.bind(saddr)
|
||||
end
|
||||
if con then
|
||||
con(string.format("tty.setcolor(0x4) print([[%s]])", er:gsub("\t", " ")))
|
||||
return true
|
||||
end
|
||||
--gs = gpu.set
|
||||
gpu.set(1, 1, "Kernel panic!")
|
||||
local y = 2
|
||||
for m in er:gmatch("(.+)\n") do
|
||||
gpu.set(1,y,m)
|
||||
y = y + 1
|
||||
end
|
||||
gpu.set(1, y, "Press any key to shut down.")
|
||||
while true do
|
||||
if (cr.pullSignal() == "key_down") then cr.shutdown() end
|
||||
end
|
||||
end
|
||||
|
||||
_RENV = utils.make_env()
|
||||
|
@ -1,24 +1,11 @@
|
||||
local lzss_decompress = ...
|
||||
local lzss_decompress, tsar, bfs, readfile = ...
|
||||
--Zorya NEO itself.
|
||||
_BIOS = "Zorya NEO"
|
||||
_ZVSTR = "2.0-rc5"
|
||||
_ZVER = 2.0
|
||||
_ZPAT = 0
|
||||
_ZGIT = "$[[git rev-parse --short HEAD]]"
|
||||
_BIOS, _ZVSTR, _ZVER, _ZPAT, _ZGIT = "Zorya NEO", "2.0-rc5", 2.0, 0, "$[[git rev-parse --short HEAD]]"
|
||||
--#include "ksrc/kinit.lua"
|
||||
local thd = krequire("thd")
|
||||
local sys = krequire("sys")
|
||||
local component = component
|
||||
local computer = computer
|
||||
local cinvoke = component.invoke
|
||||
local clist = component.list
|
||||
local cproxy = component.proxy
|
||||
local th_i = 0
|
||||
local function th_a(func)
|
||||
thd.add("zyneo$"..th_i, func)
|
||||
th_i = th_i + 1
|
||||
end
|
||||
|
||||
local krq = krequire
|
||||
local sunpack = string.unpack
|
||||
local thd, sys, ct, cr = krq"thd", krq"sys", component, computer
|
||||
local cinvoke, clist, cproxy = ct.invoke, ct.list, ct.proxy
|
||||
local function load_lua(src, ...)
|
||||
if (src:sub(1, 4) == "\27ZLS") then
|
||||
src = lzss_decompress(src:sub(5))
|
||||
@ -26,7 +13,7 @@ local function load_lua(src, ...)
|
||||
return load(src, ...)
|
||||
end
|
||||
|
||||
--#include "src/zy-neo/builtins/util_tsar.lua"
|
||||
---#include "src/zy-neo/builtins/util_tsar.lua"
|
||||
|
||||
local builtins = {}
|
||||
--#include "src/zy-neo/utils.lua"
|
||||
@ -61,24 +48,16 @@ sys.add_lib("zorya", (function()
|
||||
mod_search[#mod_search+1] = func
|
||||
log(#mod_search)
|
||||
end
|
||||
|
||||
function zy.lkthdn()
|
||||
return #thd.get_threads()
|
||||
end
|
||||
|
||||
function zy.lkthdi(i)
|
||||
return thd.get_threads()[i]
|
||||
end
|
||||
return zy
|
||||
end)())
|
||||
|
||||
--#include "src/zy-neo/init.lua"
|
||||
---#include "src/zy-neo/init.lua"
|
||||
|
||||
-- Zorya's handler thread.
|
||||
th_a(function()
|
||||
thd.add("zyneo", function()
|
||||
local er
|
||||
xpcall(function()
|
||||
local zy = krequire("zorya")
|
||||
local zy = krq"zorya"
|
||||
zy.add_mod_search(function(mod)
|
||||
if (bfs.exists(".zy2/mods/"..mod..".velx")) then
|
||||
--utils.debug_log(mod, ".zy2m")
|
||||
@ -109,17 +88,21 @@ th_a(function()
|
||||
|
||||
local c, e = load(zycfg, "=zycfg", "t", env)
|
||||
if c then
|
||||
return c()
|
||||
xpcall(function()
|
||||
return c()
|
||||
end,
|
||||
function(e)
|
||||
er = debug.traceback(e)
|
||||
utils.console_panic(er)
|
||||
end)
|
||||
else
|
||||
utils.console_panic(e)
|
||||
end
|
||||
end, function(e)
|
||||
er = e..": "..debug.traceback()
|
||||
if(not utils.console_panic(er)) then
|
||||
er = er .. "\n(Lua console failed to start)"
|
||||
end
|
||||
utils.console_panic(er)
|
||||
end)
|
||||
if er then error(er) end
|
||||
if er then utils.console_panic(er) end
|
||||
end)
|
||||
|
||||
sys.start()
|
8
util/OpenOS/initramfs.d/99_bootstrap.lua
Normal file
8
util/OpenOS/initramfs.d/99_bootstrap.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local arc = ...
|
||||
local function readfile(path)
|
||||
local f = io.open(path)
|
||||
local dat = f:read("*a")
|
||||
f:close()
|
||||
return dat
|
||||
end
|
||||
arc.file("bootstrap.bin", "r-xr-xr-x", readfile("/etc/zorya-neo/bootstrap.bin"))
|
@ -36,13 +36,17 @@ local function create_node(attr)
|
||||
uid = attr.uid,
|
||||
gid = attr.gid,
|
||||
filesize = attr.filesize,
|
||||
mtime = attr.mtime
|
||||
mtime = (attr.mtime*1000)//1
|
||||
}
|
||||
if attr.mode ~= "file" then
|
||||
ent.filesize = 0
|
||||
end
|
||||
f:write(string.pack("=I2I2I2I2I2I6I6", ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime))
|
||||
f:write(attr.name or "")
|
||||
if (ent.namesize & 1 > 0) then
|
||||
f:write("\0")
|
||||
end
|
||||
f:write(attr.data or "")
|
||||
if (ent.filesize & 1 > 0) then
|
||||
f:write("\0")
|
||||
end
|
||||
end
|
||||
local arc = {}
|
||||
function arc.file(path, perm, data)
|
||||
|
@ -138,5 +138,6 @@ for i=1, #lst do
|
||||
print(lst[i])
|
||||
writefile("/etc/zorya-neo/lib/"..lst[i]:sub(9), arc:fetch(lst[i]))
|
||||
end
|
||||
writefile("/etc/zorya-neo/bootstrap.bin", arc:fetch("bootstrap.bin"))
|
||||
arc:close()
|
||||
print("Installation complete.")
|
@ -176,7 +176,7 @@ function makeDirectory(path)
|
||||
uid = 0,
|
||||
gid = 0,
|
||||
filesize = 0,
|
||||
mtime = os.time()
|
||||
mtime = os.time()*1000
|
||||
}
|
||||
fs.write(romfs, string.pack("=I2I2I2I2I2I6I6", ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime))
|
||||
fs.write(romfs, path)
|
||||
@ -208,11 +208,11 @@ function writeFile(path, data)
|
||||
name = path,
|
||||
namesize = #path,
|
||||
magic = 0x5f7d,
|
||||
mode = getperm("file", ((ext == "lua" or ext == "z2l" or ext == "z2y") and "r-xr-xr-x") or "rw-r--r--"),
|
||||
mode = getperm("file", ((ext == "lua" or ext == "z2l" or ext == "z2y" or ext == "velx") and "r-xr-xr-x") or "rw-r--r--"),
|
||||
uid = 0,
|
||||
gid = 0,
|
||||
filesize = #data,
|
||||
mtime = os.time()
|
||||
mtime = os.time()*1000
|
||||
}
|
||||
fs.write(romfs, string.pack("=I2I2I2I2I2I6I6", ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime))
|
||||
fs.write(romfs, path)
|
||||
@ -242,28 +242,25 @@ for i=1, #pkg_files do
|
||||
writeFile(".zy2/"..pkg_files[i].path, getfile(pkg_files[i].path))
|
||||
end
|
||||
|
||||
writeFile("TRAILER!!!", [[{os="Zorya NEO",version="2.0"}]])
|
||||
|
||||
setStatus("Extracting EEPROM...")
|
||||
setBar(0)
|
||||
local bios = getfile(bios_files[1].path)
|
||||
|
||||
setStatus("Flashing EEPROM...")
|
||||
setBar(33)
|
||||
setBar(25)
|
||||
local eeprom = proxy(list("eeprom")())
|
||||
eeprom.set(bios)
|
||||
setStatus("Writing configuration data...")
|
||||
setBar(66)
|
||||
function hexid_to_binid(addr)
|
||||
addr=addr:gsub("%-", "")
|
||||
local baddr = ""
|
||||
for i=1, #addr, 2 do
|
||||
baddr = baddr .. string.char(tonumber(addr:sub(i, i+1), 16))
|
||||
end
|
||||
return baddr
|
||||
end
|
||||
setBar(50)
|
||||
eeprom.setData(fs.address)
|
||||
eeprom.setLabel("Zorya NEO BIOS v2.0")
|
||||
|
||||
setStatus("Writing bootstrapper...")
|
||||
setBar(75)
|
||||
writeFile("bootstrap.bin", getfile("bios/bootstrap.bin"))
|
||||
|
||||
writeFile("TRAILER!!!", [[{os="Zorya NEO",version="2.0"}]])
|
||||
|
||||
setBar(100)
|
||||
setStatus("Rebooting in 5 seconds...")
|
||||
if not fs.exists(".zy2/cfg.lua") then
|
||||
|
Loading…
Reference in New Issue
Block a user