fixed a bunch of stuff with all the update/package related programs, added pkg, etc.

This commit is contained in:
Izaya 2017-09-23 11:24:37 +10:00 committed by Izaya
parent faac6621a5
commit 334f3a4d50
3 changed files with 62 additions and 1 deletions

57
exec/pkg.lua Normal file
View 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

View File

@ -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)

View File

@ -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)