fixed a bunch of stuff with all the update/package related programs, added pkg, etc.
This commit is contained in:
parent
b271341b2b
commit
ed8aca42e0
57
exec/pkg.lua
Normal file
57
exec/pkg.lua
Normal file
@ -0,0 +1,57 @@
|
||||
local tA = {...}
|
||||
local rf = tA[1]
|
||||
local wget = wget or loadfile("/boot/exec/wget.lua")
|
||||
if not wget then
|
||||
print("wget is required to run this program")
|
||||
elseif rf and pcall(fs.exists,rf) then
|
||||
local pref = tA[2] or "/boot/"
|
||||
local files = {}
|
||||
local lrf = "/tmp/rf.txt"
|
||||
|
||||
local function precipe(s)
|
||||
local t = {}
|
||||
for line in s:gmatch("[^\n\r]+") do
|
||||
t[#t+1] = {line:match("(.+)[ \t](.+)")}
|
||||
local S = t[#t][1]
|
||||
t[#t][1] = ""
|
||||
for c in S:gmatch(".") do
|
||||
if (string.byte(c) > 31 and string.byte(c) < 127) then
|
||||
t[#t][1] = t[#t][1]..c
|
||||
end
|
||||
local S = t[#t][2]
|
||||
t[#t][2] = ""
|
||||
for c in S:gmatch(".") do
|
||||
if (string.byte(c) > 31 and string.byte(c) < 127) then
|
||||
t[#t][2] = t[#t][2]..c
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
local function dl(p,u)
|
||||
if u:sub(1,8) == "https://" or u:sub(1,7) == "http://" then
|
||||
wget(u,pref..p)
|
||||
end
|
||||
end
|
||||
|
||||
if rf:sub(1,8) == "https://" or rf:sub(1,7) == "http://" then
|
||||
wget(rf,"/tmp/rf.txt")
|
||||
else
|
||||
lrf = rf
|
||||
end
|
||||
|
||||
local f=io.open(lrf)
|
||||
if not f then return false, "no recipe" end
|
||||
files=precipe(f:read("*a"))
|
||||
f:close()
|
||||
local count = 1
|
||||
local total = #files
|
||||
|
||||
for k,v in ipairs(files) do
|
||||
print(tostring(count).."/"..tostring(total)..": "..pref..v[2])
|
||||
dl(v[2],v[1])
|
||||
count=count+1
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ else
|
||||
local repo = tA[1] or "https://lain.shadowkat.net/~izaya/ocdoc/PsychOS-build/fsdev/PsychOS-fsdev-latest/"
|
||||
local fl = repo .. "files.txt"
|
||||
local pref = tA[1] or "/boot/"
|
||||
local files = {{"everything"},{"minimal"},{"headless"},{"severything"},{"sminimal"},{"sheadless"},{"exec/addperm"},{"exec/cat"},{"exec/free"},{"exec/ls"},{"exec/luash"},{"exec/nbsrv"},{"exec/nshd"},{"exec/nsh"},{"exec/passwd"},{"exec/ps"},{"exec/rmperm"},{"exec/skex2"},{"exec/su"},{"exec/wget"}}
|
||||
local files = {{"everything"},{"minimal"},{"headless"},{"severything"},{"sminimal"},{"sheadless"},{"exec/addperm"},{"exec/cat"},{"exec/free"},{"exec/ls"},{"exec/luash"},{"exec/nbsrv"},{"exec/nshd"},{"exec/nsh"},{"exec/passwd"},{"exec/ps"},{"exec/rmperm"},{"exec/skex2"},{"exec/su"},{"exec/wget"},{"exec/update.lua"},{"exec/pkg.lua"}}
|
||||
local count = 1
|
||||
local total = #files
|
||||
print(total)
|
||||
|
@ -8,6 +8,10 @@ if not f then return false end
|
||||
repeat
|
||||
coroutine.yield()
|
||||
until R.finishConnect()
|
||||
local code, msg = R.response()
|
||||
if code ~= 200 then
|
||||
return false, code, msg
|
||||
end
|
||||
repeat
|
||||
coroutine.yield()
|
||||
ns = R.read(2048)
|
||||
|
Loading…
Reference in New Issue
Block a user