From 773a0952af828389e84c4cc94f1bff15e4f7f09b Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 16 Jan 2008 17:01:00 +0000 Subject: 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 --- lbu-config-html.lsp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ lbu-controller.lua | 85 +++++++++++++++++++++++++++++++++-------------------- lbu-html.lsp | 27 ----------------- lbu-model.lua | 70 ++++++++++++++++++++++++++++++++----------- lbu-read-html.lsp | 25 ---------------- lbu-status-html.lsp | 30 +++++++++++++++++++ lbu.cfg | 11 ------- 7 files changed, 213 insertions(+), 112 deletions(-) create mode 100644 lbu-config-html.lsp delete mode 100644 lbu-html.lsp delete mode 100644 lbu-read-html.lsp create mode 100644 lbu-status-html.lsp delete mode 100644 lbu.cfg diff --git a/lbu-config-html.lsp b/lbu-config-html.lsp new file mode 100644 index 0000000..24ef5a1 --- /dev/null +++ b/lbu-config-html.lsp @@ -0,0 +1,77 @@ + + +

SYSTEM INFO

+ +
+
Program status
+
+
+ +
+
Program version
+
+
+ +

CONFIG

+

Advanced config

+

Storage media

+
+
Default media for commit
+
+
+ +

Security/Encryption

+ +
+
Password protected commits
+
+
+ +
+
Cipher to use at encryption
+
+(For possible ciphers, try: openssl -v)
+
+ +
+
Password when encrypting
+
+
+ +

Save and apply above settings

+
+
Apply settings
+
+
+ +

MANAGEMENT

+ +
+
Commit and save changes
+
+ +
+
+ + +
+
Previous action result
+
+
+ + + + + + diff --git a/lbu-controller.lua b/lbu-controller.lua index 51a0538..079bf4c 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -1,7 +1,7 @@ module(..., package.seeall) local list_redir = function(self) - self.conf.action = "read" + self.conf.action = "status" self.conf.type = "redir" error(self.conf) end @@ -16,9 +16,52 @@ mvc.on_load = function(self, parent) end end --- Public methods --- /hostname/get +status = function (self) + local cmd = self.clientdata.cmd + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + return ( {status = self.model:getstatus(), + lbustatus = self.model:list(), + url = url, } ) +end + +config = function (self) + local cmd = self.clientdata.cmd + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + return ( {status = self.model:getstatus(), url = url } ) +end + +-- ################################################################################ +-- OLD FUNCTIONS + +--[[ +function commit(self) + local ret = { + script=ENV["SCRIPT_NAME"], + prefix=self.conf.prefix, + controller = self.conf.controller, + action="commit", + data={}, + title="LBU", + text={}, + } + if self.clientdata.commit then + local result, report = self.model:commit() + local label = result and "Report" or "Error" + ret.text[#ret.text + 1] = { label=label, content=report } + else + for i,v in ipairs(self.model:list(nil)) do + ret.data[#ret.data + 1] = { + status = v.status, + name = v.name, + } + end + end + ret.note=getNotes(self) + return ret +end +--]] +--[[ local function getNotes(self) ret = {} for k,v in pairs(cfgfile.model:list(nil)) do @@ -31,8 +74,9 @@ local function getNotes(self) end return ret end - -read = function(self) +--]] +--[[ +xxxstatus = function(self) return { list=cfgfile.model:list(function(x) return x.app == "lbu" end), script=ENV["SCRIPT_NAME"], @@ -43,6 +87,9 @@ read = function(self) } end +--]] + +--[[ update = function(self) local id = tonumber(self.clientdata.id) or -1 local result @@ -70,30 +117,4 @@ update = function(self) extra = ""}, value = data} end - -function commit(self) - local ret = { - script=ENV["SCRIPT_NAME"], - prefix=self.conf.prefix, - controller = self.conf.controller, - action="commit", - data={}, - title="LBU", - text={}, - } - if self.clientdata.commit then - local result, report = self.model:commit() - local label = result and "Report" or "Error" - ret.text[#ret.text + 1] = { label=label, content=report } - else - for i,v in ipairs(self.model:list(nil)) do - ret.data[#ret.data + 1] = { - status = v.status, - name = v.name, - } - end - end - ret.note=getNotes(self) - return ret -end - +--]] diff --git a/lbu-html.lsp b/lbu-html.lsp deleted file mode 100644 index 4ca2cbe..0000000 --- a/lbu-html.lsp +++ /dev/null @@ -1,27 +0,0 @@ - -

Edit

- - - - - - - - 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 - +--]] diff --git a/lbu-read-html.lsp b/lbu-read-html.lsp deleted file mode 100644 index bfd986a..0000000 --- a/lbu-read-html.lsp +++ /dev/null @@ -1,25 +0,0 @@ - - -

LBU

- -

Settings

- -

- - - -
-
- - -

Functions

-
Commit changes
-
- - diff --git a/lbu-status-html.lsp b/lbu-status-html.lsp new file mode 100644 index 0000000..fad2b2a --- /dev/null +++ b/lbu-status-html.lsp @@ -0,0 +1,30 @@ + + +

SYSTEM INFO

+ +
+
Program status
+
+
+ +
+
Program version
+
+
+ +

PROGRAM SPECIFIC OPTIONS/INFORMATION

+ + +
+
Files changed since last commit
+
+
+ + + + diff --git a/lbu.cfg b/lbu.cfg deleted file mode 100644 index fc22ed6..0000000 --- a/lbu.cfg +++ /dev/null @@ -1,11 +0,0 @@ --- /* vim: set filetype=lua : */ -{ app="lbu", section="general", - name="include", filename="/etc/lbu/include", - descr="Include list" }, -{ app="lbu", section="general", - name="exclude", filename="/etc/lbu/exclude", - descr="Exclude list" }, -{ app="lbu", section="general", - name="packages", filename="/etc/lbu/packages.list", - descr="Remembered list of installed packages" }, - -- cgit v1.2.3