diff options
author | Alexander Poslavsky <alexander.poslavsky@gmail.com> | 2007-11-02 13:08:51 +0000 |
---|---|---|
committer | Alexander Poslavsky <alexander.poslavsky@gmail.com> | 2007-11-02 13:08:51 +0000 |
commit | 1448b0049d94eb830c2e6ac17a6f1038f76de076 (patch) | |
tree | acc7f5090239bd28da98f0bb8fae2c4d48862365 /lbu-model.lua | |
download | acf-alpine-conf-1448b0049d94eb830c2e6ac17a6f1038f76de076.tar.bz2 acf-alpine-conf-1448b0049d94eb830c2e6ac17a6f1038f76de076.tar.xz |
lbu acf module work-in-progress
git-svn-id: svn://svn.alpinelinux.org/acf/lbu/trunk@259 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lbu-model.lua')
-rw-r--r-- | lbu-model.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lbu-model.lua b/lbu-model.lua new file mode 100644 index 0000000..276ef85 --- /dev/null +++ b/lbu-model.lua @@ -0,0 +1,35 @@ +module (..., package.seeall) + +require "fs" + +local function getLbuStatus() + local ret = {} + local f = io.popen("/sbin/lbu status -v", "r") + if not f then return ret end + for line in f:lines() do + local status, name = string.match(line, "^(%S+)%s+(.+)$") + if status and name then + ret[string.gsub('/' .. name, "/+", "/")] = status + end + end + f:close() + return ret +end + +function list(self) + local ret = {} + local lbuStatus = getLbuStatus() + for k,v in pairs(lbuStatus) do + ret[#ret + 1] = { name=k, status=v } + end + return ret +end + +function commit(self) + local f = io.popen("/sbin/lbu commit", 'r') + if not f then return false, "cannot run lbu" end + local ret = f:read("*a") + f:close() + return true, ret +end + |