summaryrefslogtreecommitdiffstats
path: root/apk-model.lua
diff options
context:
space:
mode:
authorZach LeBar <zach@zachlebar.com>2012-03-22 20:08:30 +0000
committerZach LeBar <zach@zachlebar.com>2012-03-22 20:08:30 +0000
commitb1d62376783a9b449ad13c5000f35eaa9a87662c (patch)
treec16296229b41ce14626425843ebc3397b35c901b /apk-model.lua
parentd6df1a0c206b2f2f979f15b2619a6e221ff39019 (diff)
downloadacf-apk-tools-master.tar.bz2
acf-apk-tools-master.tar.xz
Changed apk-controller.lua to use new handle_form() functions found in acf_www-controller.lua instead of the controllerfunctions.lua version and also instead of redirect_to_referrer(). Made corresponding changes to apk-model.lua to make everything work.HEADmaster
Diffstat (limited to 'apk-model.lua')
-rw-r--r--apk-model.lua102
1 files changed, 82 insertions, 20 deletions
diff --git a/apk-model.lua b/apk-model.lua
index b498802..02ffb03 100644
--- a/apk-model.lua
+++ b/apk-model.lua
@@ -3,8 +3,8 @@ module (..., package.seeall)
require("apk")
require("modelfunctions")
require("posix")
-require("fs")
-require("format")
+fs = require("acf.fs")
+format = require("acf.format")
local configfile = "/etc/apk/repositories"
local worldfile = "/etc/apk/world"
@@ -196,41 +196,103 @@ get_available_packages = function()
return available
end
-delete_package = function(package, sessiondata)
- local success, cmdresult = apk.delete(package)
+get_delete_package = function(clientdata)
+ local result = {}
+ result.package = cfe({ value=clientdata.package, label="Package" })
+
+ return cfe({ type="group", value=result, label="Result of Delete" })
+end
+
+delete_package = function(deleterequest)
+ local success, res = apk.delete(deleterequest.value.package.value)
if success then
+ deleterequest.descr = res
-- Destroy menu and permissions info in session so recalculated
- if sessiondata then sessiondata.menu = nil end
- if sessiondata then sessiondata.permissions = nil end
+ if session then session.menu = nil end
+ if session then session.permissions = nil end
+ else
+ deleterequest.errtxt = "Failed to delete package."
end
- return cfe({ value=cmdresult, label="Result of Delete" })
+
+ return deleterequest
+end
+
+get_install_package = function(clientdata)
+ local result = {}
+ result.package = cfe({ value=clientdata.package, label="Package" })
+
+ return cfe({ type="group", value=result, label="Result of Install" })
end
-install_package = function(package,sessiondata)
- local success, cmdresult = apk.install(package)
+install_package = function(installrequest)
+ local success, res = apk.install(installrequest.value.package.value)
if success then
+ installrequest.descr = res
-- Destroy menu and permissions info in session so recalculated
- if sessiondata then sessiondata.menu = nil end
- if sessiondata then sessiondata.permissions = nil end
+ if session then session.menu = nil end
+ if session then session.permissions = nil end
+ else
+ installrequest.errtxt = "Failed to install package."
+ end
+
+ return installrequest
+end
+
+get_upgrade_package = function(clientdata)
+ local result = {}
+ result.package = cfe({ value=clientdata.package, label="Package" })
+
+ return cfe({ type="group", value=result, label="Result of Upgrade" })
+end
+
+upgrade_package = function(upgraderequest)
+ local res = run_apk_cmd("fix -u "..upgraderequest.value.package.value)
+ if res then
+ upgraderequest.descr = res
+ else
+ upgraderequest.errtxt = "Failed to upgrade package."
end
- return cfe({ value=cmdresult, label="Result of Install" })
+
+ return upgraderequest
+end
+
+get_update_all = function(clientdata)
+ local result = {}
+
+ return cfe({ type="group", value=result, label="Result of Update" })
end
-upgrade_package = function(package)
- return cfe({ value=run_apk_cmd("fix -u "..package), label="Result of Package Upgrade" })
+update_all = function(updaterequest)
+ local res = run_apk_cmd("update")
+ if res then
+ updaterequest.descr = res
+ else
+ updaterequest.errtxt = "Failed to upgrade packages."
+ end
+
+ return updaterequest
end
-update_all = function()
- return cfe({ value=run_apk_cmd("update"), label="Result of Update" })
+get_upgrade_all = function(clientdata)
+ local result = {}
+
+ return cfe({ type="group", value=result, label="Result of Upgrade" })
end
-upgrade_all = function()
- result = {}
+upgrade_all = function(upgraderequest)
+ local result = {}
result[#result+1] = run_apk_cmd("update")
result[#result+1] = run_apk_cmd("add -u apk-tools")
result[#result+1] = run_apk_cmd("upgrade")
- return cfe({ value=table.concat(result, ""), label="Result of Upgrade" })
--- return cfe({ value=run_apk_cmd("upgrade -U"), label="Result of Upgrade" })
+
+ local res = table.concat(result, "")
+ if res then
+ upgraderequest.descr = res
+ else
+ upgraderequest.errtxt = "Failed to upgrade packages."
+ end
+
+ return upgraderequest
end
get_cache = function()