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-model.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lbu-model.lua') 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 -- cgit v1.2.3