mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-25 12:42:10 -05:00
Compare commits
5 Commits
360bb88ac3
...
6a39fe1743
Author | SHA1 | Date | |
---|---|---|---|
|
6a39fe1743 | ||
|
45c70cbaa6 | ||
|
89ab49faf6 | ||
|
f86f7d54ad | ||
|
4e3df481cc |
@ -67,7 +67,6 @@ end
|
|||||||
|
|
||||||
function dl.protos.http(host, optPort, path, dest, url) -- string string string number -- boolean -- Downloads *url* to *dest* via the internet card, if available.
|
function dl.protos.http(host, optPort, path, dest, url) -- string string string number -- boolean -- Downloads *url* to *dest* via the internet card, if available.
|
||||||
if not component.list("internet")() then
|
if not component.list("internet")() then
|
||||||
print("Internet card unavailable, falling back to proxy.")
|
|
||||||
local proto,host,sPort,path = parseURL(url)
|
local proto,host,sPort,path = parseURL(url)
|
||||||
local proxy = os.getenv(proto:upper().."_PROXY")
|
local proxy = os.getenv(proto:upper().."_PROXY")
|
||||||
if not proxy and fs.exists("/boot/cfg/"..proto.."_proxy") then
|
if not proxy and fs.exists("/boot/cfg/"..proto.."_proxy") then
|
||||||
@ -76,7 +75,7 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
if not proxy then error("No internet card or HTTP(S) proxy available") end
|
if not proxy then error("No internet card or HTTP(S) proxy available") end
|
||||||
print("Proxy found: "..proxy)
|
print("Internet card unavailable, falling back to proxy "..proxy)
|
||||||
if optPort then host=string.format("%s:%i",host,optPort) end
|
if optPort then host=string.format("%s:%i",host,optPort) end
|
||||||
return dl.wget(string.format("%s/%s%s",proxy,host,path),dest)
|
return dl.wget(string.format("%s/%s%s",proxy,host,path),dest)
|
||||||
end
|
end
|
||||||
@ -88,7 +87,11 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
repeat
|
repeat
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
until R.finishConnect()
|
until R.finishConnect()
|
||||||
local code, message, headers = R.response()
|
local code, messsage, headers
|
||||||
|
repeat
|
||||||
|
coroutine.yield()
|
||||||
|
code, message, headers = R.response()
|
||||||
|
until code or message
|
||||||
if code > 299 or code < 200 then
|
if code > 299 or code < 200 then
|
||||||
return false, code, message
|
return false, code, message
|
||||||
end
|
end
|
||||||
@ -97,7 +100,7 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
io.write(string.format("Saving %s to %s...\n", url, dest))
|
io.write(string.format("Saving %s to %s...\n", url, dest))
|
||||||
repeat
|
repeat
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
ns = R.read(2048)
|
ns = R.read()
|
||||||
f:write(ns or "")
|
f:write(ns or "")
|
||||||
until not ns
|
until not ns
|
||||||
f:close()
|
f:close()
|
||||||
|
@ -15,7 +15,7 @@ local function rzero()
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
pkgfs.component = {seek = rfalse, makeDirectory = rfalse, write = rfalse, rename = rfalse, setlabel = rfalse, spaceUsed = rzero, spaceTotal = rzero, lastModified = rzero}
|
pkgfs.component = {seek = rfalse, makeDirectory = rfalse, write = rfalse, rename = rfalse, setlabel = rfalse, spaceUsed = rzero, spaceTotal = rzero, lastModified = rzero, address = "pkgfs"}
|
||||||
|
|
||||||
local function fopen(path,comp)
|
local function fopen(path,comp)
|
||||||
local f
|
local f
|
||||||
@ -31,6 +31,11 @@ local function fnormalize(s)
|
|||||||
return table.concat(fs.segments(s),"/")
|
return table.concat(fs.segments(s),"/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function pkgfs.component.exists(path)
|
||||||
|
path = fnormalize(path)
|
||||||
|
return findex[path] and true
|
||||||
|
end
|
||||||
|
|
||||||
function pkgfs.component.list(path)
|
function pkgfs.component.list(path)
|
||||||
path = fnormalize(path).."/"
|
path = fnormalize(path).."/"
|
||||||
local ft,rt = {},{}
|
local ft,rt = {},{}
|
||||||
@ -107,8 +112,7 @@ local function index()
|
|||||||
fname = "/"..fnormalize(os.getenv("PWD").."/"..fname)
|
fname = "/"..fnormalize(os.getenv("PWD").."/"..fname)
|
||||||
end
|
end
|
||||||
local f = fopen(fname,comp)
|
local f = fopen(fname,comp)
|
||||||
if not f then error("unable to open file") end
|
if not f then error("unable to open file "..fname) end
|
||||||
print(fname)
|
|
||||||
for name, read, fsize in mtar.iter(f) do
|
for name, read, fsize in mtar.iter(f) do
|
||||||
findex[fnormalize(name)] = {fname,comp}
|
findex[fnormalize(name)] = {fname,comp}
|
||||||
end
|
end
|
||||||
@ -132,4 +136,11 @@ end
|
|||||||
|
|
||||||
fs.makeDirectory("/pkg")
|
fs.makeDirectory("/pkg")
|
||||||
fs.mount("/pkg",pkgfs.component)
|
fs.mount("/pkg",pkgfs.component)
|
||||||
|
for _,file in ipairs(fs.list("/boot/pkg/")) do
|
||||||
|
if file:sub(-5) == ".mtar" then
|
||||||
|
pcall(pkgfs.add,"/boot/pkg/"..file)
|
||||||
|
elseif file:sub(-9) == ".mtar.lss" then
|
||||||
|
pcall(pkgfs.add,"/boot/pkg/"..file,true)
|
||||||
|
end
|
||||||
|
end
|
||||||
return pkgfs
|
return pkgfs
|
||||||
|
@ -128,6 +128,7 @@ function pkg.upgrade(force) -- boolean -- boolean -- Upgrades all packages on th
|
|||||||
for repo,info in pairs(getSources()) do
|
for repo,info in pairs(getSources()) do
|
||||||
for pkgname,pkg in pairs(getRepoMeta(repo)) do
|
for pkgname,pkg in pairs(getRepoMeta(repo)) do
|
||||||
if pkg.version ~= installed[pkgname].version or force then
|
if pkg.version ~= installed[pkgname].version or force then
|
||||||
|
pkg.remove(pkgname)
|
||||||
dl(info.path.."/"..pkg.filename,"/boot/pkg/"..pkg.filename)
|
dl(info.path.."/"..pkg.filename,"/boot/pkg/"..pkg.filename)
|
||||||
installed[pkgname] = pkg
|
installed[pkgname] = pkg
|
||||||
pcall(activatePackage,"/boot/pkg/"..pkg.filename,pkg.compressed)
|
pcall(activatePackage,"/boot/pkg/"..pkg.filename,pkg.compressed)
|
||||||
|
@ -29,7 +29,7 @@ function rc.load(name,force) -- string boolean -- table -- Attempts to load serv
|
|||||||
end
|
end
|
||||||
if service[name] then return true end
|
if service[name] then return true end
|
||||||
service[name] = setmetatable({},{__index=_G})
|
service[name] = setmetatable({},{__index=_G})
|
||||||
local f = io.open("/boot/service/"..name..".lua","rb")
|
local f = io.open("/boot/service/"..name..".lua","rb") or io.open("/pkg/service/"..name..".lua","rb")
|
||||||
local res = load(f:read("*a"),name,"t",service[name])()
|
local res = load(f:read("*a"),name,"t",service[name])()
|
||||||
f:close()
|
f:close()
|
||||||
return res
|
return res
|
||||||
|
@ -15,7 +15,7 @@ _G.package = {}
|
|||||||
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
|
||||||
function require(f,force) -- string boolean -- table -- searches for a library with name *f* and returns what the library returns, if possible. if *force* is set, loads the library even if it is cached
|
function require(f,force) -- string boolean -- table -- searches for a library with name *f* and returns what the library returns, if possible. if *force* is set, loads the library even if it is cached
|
||||||
if not package.loaded[f] or force then
|
if not package.loaded[f] or force then
|
||||||
local lib = os.getenv("LIB") or "/boot/lib"
|
local lib = os.getenv("LIB") or "/boot/lib\n/pkg/lib"
|
||||||
for d in lib:gmatch("[^\n]+") do
|
for d in lib:gmatch("[^\n]+") do
|
||||||
if fs.exists(d.."/"..f) then
|
if fs.exists(d.."/"..f) then
|
||||||
package.loaded[f] = runfile(d.."/"..f)
|
package.loaded[f] = runfile(d.."/"..f)
|
||||||
|
Loading…
Reference in New Issue
Block a user