* luci/libs/uvl:
- implement bytecode loading in luci.uvl.read_scheme() - add "uvlc" executable to byte-compile arbitary schemes - add lib/uci/schema/bytecode/ directory
This commit is contained in:
parent
8af9060efd
commit
3315203f2f
2 changed files with 53 additions and 20 deletions
|
@ -355,32 +355,43 @@ end
|
|||
function UVL.read_scheme( self, scheme, alias )
|
||||
|
||||
local so = luci.uvl.scheme( self, scheme )
|
||||
local bc = "%s/bytecode/%s.lua" %{ self.schemedir, scheme }
|
||||
|
||||
local schemes = { }
|
||||
local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
|
||||
if not luci.fs.access(bc) then
|
||||
local schemes = { }
|
||||
local files = luci.fs.glob(self.schemedir .. '/*/' .. scheme)
|
||||
|
||||
if files then
|
||||
for i, file in ipairs( files ) do
|
||||
if not luci.fs.access(file) then
|
||||
return so:error(ERR.SME_READ(so,file))
|
||||
if files then
|
||||
for i, file in ipairs( files ) do
|
||||
if not luci.fs.access(file) then
|
||||
return false, so:error(ERR.SME_READ(so,file))
|
||||
end
|
||||
|
||||
local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
|
||||
|
||||
local sd, err = uci:get_all( luci.fs.basename(file) )
|
||||
|
||||
if not sd then
|
||||
return false, ERR.UCILOAD(so, err)
|
||||
end
|
||||
|
||||
table.insert( schemes, sd )
|
||||
end
|
||||
|
||||
local uci = luci.model.uci.cursor( luci.fs.dirname(file), default_savedir )
|
||||
|
||||
local sd, err = uci:get_all( luci.fs.basename(file) )
|
||||
|
||||
if not sd then
|
||||
return false, ERR.UCILOAD(so, err)
|
||||
end
|
||||
|
||||
table.insert( schemes, sd )
|
||||
local ok, err = self:_read_scheme_parts( so, schemes )
|
||||
if ok and alias then self.packages[alias] = self.packages[scheme] end
|
||||
return ok, err
|
||||
else
|
||||
return false, so:error(ERR.SME_FIND(so, self.schemedir))
|
||||
end
|
||||
|
||||
local ok, err = self:_read_scheme_parts( so, schemes )
|
||||
if ok and alias then self.packages[alias] = self.packages[scheme] end
|
||||
return ok, err
|
||||
else
|
||||
return false, so:error(ERR.SME_FIND(so, self.schemedir))
|
||||
local sc = loadfile(bc)
|
||||
if sc then
|
||||
self.packages[scheme] = sc()
|
||||
return true
|
||||
else
|
||||
return false, so:error(ERR.SME_READ(so,file))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
22
libs/uvl/root/usr/bin/uvlc
Executable file
22
libs/uvl/root/usr/bin/uvlc
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/lua
|
||||
|
||||
|
||||
if arg[1] then
|
||||
require("luci.util")
|
||||
require("luci.uvl")
|
||||
require("luci.fs")
|
||||
|
||||
local uvl = luci.uvl.UVL()
|
||||
local scheme, err = uvl:get_scheme( arg[1] )
|
||||
|
||||
if scheme then
|
||||
luci.fs.writefile(
|
||||
"%s/bytecode/%s.lua" %{ uvl.schemedir, arg[1] },
|
||||
luci.util.get_bytecode(scheme)
|
||||
)
|
||||
else
|
||||
print("Error:", err:string())
|
||||
end
|
||||
else
|
||||
print( "Usage: uvlc <scheme>" )
|
||||
end
|
Loading…
Reference in a new issue