Add capability for package manager lib to install to other directories
This commit is contained in:
parent
441e2a3fdb
commit
cba35c2197
@ -1,4 +1,5 @@
|
|||||||
local mfs=dofile("/lib/mfs.lua")
|
local mfs=dofile("/lib/mfs.lua")
|
||||||
|
local local_pkg_files=false
|
||||||
local pkg_url="https://git.osmarks.tk/heavpoot/packages1/raw/branch/master/"
|
local pkg_url="https://git.osmarks.tk/heavpoot/packages1/raw/branch/master/"
|
||||||
local res={}
|
local res={}
|
||||||
local cache={}
|
local cache={}
|
||||||
@ -10,6 +11,18 @@ function res.get_pkg_url()
|
|||||||
return pkg_url
|
return pkg_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function res.set_local(x)
|
||||||
|
local_pkg_files=x
|
||||||
|
end
|
||||||
|
|
||||||
|
function res.set_install_dir(x)
|
||||||
|
return mfs.setcd(x)
|
||||||
|
end
|
||||||
|
|
||||||
|
function res.get_install_dir()
|
||||||
|
return mfs.getcd()
|
||||||
|
end
|
||||||
|
|
||||||
function hget(x)
|
function hget(x)
|
||||||
local f=http.get(x)
|
local f=http.get(x)
|
||||||
if not f then return nil end
|
if not f then return nil end
|
||||||
@ -18,8 +31,20 @@ function hget(x)
|
|||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function res.pkgfile(p,x)
|
||||||
|
if local_pkg_files then
|
||||||
|
local cd=mfs.getcd()
|
||||||
|
mfs.setcd("")
|
||||||
|
local i=mfs.read(pkg_url.."/"..p.."/"..x)
|
||||||
|
mfs.setcd(cd)
|
||||||
|
return i
|
||||||
|
else
|
||||||
|
return hget(pkg_url..p.."/"..x)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function res.pkgmeta(p)
|
function res.pkgmeta(p)
|
||||||
local mt=hget(pkg_url..p.."/pkgmeta.ltn")
|
local mt=res.pkgfile(p,"pkgmeta.ltn")
|
||||||
if not mt then error("Package "..p.." does not have a pkgmeta.ltn!") end
|
if not mt then error("Package "..p.." does not have a pkgmeta.ltn!") end
|
||||||
return textutils.unserialize(mt)
|
return textutils.unserialize(mt)
|
||||||
end
|
end
|
||||||
@ -34,7 +59,7 @@ function res.pkginst(p)
|
|||||||
for i,thing in pairs(mt.files) do
|
for i,thing in pairs(mt.files) do
|
||||||
mfs.mmkdir("/"..i)
|
mfs.mmkdir("/"..i)
|
||||||
for _,v in pairs(thing) do
|
for _,v in pairs(thing) do
|
||||||
mfs.write("/"..i.."/"..v,hget(pkg_url..p.."/"..i.."/"..v))
|
mfs.write(i.."/"..v,res.pkgfile(p,i.."/"..v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -49,7 +74,7 @@ function res.pkguinst(p)
|
|||||||
if mt.files then
|
if mt.files then
|
||||||
for i,thing in pairs(mt.files) do
|
for i,thing in pairs(mt.files) do
|
||||||
for _,v in pairs(thing) do
|
for _,v in pairs(thing) do
|
||||||
fs.delete("/"..i.."/"..v)
|
mfs.rm(i.."/"..v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
["version"] = "0.1.0",
|
["version"] = "0.1.1",
|
||||||
["dependencies"] = {
|
["dependencies"] = {
|
||||||
"mfs",
|
"mfs",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user