libs/lpk: Initial CLI
This commit is contained in:
parent
db4447af91
commit
1f3700085c
4 changed files with 73 additions and 29 deletions
|
@ -1,4 +1,43 @@
|
||||||
module("luci.lpk", package.seeall)
|
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__)
|
||||||
|
__welcome__ = string.format("%s v%s\n%s",
|
||||||
|
__appname__, __version__, __cpyrght__)
|
||||||
|
|
||||||
|
|
||||||
|
options, arguments = luci.lpk.util.getopt(arg)
|
||||||
|
config = luci.util.dtable()
|
||||||
|
|
||||||
|
local cfgdump = loadfile("/etc/lpk.conf")
|
||||||
|
if cfgdump then
|
||||||
|
setfenv(cfgdump, config)
|
||||||
|
pcall(cfgdump)
|
||||||
|
end
|
||||||
|
|
||||||
|
if #arguments < 1 then
|
||||||
|
print(__welcome__)
|
||||||
|
print([[
|
||||||
|
|
||||||
|
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
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
-- Start machine
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module("luci.lpk.util", package.seeall)
|
module("luci.lpk.util", package.seeall)
|
||||||
|
|
||||||
function getopt( arg, options )
|
function getopt( arg, options )
|
||||||
|
options = options or ""
|
||||||
local tab = {}
|
local tab = {}
|
||||||
local args = {}
|
local args = {}
|
||||||
for k, v in ipairs(arg) do
|
for k, v in ipairs(arg) do
|
||||||
|
@ -23,13 +24,14 @@ function getopt( arg, options )
|
||||||
y = l
|
y = l
|
||||||
else
|
else
|
||||||
tab[ jopt ] = arg[ k + 1 ]
|
tab[ jopt ] = arg[ k + 1 ]
|
||||||
|
arg[ k + 1 ] = ""
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tab[ jopt ] = true
|
tab[ jopt ] = true
|
||||||
end
|
end
|
||||||
y = y + 1
|
y = y + 1
|
||||||
end
|
end
|
||||||
else
|
elseif #v > 0 then
|
||||||
table.insert(args, v)
|
table.insert(args, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
1
libs/lpk/root/etc/lpk.conf
Normal file
1
libs/lpk/root/etc/lpk.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
backend.model = "ipkg"
|
2
libs/lpk/root/usr/bin/lpk
Executable file
2
libs/lpk/root/usr/bin/lpk
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/lua
|
||||||
|
require("luci.lpk")
|
Loading…
Reference in a new issue