diff options
author | Steven Barth <steven@midlink.org> | 2008-07-28 15:16:44 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-07-28 15:16:44 +0000 |
commit | 1f3700085c59ea3b3ed162277948771d41a57ccc (patch) | |
tree | fe0b3d340a9d9f5e9e7bb0428770aa2fea685571 /libs/lpk | |
parent | db4447af91e06cbe875fc656a65756751a1549e5 (diff) |
libs/lpk: Initial CLI
Diffstat (limited to 'libs/lpk')
-rw-r--r-- | libs/lpk/luasrc/lpk.lua | 39 | ||||
-rw-r--r-- | libs/lpk/luasrc/lpk/util.lua | 56 | ||||
-rw-r--r-- | libs/lpk/root/etc/lpk.conf | 1 | ||||
-rwxr-xr-x | libs/lpk/root/usr/bin/lpk | 2 |
4 files changed, 71 insertions, 27 deletions
diff --git a/libs/lpk/luasrc/lpk.lua b/libs/lpk/luasrc/lpk.lua index ae6aefd6b..56f62f0ca 100644 --- a/libs/lpk/luasrc/lpk.lua +++ b/libs/lpk/luasrc/lpk.lua @@ -1,4 +1,43 @@ 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 diff --git a/libs/lpk/luasrc/lpk/util.lua b/libs/lpk/luasrc/lpk/util.lua index d39809483..50b33e105 100644 --- a/libs/lpk/luasrc/lpk/util.lua +++ b/libs/lpk/luasrc/lpk/util.lua @@ -1,37 +1,39 @@ 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 + 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 ] = arg[ k + 1 ] + tab[ jopt ] = true end - else - tab[ jopt ] = true + y = y + 1 end - y = y + 1 - end - else - table.insert(args, v) - end - end - return tab, args + elseif #v > 0 then + table.insert(args, v) + end + end + return tab, args end
\ No newline at end of file diff --git a/libs/lpk/root/etc/lpk.conf b/libs/lpk/root/etc/lpk.conf new file mode 100644 index 000000000..7ff49f89b --- /dev/null +++ b/libs/lpk/root/etc/lpk.conf @@ -0,0 +1 @@ +backend.model = "ipkg"
\ No newline at end of file diff --git a/libs/lpk/root/usr/bin/lpk b/libs/lpk/root/usr/bin/lpk new file mode 100755 index 000000000..6e6dcded3 --- /dev/null +++ b/libs/lpk/root/usr/bin/lpk @@ -0,0 +1,2 @@ +#!/usr/bin/lua +require("luci.lpk")
\ No newline at end of file |