luci-0.8: drop lpk, unused
This commit is contained in:
parent
280e9f296c
commit
d4644a3a73
11 changed files with 0 additions and 236 deletions
|
@ -1,2 +0,0 @@
|
||||||
include ../../build/config.mk
|
|
||||||
include ../../build/module.mk
|
|
|
@ -1,41 +0,0 @@
|
||||||
module("luci.lpk", package.seeall)
|
|
||||||
require("luci.lpk.util")
|
|
||||||
require("luci.lpk.core")
|
|
||||||
|
|
||||||
__appname__ = "LuCI »lpk« Package Manager"
|
|
||||||
__version__ = "0.1"
|
|
||||||
__authors__ = "Steven Barth, Jo-Philipp Wich"
|
|
||||||
__cpyrght__ = string.format("Copyright (c) 2008 %s", __authors__)
|
|
||||||
|
|
||||||
|
|
||||||
options, arguments = luci.lpk.util.getopt(arg)
|
|
||||||
config = luci.util.dtable()
|
|
||||||
machine = luci.lpk.core.Machine()
|
|
||||||
|
|
||||||
local cfgdump = loadfile("/etc/lpk.conf")
|
|
||||||
if cfgdump then
|
|
||||||
setfenv(cfgdump, config)
|
|
||||||
pcall(cfgdump)
|
|
||||||
end
|
|
||||||
|
|
||||||
if #arguments < 1 then
|
|
||||||
luci.lpk.util.splash()
|
|
||||||
else
|
|
||||||
local task, error = machine:task(table.remove(arguments, 1),
|
|
||||||
unpack(arguments))
|
|
||||||
|
|
||||||
if task then
|
|
||||||
local stat, error = task:perform()
|
|
||||||
if not stat then
|
|
||||||
luci.util.perror(error or task.register.errstr or "Unknown Error")
|
|
||||||
os.exit(task.register.error or 1)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
luci.util.perror((error or "Unknown Error") .. "\n")
|
|
||||||
luci.lpk.util.splash()
|
|
||||||
os.exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
module("luci.lpk.core", package.seeall)
|
|
||||||
require("luci.util")
|
|
||||||
|
|
||||||
Task = luci.util.class()
|
|
||||||
|
|
||||||
function Task.__init__(self, machine, register, start)
|
|
||||||
self.machine = machine
|
|
||||||
|
|
||||||
-- The queue that has to be processed
|
|
||||||
self.work = {start}
|
|
||||||
|
|
||||||
-- The queue that has to be processed in case of rollback
|
|
||||||
self.done = {}
|
|
||||||
|
|
||||||
-- The Task register
|
|
||||||
self.register = register
|
|
||||||
end
|
|
||||||
|
|
||||||
function Task.rollback(self)
|
|
||||||
if #self.done < 1 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local state = table.remove(self.done)
|
|
||||||
if not state.rollback then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local ret, err = pcall(state.rollback, state, self.register)
|
|
||||||
|
|
||||||
if ret then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false, err
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Task.step(self)
|
|
||||||
local state = table.remove(self.work)
|
|
||||||
local ret, next = pcall(state.process, self.register)
|
|
||||||
|
|
||||||
if ret then
|
|
||||||
if next then
|
|
||||||
local nstate = self.machine:state(next)
|
|
||||||
if nstate then
|
|
||||||
table.insert(self.work, state)
|
|
||||||
table.insert(self.work, nstate)
|
|
||||||
else
|
|
||||||
self.register.error = 2
|
|
||||||
self.register.errstr = "Unknown state: " .. next
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.insert(self.done, state)
|
|
||||||
end
|
|
||||||
|
|
||||||
return #self.work > 0
|
|
||||||
else
|
|
||||||
self.register.error = next
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Task.perform(self)
|
|
||||||
while self:step() do
|
|
||||||
end
|
|
||||||
|
|
||||||
if not self.register.error then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
local stat, err
|
|
||||||
repeat
|
|
||||||
stat, err = self:rollback()
|
|
||||||
until not stat
|
|
||||||
|
|
||||||
if err then
|
|
||||||
self.register.errstr = err
|
|
||||||
self.register.error = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
Machine = luci.util.class()
|
|
||||||
|
|
||||||
function Machine.__init__(self, namespace)
|
|
||||||
self.namespace = namespace or _NAME
|
|
||||||
end
|
|
||||||
|
|
||||||
function Machine.state(self, name)
|
|
||||||
local ret, state = pcall(require, self.namespace .. "." .. name)
|
|
||||||
return ret and state
|
|
||||||
end
|
|
||||||
|
|
||||||
function Machine.task(self, name, ...)
|
|
||||||
local start = self:state(name)
|
|
||||||
|
|
||||||
if type(start) ~= "table" or not start.entry then
|
|
||||||
return false, "No such command: " .. name
|
|
||||||
end
|
|
||||||
|
|
||||||
local register = {}
|
|
||||||
|
|
||||||
return start.entry(register, ...) and Task(self, register, start)
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
module("luci.lpk.core.download", package.seeall)
|
|
|
@ -1,16 +0,0 @@
|
||||||
module("luci.lpk.core.install", package.seeall)
|
|
||||||
|
|
||||||
function entry(register, ...)
|
|
||||||
print("Requested install of " .. table.concat(arg, ", "))
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function process(register)
|
|
||||||
register.sometext = "Test"
|
|
||||||
if not register.retrieved then
|
|
||||||
print("Step down to retrieve")
|
|
||||||
return "retrieve"
|
|
||||||
else
|
|
||||||
print("Coming up again")
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
module("luci.lpk.core.retrieve", package.seeall)
|
|
||||||
|
|
||||||
function process(register)
|
|
||||||
print "Now in retrieve"
|
|
||||||
print (register.sometext)
|
|
||||||
register.retrieved = true
|
|
||||||
end
|
|
|
@ -1,59 +0,0 @@
|
||||||
module("luci.lpk.util", package.seeall)
|
|
||||||
|
|
||||||
function getopt( arg, options )
|
|
||||||
options = options or ""
|
|
||||||
local tab = {}
|
|
||||||
local args = {}
|
|
||||||
for k, v in ipairs(arg) do
|
|
||||||
if v:sub(1, 2) == "--" then
|
|
||||||
local x = v:find( "=", 1, true )
|
|
||||||
if x then
|
|
||||||
tab[ v:sub( 3, x-1 ) ] = v:sub( x+1 )
|
|
||||||
else
|
|
||||||
tab[ v:sub( 3 ) ] = true
|
|
||||||
end
|
|
||||||
elseif v:sub( 1, 1 ) == "-" then
|
|
||||||
local y = 2
|
|
||||||
local l = #v
|
|
||||||
local jopt
|
|
||||||
while ( y <= l ) do
|
|
||||||
jopt = v:sub( y, y )
|
|
||||||
if options:find( jopt, 1, true ) then
|
|
||||||
if y < l then
|
|
||||||
tab[ jopt ] = v:sub( y+1 )
|
|
||||||
y = l
|
|
||||||
else
|
|
||||||
tab[ jopt ] = arg[ k + 1 ]
|
|
||||||
arg[ k + 1 ] = ""
|
|
||||||
end
|
|
||||||
else
|
|
||||||
tab[ jopt ] = true
|
|
||||||
end
|
|
||||||
y = y + 1
|
|
||||||
end
|
|
||||||
elseif #v > 0 then
|
|
||||||
table.insert(args, v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return tab, args
|
|
||||||
end
|
|
||||||
|
|
||||||
function splash()
|
|
||||||
require("luci.lpk")
|
|
||||||
luci.util.perror(string.format("%s v%s\n%s",
|
|
||||||
luci.lpk.__appname__, luci.lpk.__version__, luci.lpk.__cpyrght__))
|
|
||||||
luci.util.perror([[
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
lpk [options] <command> [arguments]
|
|
||||||
lpk [options] install|remove pkg1 [pkg2] [...] [pkgn]
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
install - Install packages
|
|
||||||
remove - Remove packages
|
|
||||||
purge - Remove packages and their configuration files
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--force-depends - Ignore unresolvable dependencies
|
|
||||||
]])
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
backend.model = "ipkg"
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/lua
|
|
||||||
require("luci.lpk")
|
|
Loading…
Reference in a new issue