From 61104b8eed155a798a69256d45776cb3e1a40ccf Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 19 Nov 2008 14:25:49 +0000 Subject: Modified lbu to add ability to download overlay package. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@1601 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-controller.lua | 5 +++++ lbu-listchanges-html.lsp | 9 +++++++++ lbu-model.lua | 27 +++++++++++++++++++++++++++ lbu.roles | 4 ++-- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lbu-controller.lua b/lbu-controller.lua index 3db860d..8ced688 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -42,3 +42,8 @@ end function selectbackup(self) return self:redirect_to_referrer(self.model.selectbackupfile(self.clientdata.backup)) end + +function getpackage(self) + self.conf.viewtype = "stream" + return self.model.getpackage() +end diff --git a/lbu-listchanges-html.lsp b/lbu-listchanges-html.lsp index 88c1655..0733e96 100644 --- a/lbu-listchanges-html.lsp +++ b/lbu-listchanges-html.lsp @@ -18,6 +18,15 @@ io.write("") end end %> +<% if session.permissions.lbu.getpackage then %> +

Download Overlay

+
+
Generate and download overlay
+
+
+
+<% end %> +

Changes Since Last Commit

Files changed since last commit
diff --git a/lbu-model.lua b/lbu-model.lua index ae91096..a5856d2 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -433,3 +433,30 @@ function selectbackupfile(selectfile) end return cmdresult end + +function getpackage() + -- create a temporary directory to store the file + require("session") + local tmp = "/tmp/"..session.random_hash(10) + while posix.stat( tmp ) do + tmp = "/tmp/"..session.random_hash(10) + end + posix.mkdir(tmp) + local f = io.popen("PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin lbu package "..tmp.." 2>&1") + local cmdresult = f:read("*a") + f:close() + + -- find and read the file + local package = cfe({ type="raw", label="error", option="application/x-gzip" }) + for name in fs.find(".*tar%.gz", tmp) do + package.label = basename(name) + package.value = fs.read_file(name) + break + end + + -- delete the temp directory and file + f = io.popen("rm -r "..tmp) + f:close() + + return package +end diff --git a/lbu.roles b/lbu.roles index ac628c4..a9888ed 100644 --- a/lbu.roles +++ b/lbu.roles @@ -1,5 +1,5 @@ GUEST=lbu:status -USER=lbu:listchanges +USER=lbu:listchanges,lbu:getpackage EDITOR=lbu:config,lbu:commit,lbu:editincluded,lbu:editexcluded,lbu:listbackups,lbu:selectbackup EXPERT=lbu:expert -ADMIN=lbu:status,lbu:listchanges,lbu:config,lbu:commit,lbu:editincluded,lbu:editexcluded,lbu:listbackups,lbu:selectbackup,lbu:expert +ADMIN=lbu:status,lbu:listchanges,lbu:getpackage,lbu:config,lbu:commit,lbu:editincluded,lbu:editexcluded,lbu:listbackups,lbu:selectbackup,lbu:expert -- cgit v1.2.3