diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-12-31 14:14:17 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-12-31 14:14:17 +0000 |
commit | 30e3d9b315164804de9738efebf4d6aaaad50197 (patch) | |
tree | 0dc401aea8a81625e0fa3389e0b831fdfc7f4875 /apk.lua | |
download | acf-lib-30e3d9b315164804de9738efebf4d6aaaad50197.tar.bz2 acf-lib-30e3d9b315164804de9738efebf4d6aaaad50197.tar.xz |
Lua libraries for standard functions moved out of acf-core 0.9.0v0.1.0
Diffstat (limited to 'apk.lua')
-rw-r--r-- | apk.lua | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -0,0 +1,44 @@ +-- apk library +module (..., package.seeall) + +local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " + +delete = function(package) + local success = false + local cmdresult + local cmd = path .. "apk del " .. package .. " 2>&1" + local f = io.popen( cmd ) + cmdresult = f:read("*a") or "" + f:close() + if string.find(cmdresult, "^OK") then + cmdresult = "ERROR: Package not found\n"..cmdresult + elseif not string.find(cmdresult, "ERROR") then + success = true + end + return success, cmdresult +end + +install = function(package) + local success = true + local cmdresult + local cmd = path .. "apk add " .. package .. " 2>&1" + local f = io.popen( cmd ) + cmdresult = f:read("*a") + f:close() + if string.find(cmdresult, "^ERROR") then + success = false + end + return success, cmdresult +end + +version = function(package) + local cmdresult + local cmd = path .. "apk info -ve " .. package .. " 2>&1" + local f = io.popen( cmd ) + cmdresult = f:read("*a") + f:close() + if string.find(cmdresult, "^%s*$") then + cmdresult = nil + end + return cmdresult +end |