add pkgfs.component.exists and do automounting of archives
This commit is contained in:
parent
4e3df481cc
commit
f86f7d54ad
@ -15,7 +15,7 @@ local function rzero()
|
||||
return 0
|
||||
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 f
|
||||
@ -31,6 +31,11 @@ local function fnormalize(s)
|
||||
return table.concat(fs.segments(s),"/")
|
||||
end
|
||||
|
||||
function pkgfs.component.exists(path)
|
||||
path = fnormalize(path)
|
||||
return findex[path] and true
|
||||
end
|
||||
|
||||
function pkgfs.component.list(path)
|
||||
path = fnormalize(path).."/"
|
||||
local ft,rt = {},{}
|
||||
@ -107,8 +112,7 @@ local function index()
|
||||
fname = "/"..fnormalize(os.getenv("PWD").."/"..fname)
|
||||
end
|
||||
local f = fopen(fname,comp)
|
||||
if not f then error("unable to open file") end
|
||||
print(fname)
|
||||
if not f then error("unable to open file "..fname) end
|
||||
for name, read, fsize in mtar.iter(f) do
|
||||
findex[fnormalize(name)] = {fname,comp}
|
||||
end
|
||||
@ -132,4 +136,11 @@ end
|
||||
|
||||
fs.makeDirectory("/pkg")
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user