formating better for spm packages
This commit is contained in:
@@ -106,7 +106,7 @@ local ok, err = xpcall(function()
|
|||||||
|
|
||||||
local file = {}
|
local file = {}
|
||||||
|
|
||||||
function file:read(n)
|
function file.read(n)
|
||||||
assert(not closed, "file is closed")
|
assert(not closed, "file is closed")
|
||||||
|
|
||||||
local s = content()
|
local s = content()
|
||||||
@@ -123,7 +123,7 @@ local ok, err = xpcall(function()
|
|||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
function file:write(data)
|
function file.write(data)
|
||||||
assert(not closed, "file is closed")
|
assert(not closed, "file is closed")
|
||||||
|
|
||||||
local s = content()
|
local s = content()
|
||||||
@@ -136,7 +136,7 @@ local ok, err = xpcall(function()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function file:seek(whence, offset)
|
function file.seek(whence, offset)
|
||||||
assert(not closed, "file is closed")
|
assert(not closed, "file is closed")
|
||||||
|
|
||||||
local s = content()
|
local s = content()
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
--:Minify:--
|
--:Minify:--
|
||||||
local BOOT_DRIVE_PATH = ({...})[1] or "/$"
|
local BOOT_DRIVE_PATH = ({...})[1] or "/$"
|
||||||
---@diagnostic disable-next-line: undefined-global
|
---@diagnostic disable-next-line: undefined-global
|
||||||
local term = term
|
local lterm = term
|
||||||
local os = os
|
local function write(text, term)
|
||||||
local function write(text)
|
|
||||||
local x, y = term.getCursorPos()
|
local x, y = term.getCursorPos()
|
||||||
local w, h = term.getSize()
|
local w, h = term.getSize()
|
||||||
|
|
||||||
@@ -49,13 +48,13 @@ local function write(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function displaySuperBadError(err)
|
local function displaySuperBadError(err)
|
||||||
term.setBackgroundColor(0x1)
|
lterm.setBackgroundColor(0x1)
|
||||||
term.setTextColor(0x4)
|
lterm.setTextColor(0x4)
|
||||||
term.clear()
|
lterm.clear()
|
||||||
term.setCursorPos(1, 1)
|
lterm.setCursorPos(1, 1)
|
||||||
term.write("A critical error occurred while loading the system:")
|
lterm.write("A critical error occurred while loading the system:")
|
||||||
term.setCursorPos(1, 3)
|
lterm.setCursorPos(1, 3)
|
||||||
write(err)
|
write(err, lterm)
|
||||||
while true do end
|
while true do end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -172,22 +171,22 @@ local ok, err = xpcall(function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local colors = {
|
local colors = {
|
||||||
[0x000000]=0x0001,
|
[0xFFFFFF]=0x0001,
|
||||||
[0xFFFFFF]=0x0002,
|
[0xFF0000]=0x0002,
|
||||||
[0xFF0000]=0x0004,
|
[0x00FF00]=0x0004,
|
||||||
[0x00FF00]=0x0008,
|
[0x0000FF]=0x0008,
|
||||||
[0x0000FF]=0x0010,
|
[0x00FFFF]=0x0010,
|
||||||
[0x00FFFF]=0x0020,
|
[0xFF00FF]=0x0020,
|
||||||
[0xFF00FF]=0x0040,
|
[0xFFFF00]=0x0040,
|
||||||
[0xFFFF00]=0x0080,
|
[0xFF6D00]=0x0080,
|
||||||
[0xFF6D00]=0x0100,
|
[0x6DFF55]=0x0100,
|
||||||
[0x6DFF55]=0x0200,
|
[0x24FFFF]=0x0200,
|
||||||
[0x24FFFF]=0x0400,
|
[0x924900]=0x0400,
|
||||||
[0x924900]=0x0800,
|
[0x6D6D55]=0x0800,
|
||||||
[0x6D6D55]=0x1000,
|
[0xDBDBAA]=0x1000,
|
||||||
[0xDBDBAA]=0x2000,
|
[0x6D00FF]=0x2000,
|
||||||
[0x6D00FF]=0x4000,
|
[0xB6FF00]=0x4000,
|
||||||
[0xB6FF00]=0x8000
|
[0x000000]=0x8000
|
||||||
}
|
}
|
||||||
|
|
||||||
local fg,bg=0x6D6D55,0x000000
|
local fg,bg=0x6D6D55,0x000000
|
||||||
@@ -401,9 +400,10 @@ local ok, err = xpcall(function()
|
|||||||
allscreens[i].setTextScale(.5)
|
allscreens[i].setTextScale(.5)
|
||||||
allscreens[i].clear()
|
allscreens[i].clear()
|
||||||
allscreens[i].setCursorPos(1,1)
|
allscreens[i].setCursorPos(1,1)
|
||||||
allscreens[i].write("Initializing...")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
allscreens[#allscreens+1] = apis.term
|
||||||
|
|
||||||
local EFI = {
|
local EFI = {
|
||||||
getEpochMs = function() return apis.os.epoch("utc") end,
|
getEpochMs = function() return apis.os.epoch("utc") end,
|
||||||
getUptime = function() return apis.os.clock() * 1000 end,
|
getUptime = function() return apis.os.clock() * 1000 end,
|
||||||
@@ -424,22 +424,38 @@ local ok, err = xpcall(function()
|
|||||||
initfs=fs,
|
initfs=fs,
|
||||||
disks=initFs,
|
disks=initFs,
|
||||||
screenCtl={
|
screenCtl={
|
||||||
print = function(_, text) write(text .. "\n") end,
|
print = function(_, text)
|
||||||
printInline = function(_, text) write(text) end,
|
for i=1, #allscreens do
|
||||||
|
write(text.."\n", allscreens[i])
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
printInline = function(_, text)
|
||||||
|
for i=1, #allscreens do
|
||||||
|
write(text, allscreens[i])
|
||||||
|
end
|
||||||
|
end,
|
||||||
clear = function()
|
clear = function()
|
||||||
apis.term.clear()
|
for i=1, #allscreens do
|
||||||
apis.term.setCursorPos(1, 1)
|
allscreens[i].clear()
|
||||||
|
allscreens[i].setCursorPos(1, 1)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
setCursorPos = function(_, x, y)
|
resetCursor = function()
|
||||||
apis.term.setCursorPos(x, y)
|
for i=1, #allscreens do
|
||||||
|
allscreens[i].setCursorPos(1, 1)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
getCursorPos = function() return apis.term.getCursorPos() end,
|
|
||||||
getSize = function() return apis.term.getSize() end,
|
|
||||||
setBackgroundColor = function(_, color)
|
setBackgroundColor = function(_, color)
|
||||||
apis.term.setBackgroundColor(aprox(color))
|
bg=color
|
||||||
|
for i=1, #allscreens do
|
||||||
|
allscreens[i].setBackgroundColor(aprox(color))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
setTextColor = function(_, color)
|
setTextColor = function(_, color)
|
||||||
apis.term.setTextColor(aprox(color))
|
fg=color
|
||||||
|
for i=1, #allscreens do
|
||||||
|
allscreens[i].setTextColor(aprox(color))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
getBackgroundColor = function()
|
getBackgroundColor = function()
|
||||||
return bg
|
return bg
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
--:Minify:--
|
||||||
@@ -246,7 +246,5 @@ kernel.cct.fifo=fifo
|
|||||||
newtty(kernel.apis.term, "1", fifo.pop)
|
newtty(kernel.apis.term, "1", fifo.pop)
|
||||||
|
|
||||||
for i,v in ipairs({peripheral.find("monitor")}) do
|
for i,v in ipairs({peripheral.find("monitor")}) do
|
||||||
v.setTextScale(.5)
|
|
||||||
v.write("Initializing...")
|
|
||||||
newtty(v,tostring(i+1),function () end)
|
newtty(v,tostring(i+1),function () end)
|
||||||
end
|
end
|
||||||
@@ -7,7 +7,8 @@ local disks=EFI.disks
|
|||||||
local arch=EFI.architecture
|
local arch=EFI.architecture
|
||||||
local kernel = {}
|
local kernel = {}
|
||||||
kernel.LOG_Text=""
|
kernel.LOG_Text=""
|
||||||
kernel.version="HyperionOS V1.2.4"
|
kernel.version="HyperionOS V1.2.4-dev_5"
|
||||||
|
kernel.tag="1.2.4-dev_5"
|
||||||
kernel.process = "Kernel"
|
kernel.process = "Kernel"
|
||||||
kernel.users={[0]="root",[1]="User"}
|
kernel.users={[0]="root",[1]="User"}
|
||||||
kernel.hostname = "hyperion"
|
kernel.hostname = "hyperion"
|
||||||
@@ -22,7 +23,7 @@ kernel._G=_G
|
|||||||
kernel.sleep=sleep
|
kernel.sleep=sleep
|
||||||
|
|
||||||
_G.sleep=nil
|
_G.sleep=nil
|
||||||
local windowsExp = false
|
local windowsExp = true
|
||||||
|
|
||||||
function kernel.log(msg, level, c)
|
function kernel.log(msg, level, c)
|
||||||
c=c or 0x6D6D6D
|
c=c or 0x6D6D6D
|
||||||
@@ -51,7 +52,7 @@ function kernel.PANIC(msg)
|
|||||||
screen:setTextColor(0xFF0000)
|
screen:setTextColor(0xFF0000)
|
||||||
screen:setBackgroundColor(0x000000)
|
screen:setBackgroundColor(0x000000)
|
||||||
screen:clear()
|
screen:clear()
|
||||||
screen:setCursorPos(1,1)
|
screen:resetCursor()
|
||||||
screen:print(kernel.LOG_Text)
|
screen:print(kernel.LOG_Text)
|
||||||
screen:print("KERNEL PANIC!\n"..msg.."\nSystem halted.")
|
screen:print("KERNEL PANIC!\n"..msg.."\nSystem halted.")
|
||||||
screen:print("Press any key to continue...")
|
screen:print("Press any key to continue...")
|
||||||
@@ -72,17 +73,11 @@ if windowsExp then
|
|||||||
screen:setTextColor(0xFFFFFF)
|
screen:setTextColor(0xFFFFFF)
|
||||||
screen:setBackgroundColor(0x0000FF)
|
screen:setBackgroundColor(0x0000FF)
|
||||||
screen:clear()
|
screen:clear()
|
||||||
local w,h = screen:getSize()
|
screen:resetCursor()
|
||||||
screen:setCursorPos(3,5)
|
screen:print("\n\n\n\n\n :(")
|
||||||
screen:print(":(")
|
screen:print("\n Your PC ran into a problem and needs to restart. We're just collecting some error")
|
||||||
screen:setCursorPos(3,7)
|
|
||||||
screen:print("Your PC ran into a problem and needs to restart. We're just collecting some error")
|
|
||||||
screen:setCursorPos(3,8)
|
|
||||||
screen:print(" info, and then we'll restart for you.\n")
|
screen:print(" info, and then we'll restart for you.\n")
|
||||||
screen:setCursorPos(3,h-5)
|
screen:print("\n\n\n Stop code: average windows experience")
|
||||||
screen:print("Stop code: average windows experience")
|
|
||||||
screen:setCursorPos(1,h)
|
|
||||||
screen:print("Press any key to continue... jk reboot it yourself lazy")
|
|
||||||
while true do end
|
while true do end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -254,6 +249,7 @@ end
|
|||||||
kernel.syscalls["time"]=function() return kernel.EFI:getEpochMs() end
|
kernel.syscalls["time"]=function() return kernel.EFI:getEpochMs() end
|
||||||
kernel.syscalls["date"]=function() return kernel.EFI:date() end
|
kernel.syscalls["date"]=function() return kernel.EFI:date() end
|
||||||
kernel.syscalls["log"]=kernel.log
|
kernel.syscalls["log"]=kernel.log
|
||||||
|
kernel.syscalls["tag"]=function() return kernel.tag end
|
||||||
kernel.syscalls["getUptime"]=function() return kernel.EFI:getUptime() end
|
kernel.syscalls["getUptime"]=function() return kernel.EFI:getUptime() end
|
||||||
kernel.syscalls["getUsername"]=function(uid) return kernel.users[uid or kernel.uid] end
|
kernel.syscalls["getUsername"]=function(uid) return kernel.users[uid or kernel.uid] end
|
||||||
kernel.syscalls["getHostname"]=function() return kernel.hostname end
|
kernel.syscalls["getHostname"]=function() return kernel.hostname end
|
||||||
@@ -7,6 +7,5 @@ return {
|
|||||||
initPath = "/sbin/init",
|
initPath = "/sbin/init",
|
||||||
maxOpenFiles = 128,
|
maxOpenFiles = 128,
|
||||||
maxFilesPerTask = 16,
|
maxFilesPerTask = 16,
|
||||||
preempt=true,
|
preempt=true
|
||||||
logTaskExit=true
|
|
||||||
}
|
}
|
||||||
@@ -129,6 +129,8 @@ local function validateComponent(comp)
|
|||||||
end
|
end
|
||||||
if lower == ".meta" then
|
if lower == ".meta" then
|
||||||
error("EINVAL: reserved path component: .meta", 3)
|
error("EINVAL: reserved path component: .meta", 3)
|
||||||
|
elseif lower:sub(#lower) == "." then
|
||||||
|
error("Cannot have empty name extention: " .. comp, 3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -397,6 +399,10 @@ end
|
|||||||
local function getFileMeta(path, noFollow)
|
local function getFileMeta(path, noFollow)
|
||||||
local real = namei(path, noFollow)
|
local real = namei(path, noFollow)
|
||||||
|
|
||||||
|
if kernel.unixSockets[real] then
|
||||||
|
return kernel.unixSockets[real].meta
|
||||||
|
end
|
||||||
|
|
||||||
if real == "/" then
|
if real == "/" then
|
||||||
return { etype = 0x00, owner = 0, group = 0, perms = 62, cmeta = "" }
|
return { etype = 0x00, owner = 0, group = 0, perms = 62, cmeta = "" }
|
||||||
end
|
end
|
||||||
@@ -596,8 +602,8 @@ function vfs.open(path, mode)
|
|||||||
if not disk then error("NODISK") end
|
if not disk then error("NODISK") end
|
||||||
if (mode=="w" or mode=="a") and disk:isReadOnly() then error("ERDONLY") end
|
if (mode=="w" or mode=="a") and disk:isReadOnly() then error("ERDONLY") end
|
||||||
|
|
||||||
if kernel.unixSockets[normalizePath(path)] then
|
if kernel.unixSockets[namei(path)] then
|
||||||
local meta = kernel.unixSockets[normalizePath(path)].meta
|
local meta = kernel.unixSockets[namei(path)].meta
|
||||||
if kernel.uid~=0 or kernel.uid~=meta.owner then
|
if kernel.uid~=0 or kernel.uid~=meta.owner then
|
||||||
local groups = (task and task.groups) or kernel.groups or {}
|
local groups = (task and task.groups) or kernel.groups or {}
|
||||||
local access=false
|
local access=false
|
||||||
@@ -606,7 +612,7 @@ function vfs.open(path, mode)
|
|||||||
end
|
end
|
||||||
if not access then error("EACCES") end
|
if not access then error("EACCES") end
|
||||||
end
|
end
|
||||||
task[fd]=kernel.unixSockets[normalizePath(path)]
|
task[fd]=kernel.unixSockets[namei(path)]
|
||||||
return fd
|
return fd
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -711,12 +717,11 @@ end
|
|||||||
|
|
||||||
function vfs.stat(path)
|
function vfs.stat(path)
|
||||||
local attrs
|
local attrs
|
||||||
local meta
|
local disk, diskPath = resolvePath(path)
|
||||||
|
local meta = getFileMeta(path)
|
||||||
if meta.etype == 0x02 then
|
if meta.etype == 0x02 then
|
||||||
attrs = { size=0, modified=0, created=0 }
|
attrs = { size=0, modified=0, created=0 }
|
||||||
else
|
else
|
||||||
local disk, diskPath = resolvePath(path)
|
|
||||||
meta = getFileMeta(path)
|
|
||||||
local ok
|
local ok
|
||||||
ok, attrs = pcall(disk.attributes, disk, diskPath)
|
ok, attrs = pcall(disk.attributes, disk, diskPath)
|
||||||
if not ok then attrs = { size=0, modified=0, created=0 } end
|
if not ok then attrs = { size=0, modified=0, created=0 } end
|
||||||
@@ -856,13 +861,13 @@ function vfs.remove(path)
|
|||||||
|
|
||||||
local meta = getFileMeta(path, true)
|
local meta = getFileMeta(path, true)
|
||||||
|
|
||||||
if kernel.unixSockets and kernel.unixSockets[normalizePath(path)] then
|
if kernel.unixSockets[namei(path)] then
|
||||||
if kernel.uid ~= 0 then
|
if kernel.uid ~= 0 then
|
||||||
if kernel.unixSockets[normalizePath(path)].meta.owner~=kernel.uid then
|
if kernel.unixSockets[namei(path)].meta.owner~=kernel.uid then
|
||||||
error("EACCES")
|
error("EACCES")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
kernel.unixSockets[normalizePath(path)] = nil
|
kernel.unixSockets[namei(path)] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if meta.etype == 0x01 then
|
if meta.etype == 0x01 then
|
||||||
@@ -973,7 +978,7 @@ local function updateMeta(path, fn, noFollow)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function vfs.chmod(path, perms)
|
function vfs.chmod(path, perms)
|
||||||
if kernel.unixSockets[normalizePath(path)] then error("EINVAL") end
|
if kernel.unixSockets[namei(path)] then error("EINVAL") end
|
||||||
local disk = resolveMount(path)
|
local disk = resolveMount(path)
|
||||||
if disk:isReadOnly() then error("ERDONLY") end
|
if disk:isReadOnly() then error("ERDONLY") end
|
||||||
local meta = getFileMeta(path)
|
local meta = getFileMeta(path)
|
||||||
@@ -985,12 +990,12 @@ end
|
|||||||
function vfs.fchmod(fd, perms)
|
function vfs.fchmod(fd, perms)
|
||||||
local file = kernel.currentTask.fd[fd]
|
local file = kernel.currentTask.fd[fd]
|
||||||
if not file then error("EBADF") end
|
if not file then error("EBADF") end
|
||||||
if file.etype==0x02 then error("EINVAL") end
|
if file.meta.etype==0x02 then error("EINVAL") end
|
||||||
vfs.chmod(file.path, perms)
|
vfs.chmod(file.path, perms)
|
||||||
end
|
end
|
||||||
|
|
||||||
function vfs.chown(path, uid, gid)
|
function vfs.chown(path, uid, gid)
|
||||||
if kernel.unixSockets[normalizePath(path)] then error("EINVAL") end
|
if kernel.unixSockets[namei(path)] then error("EINVAL") end
|
||||||
local disk = resolveMount(path)
|
local disk = resolveMount(path)
|
||||||
if disk:isReadOnly() then error("ERDONLY") end
|
if disk:isReadOnly() then error("ERDONLY") end
|
||||||
local _euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid
|
local _euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid
|
||||||
@@ -1001,14 +1006,14 @@ end
|
|||||||
function vfs.fchown(fd, uid, gid)
|
function vfs.fchown(fd, uid, gid)
|
||||||
local file = kernel.currentTask.fd[fd]
|
local file = kernel.currentTask.fd[fd]
|
||||||
if not file then error("EBADF") end
|
if not file then error("EBADF") end
|
||||||
if file.etype==0x02 then error("EINVAL") end
|
if file.meta.etype==0x02 then error("EINVAL") end
|
||||||
vfs.chown(file.path, uid, gid)
|
vfs.chown(file.path, uid, gid)
|
||||||
end
|
end
|
||||||
|
|
||||||
function vfs.exists(path)
|
function vfs.exists(path)
|
||||||
if kernel.unixSockets[normalizePath(path)] then return true end
|
if kernel.unixSockets[namei(path)] then return true end
|
||||||
local meta = getFileMeta(path, true)
|
local meta = getFileMeta(path, true)
|
||||||
if meta.etype == 0x01 then return true end
|
if meta.etype == 0x01 or meta.etype == 0x02 then return true end
|
||||||
local ok, disk, diskPath = pcall(resolvePath, path)
|
local ok, disk, diskPath = pcall(resolvePath, path)
|
||||||
if not ok then return false end
|
if not ok then return false end
|
||||||
if disk:type(diskPath) then
|
if disk:type(diskPath) then
|
||||||
@@ -1021,7 +1026,7 @@ end
|
|||||||
function vfs.type(path)
|
function vfs.type(path)
|
||||||
local meta = getFileMeta(path, true)
|
local meta = getFileMeta(path, true)
|
||||||
if meta.etype == 0x01 then return "symlink" end
|
if meta.etype == 0x01 then return "symlink" end
|
||||||
if kernel.unixSockets[normalizePath(path)] then
|
if kernel.unixSockets[namei(path)] then
|
||||||
return "socket"
|
return "socket"
|
||||||
end
|
end
|
||||||
local ok, disk, diskPath = pcall(resolvePath, path)
|
local ok, disk, diskPath = pcall(resolvePath, path)
|
||||||
@@ -50,7 +50,7 @@ function proxy:type(path, mode)
|
|||||||
if type(step[steps[#steps]]) == "table" then
|
if type(step[steps[#steps]]) == "table" then
|
||||||
return "directory"
|
return "directory"
|
||||||
end
|
end
|
||||||
error(type(step[steps[#steps]]))
|
error("ENOENT")
|
||||||
end
|
end
|
||||||
|
|
||||||
function proxy:list(path)
|
function proxy:list(path)
|
||||||
@@ -28,15 +28,15 @@ function socket.socket()
|
|||||||
local P=kernel.vfs.P
|
local P=kernel.vfs.P
|
||||||
local data=kernel.newFifo()
|
local data=kernel.newFifo()
|
||||||
local isClosed=false
|
local isClosed=false
|
||||||
kernel.vfs.newfd({
|
return kernel.vfs.newfd({
|
||||||
handle={
|
handle={
|
||||||
read=function() if isClosed then error("ECCON") end return data.read() end,
|
read=function() if isClosed then error("ECCON") end return data.pop() end,
|
||||||
write=function() if isClosed then error("ECCON") end return data.write() end,
|
write=function(data) if isClosed then error("ECCON") end return data.push(data) end,
|
||||||
close=function() isClosed = true end
|
close=function() isClosed = true end
|
||||||
},
|
},
|
||||||
type="socket",
|
type="socket",
|
||||||
refcount=1,
|
refcount=1,
|
||||||
|
socket={},
|
||||||
meta={
|
meta={
|
||||||
owner=kernel.currentTask.uid,
|
owner=kernel.currentTask.uid,
|
||||||
group=kernel.currentTask.uid,
|
group=kernel.currentTask.uid,
|
||||||
@@ -48,11 +48,20 @@ function socket.socket()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function socket.connect(fd, address)
|
function socket.connect(fd, address)
|
||||||
|
local handler
|
||||||
|
for k, v in pairs(socket.handlers) do
|
||||||
|
if string.hasPrefix(address, k) then
|
||||||
|
handler=v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
handler.connect(kernel.currentTask.fd[fd], address)
|
||||||
end
|
end
|
||||||
|
|
||||||
function socket.listen(fd, backlog)
|
function socket.listen(fd, backlog)
|
||||||
|
error("Not Implemented")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local sys=kernel.syscalls
|
||||||
|
sys["socket"]=socket.socket
|
||||||
|
|
||||||
kernel.log("Loaded socket module")
|
kernel.log("Loaded socket module")
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
--:Minify:--
|
||||||
|
local kernel=...
|
||||||
|
kernel.unixSockets={}
|
||||||
|
local socket=kernel.socket
|
||||||
@@ -203,12 +203,14 @@ function sys.collect(pid)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function sys.kill(pid)
|
function sys.kill(pid, force)
|
||||||
local task = tasks[tostring(pid)]
|
local task = tasks[tostring(pid)]
|
||||||
if not task then
|
if not task then
|
||||||
return false, "Task does not exist"
|
return false, "Task does not exist"
|
||||||
elseif task.status == "Z" then
|
elseif task.status == "Z" then
|
||||||
return false, "Task is already dead"
|
return false, "Task is already dead"
|
||||||
|
elseif task.status == "D" and not force then
|
||||||
|
return false, "Cannot kill task waiting for IO"
|
||||||
end
|
end
|
||||||
local caller = kernel.currentTask
|
local caller = kernel.currentTask
|
||||||
local ceuid = caller and (caller.euid or caller.uid) or kernel.uid
|
local ceuid = caller and (caller.euid or caller.uid) or kernel.uid
|
||||||
@@ -223,10 +225,14 @@ function sys.stop(pid)
|
|||||||
local task = tasks[tostring(pid)]
|
local task = tasks[tostring(pid)]
|
||||||
if not task then
|
if not task then
|
||||||
return false, "Task does not exist"
|
return false, "Task does not exist"
|
||||||
elseif task.status ~= "R" then
|
elseif task.status ~= "R" and task.status ~= "S" then
|
||||||
return false, "Cannot stop non-running task"
|
return false, "Cannot stop non-running task"
|
||||||
|
else
|
||||||
|
if task.status == "S" then
|
||||||
|
task.status = "ST"
|
||||||
else
|
else
|
||||||
task.status = "T"
|
task.status = "T"
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -235,10 +241,14 @@ function sys.continue(pid)
|
|||||||
local task = tasks[tostring(pid)]
|
local task = tasks[tostring(pid)]
|
||||||
if not task then
|
if not task then
|
||||||
return false, "Task does not exist"
|
return false, "Task does not exist"
|
||||||
elseif task.status ~= "T" then
|
elseif task.status ~= "T" and task.status ~= "ST" then
|
||||||
return false, "Task is not stopped"
|
return false, "Task is not stopped"
|
||||||
|
else
|
||||||
|
if task.status == "ST" then
|
||||||
|
task.status = "S"
|
||||||
else
|
else
|
||||||
task.status = "R"
|
task.status = "R"
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -351,6 +361,11 @@ function kernel.main()
|
|||||||
task.sleep = 0
|
task.sleep = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if task.status == "ST" and kernel.EFI:getEpochMs() >= task.sleep then
|
||||||
|
task.status = "T"
|
||||||
|
task.sleep = 0
|
||||||
|
end
|
||||||
|
|
||||||
if task.status == "D" then
|
if task.status == "D" then
|
||||||
if task.ksh then
|
if task.ksh then
|
||||||
coroutine.resume(task.ksh)
|
coroutine.resume(task.ksh)
|
||||||
@@ -364,14 +379,19 @@ function kernel.main()
|
|||||||
|
|
||||||
if task.sigq and #task.sigq ~= 0 and task.sigh then
|
if task.sigq and #task.sigq ~= 0 and task.sigh then
|
||||||
local coro = coroutine.create(task.sigh)
|
local coro = coroutine.create(task.sigh)
|
||||||
local status,err=coroutine.resumeWithTimeout(coro, 100, table.remove(task.sigq, 1))
|
local status,err
|
||||||
if status=="error" then
|
if kernel.config.preempt then
|
||||||
task.sigd.error=err
|
status,err=coroutine.resumeWithTimeout(coro, 100, table.remove(task.sigq, 1))
|
||||||
|
else
|
||||||
|
status,err=coroutine.resume(coro, table.remove(task.sigq, 1))
|
||||||
|
end
|
||||||
|
if status=="error" or status==false then
|
||||||
|
task.sigd.error=err or "Unknown"
|
||||||
task.sigd.active=false
|
task.sigd.active=false
|
||||||
task.sigh=nil
|
task.sigh=nil
|
||||||
task.sigq=nil
|
task.sigq=nil
|
||||||
task.sigd=nil
|
task.sigd=nil
|
||||||
elseif status=="success" then
|
elseif status=="success" or status==true then
|
||||||
if err=="syscall" then
|
if err=="syscall" then
|
||||||
task.sigd.error="Cannot execute syscalls from signals"
|
task.sigd.error="Cannot execute syscalls from signals"
|
||||||
task.sigd.active=false
|
task.sigd.active=false
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
--:Minify:--
|
|
||||||
local kernel=...
|
|
||||||
kernel.unixSockets={}
|
|
||||||
@@ -827,6 +827,12 @@ builtinCmds.df = function(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
builtinCmds.ops = function()
|
||||||
|
for i,v in pairs(math) do
|
||||||
|
print(i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function listDir(dir, prefix)
|
local function listDir(dir, prefix)
|
||||||
local ok, entries = pcall(syscall.listdir, dir)
|
local ok, entries = pcall(syscall.listdir, dir)
|
||||||
if not ok or not entries then return {} end
|
if not ok or not entries then return {} end
|
||||||
@@ -981,6 +987,7 @@ local function doTabComplete(input, cursorPos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local lastghost=""
|
||||||
local function getUserInput()
|
local function getUserInput()
|
||||||
syscall.devctl(1,"sfgc",0x00FF00)
|
syscall.devctl(1,"sfgc",0x00FF00)
|
||||||
syscall.write(1, userhost)
|
syscall.write(1, userhost)
|
||||||
@@ -1147,7 +1154,7 @@ end
|
|||||||
|
|
||||||
local function runCommand(command)
|
local function runCommand(command)
|
||||||
do
|
do
|
||||||
local func = load("return "..command, "@equation", "t", {})
|
local func = load("return "..command, "@equation", "t", math)
|
||||||
if func then
|
if func then
|
||||||
local ok, result = pcall(func)
|
local ok, result = pcall(func)
|
||||||
if ok and type(result)=="number" then print(result); return end
|
if ok and type(result)=="number" then print(result); return end
|
||||||
@@ -95,6 +95,8 @@ local screenSizeStr = syscall.devctl(1, "size")
|
|||||||
local sizeX = tonumber(screenSizeStr:match("^(%d+)")) or 80
|
local sizeX = tonumber(screenSizeStr:match("^(%d+)")) or 80
|
||||||
|
|
||||||
local list = fs.list(dir)
|
local list = fs.list(dir)
|
||||||
|
list[#list+1] = "."
|
||||||
|
list[#list+1] = ".."
|
||||||
if not cloptions.a then
|
if not cloptions.a then
|
||||||
for i = #list, 1, -1 do
|
for i = #list, 1, -1 do
|
||||||
if list[i]:sub(1, 1) == "." then table.remove(list, i) end
|
if list[i]:sub(1, 1) == "." then table.remove(list, i) end
|
||||||
@@ -4,5 +4,9 @@
|
|||||||
"hysh",
|
"hysh",
|
||||||
"lua",
|
"lua",
|
||||||
"micro",
|
"micro",
|
||||||
"sysinit"
|
"sysinit",
|
||||||
|
"bit32",
|
||||||
|
"json",
|
||||||
|
"muxzcat",
|
||||||
|
"spm"
|
||||||
]
|
]
|
||||||
@@ -300,6 +300,7 @@ local function getUserInput(prompt, history)
|
|||||||
end
|
end
|
||||||
|
|
||||||
c(C_PROMPT); w("HyperionOS " .. _VERSION .. "\n")
|
c(C_PROMPT); w("HyperionOS " .. _VERSION .. "\n")
|
||||||
|
w("Type \"exit()\" to exit.")
|
||||||
c(C_NIL)
|
c(C_NIL)
|
||||||
w("Interactive Lua REPL. exit() to quit.\n\n")
|
w("Interactive Lua REPL. exit() to quit.\n\n")
|
||||||
c(1)
|
c(1)
|
||||||
@@ -1 +0,0 @@
|
|||||||
[symlinks]
|
|
||||||
1973
Src/xz/data/lib/xz
Normal file
1973
Src/xz/data/lib/xz
Normal file
File diff suppressed because it is too large
Load Diff
13
build.py
13
build.py
@@ -27,6 +27,7 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
@@ -98,16 +99,18 @@ def process_root(src_root: Path, out_root: Path, minify: bool, micro: bool, arch
|
|||||||
if prod != True:
|
if prod != True:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
data_dir=pkg_dir / "data"
|
||||||
|
|
||||||
|
if not data_dir.is_dir():
|
||||||
|
continue
|
||||||
|
|
||||||
print(f"== Package: {pkg_dir.name} ==")
|
print(f"== Package: {pkg_dir.name} ==")
|
||||||
|
|
||||||
for src in sorted(pkg_dir.rglob("*")):
|
for src in sorted(data_dir.rglob("*")):
|
||||||
if not src.is_file():
|
if not src.is_file():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rel = src.relative_to(pkg_dir)
|
rel = src.relative_to(data_dir)
|
||||||
|
|
||||||
if rel.name=="$PKGCONFIG.ini":
|
|
||||||
continue
|
|
||||||
|
|
||||||
dst = out_root / rel
|
dst = out_root / rel
|
||||||
if prod:
|
if prod:
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ local function printTitle()
|
|||||||
print("DESCLAIMER: This will wipe your system on install...")
|
print("DESCLAIMER: This will wipe your system on install...")
|
||||||
term.write("Bspc: Back | Enter: execute | Tab: description")
|
term.write("Bspc: Back | Enter: execute | Tab: description")
|
||||||
end
|
end
|
||||||
printTitle()
|
|
||||||
|
|
||||||
local function pc(text, y, c)
|
local function pc(text, y, c)
|
||||||
local x=(w/2)-#text/2
|
local x=(w/2)-#text/2
|
||||||
@@ -110,9 +109,7 @@ end
|
|||||||
|
|
||||||
local releases,page={},1
|
local releases,page={},1
|
||||||
while true do
|
while true do
|
||||||
local handle=http.get("https://git.astronand.dev/api/v1/repos/Hyperion/HyperionOS/releases?page="..tostring(page).."&limit=1")
|
local raw=download("https://git.astronand.dev/api/v1/repos/Hyperion/HyperionOS/releases?page="..tostring(page).."&limit=1")
|
||||||
local raw=handle.readAll()
|
|
||||||
handle.close()
|
|
||||||
if raw=="[]\n" then
|
if raw=="[]\n" then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -130,6 +127,8 @@ local function makePage(start, num)
|
|||||||
desc=release.body,
|
desc=release.body,
|
||||||
color=release.prerelease and colors.orange or colors.white,
|
color=release.prerelease and colors.orange or colors.white,
|
||||||
func=function()
|
func=function()
|
||||||
|
term.clear()
|
||||||
|
term.setCursorPos(1,1)
|
||||||
local data=download("https://git.astronand.dev/Hyperion/HyperionOS/raw/tag/"..release.tag_name.."/Src/install.json")
|
local data=download("https://git.astronand.dev/Hyperion/HyperionOS/raw/tag/"..release.tag_name.."/Src/install.json")
|
||||||
if not data then
|
if not data then
|
||||||
term.clear()
|
term.clear()
|
||||||
@@ -158,7 +157,9 @@ local function makePage(start, num)
|
|||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
printTitle()
|
||||||
menu(makePage(1,5))
|
menu(makePage(1,5))
|
||||||
|
if not exitall then error("Exited") end
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@@ -187,8 +188,9 @@ local function delDir(dir)
|
|||||||
fs.delete(dir..list[i])
|
fs.delete(dir..list[i])
|
||||||
printc(colors.gray, "[ ", colors.red, " DELET ", colors.gray, " ] ", colors.white, dir..list[i])
|
printc(colors.gray, "[ ", colors.red, " DELET ", colors.gray, " ] ", colors.white, dir..list[i])
|
||||||
end
|
end
|
||||||
sleep(.1)
|
sleep(.01)
|
||||||
end
|
end
|
||||||
|
sleep(.15)
|
||||||
end
|
end
|
||||||
|
|
||||||
delDir("/")
|
delDir("/")
|
||||||
@@ -210,7 +212,9 @@ local function installdir(path, dir, pkg)
|
|||||||
else
|
else
|
||||||
error("Uh Oh: unknown entrytype "..entry.path)
|
error("Uh Oh: unknown entrytype "..entry.path)
|
||||||
end
|
end
|
||||||
|
sleep(.01)
|
||||||
end
|
end
|
||||||
|
sleep(.15)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function installpkg(pkg)
|
local function installpkg(pkg)
|
||||||
|
|||||||
55
misc/spm.lua
Normal file
55
misc/spm.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
local cloptions = {
|
||||||
|
a = false,
|
||||||
|
h = false,
|
||||||
|
l = false,
|
||||||
|
help = false,
|
||||||
|
}
|
||||||
|
local inpArgs = { ... }
|
||||||
|
local args = {}
|
||||||
|
|
||||||
|
for _, v in pairs(inpArgs) do
|
||||||
|
if v:sub(1, 2) == "--" then
|
||||||
|
local opt = v:sub(3)
|
||||||
|
if cloptions[opt] == nil then
|
||||||
|
print("spm: unrecognized option '" .. v .. "'.")
|
||||||
|
print("try 'spm --help' for more information.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
cloptions[opt] = true
|
||||||
|
elseif v:sub(1, 1) == "-" then
|
||||||
|
for i = 2, #v do
|
||||||
|
local opt = v:sub(i, i)
|
||||||
|
if cloptions[opt] == nil then
|
||||||
|
print("spm: invalid option '-" .. opt .. "'.")
|
||||||
|
print("try 'spm --help' for more information.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
cloptions[opt] = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(args, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local http=http or require("http")
|
||||||
|
local json=json or require("json")
|
||||||
|
local xz =xz or require("xz")
|
||||||
|
|
||||||
|
if cloptions.help then
|
||||||
|
print("Usage: spm [COMMAND] [OPTION] [packages]")
|
||||||
|
print("The Simple package Mannager.")
|
||||||
|
print("")
|
||||||
|
print("Commands:")
|
||||||
|
print(" remove Remove package(s)")
|
||||||
|
print(" update Updates package(s)")
|
||||||
|
print(" install Install package(s)")
|
||||||
|
print(" sync Syncs local registry with servers")
|
||||||
|
print("")
|
||||||
|
print("Options:")
|
||||||
|
print(" --help display this help and exit")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getustar()
|
||||||
|
|
||||||
|
end
|
||||||
14
packages/spm.pkg
Normal file
14
packages/spm.pkg
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"authors":[
|
||||||
|
"Astronand"
|
||||||
|
],
|
||||||
|
"versions":{
|
||||||
|
"1.0.0":{
|
||||||
|
"dependencies":[
|
||||||
|
"json",
|
||||||
|
"xz"
|
||||||
|
],
|
||||||
|
"package":"https://git.astronand.dev/Hyperion/HyperionOS/raw/branch/main/packages/raw/spm.sp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user