summaryrefslogtreecommitdiffstats
path: root/lbu-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-16 17:01:00 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-16 17:01:00 +0000
commit773a0952af828389e84c4cc94f1bff15e4f7f09b (patch)
treee6faf2c97e84915c6b6a0204fd7b1c06a2bf25ad /lbu-model.lua
parentf2ff77a050a092c3677746a31fe061477e2cc85d (diff)
downloadacf-alpine-conf-773a0952af828389e84c4cc94f1bff15e4f7f09b.tar.bz2
acf-alpine-conf-773a0952af828389e84c4cc94f1bff15e4f7f09b.tar.xz
Moving around things in LBU to get a grip on how it could look and work
git-svn-id: svn://svn.alpinelinux.org/acf/lbu/trunk@592 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lbu-model.lua')
-rw-r--r--lbu-model.lua70
1 files changed, 53 insertions, 17 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index 276ef85..8a362ce 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -1,30 +1,66 @@
module (..., package.seeall)
require "fs"
+local configfile = "/etc/lbu/lbu.conf"
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+local function get_version ()
+ local f,error = io.popen("/sbin/lbu 2>&1")
+ local programversion = f:read("*l")
+ f:close()
+ return programversion
+end
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
+ local ret = {}
+ local f = io.popen("/sbin/lbu status -v", "r")
+ if not (f) then return ret end
+ for line in f:lines() do
+ if (string.match(line, "^Include files")) then break end
+ if (string.match(line, "^Exclude files")) then break end
+ local status, name = string.match(line, "^(%S+)%s+(.+)$")
+ if (status) and (name) then
+ ret[string.gsub('/' .. name, "/+", "/")] = status
+ end
end
- end
- f:close()
- return ret
+ f:close()
+ return ret
+end
+
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function getstatus ()
+ local status = {}
+ local statustxt = nil
+ local lbustatus = list()
+ if (#lbustatus == 0) then
+ statustxt = "OK! (There is no uncommited files)"
+ else
+ statustxt = "WARNING! (Until you commit, you will loose your changes at next reboot/shutdown!)"
+ end
+ status["version"] = get_version()
+ status["status"] = statustxt
+ return status
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
+ local ret = {}
+ local lbuStatus = getLbuStatus()
+ for k,v in pairs(lbuStatus) do
+ ret[#ret + 1] = { name=k, status=v }
+ end
+ table.sort(ret, function(a,b) return (a.name < b.name) end)
+ return ret
end
+-- ################################################################################
+-- OLD FUNCTIONS
+
+--[[
function commit(self)
local f = io.popen("/sbin/lbu commit", 'r')
if not f then return false, "cannot run lbu" end
@@ -32,4 +68,4 @@ function commit(self)
f:close()
return true, ret
end
-
+--]]