summaryrefslogtreecommitdiffstats
path: root/apk-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
commitb9d7a2991f19d0b99dc315dcef95d8f69e4faa76 (patch)
tree405f4fdc78aa6243f2d01b85d5cb7fa74c80eb56 /apk-model.lua
parent7d90ce8ab9ef817bc640fcf26d2ba875e7a50a6a (diff)
downloadacf-apk-tools-b9d7a2991f19d0b99dc315dcef95d8f69e4faa76.tar.bz2
acf-apk-tools-b9d7a2991f19d0b99dc315dcef95d8f69e4faa76.tar.xz
Removed getopts library and added functionality to format library as opts_to_table, table_to_opts, parse_configfile2, update_configfile2, get_section, and set_section. New functions work on strings, not files. Modified all code using getopts to use format instead. Fixed nil string bugs in TCPProxy. Fixed forward only bug in DNSCache.
git-svn-id: svn://svn.alpinelinux.org/acf/apk-tools/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'apk-model.lua')
-rw-r--r--apk-model.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/apk-model.lua b/apk-model.lua
index f26fbb8..5c1af6e 100644
--- a/apk-model.lua
+++ b/apk-model.lua
@@ -1,7 +1,8 @@
-- acf model for packages (apk)
module (..., package.seeall)
-require("getopts")
require("apk")
+require("fs")
+require("format")
local configfile = "/etc/apk/apk.conf"
@@ -47,15 +48,19 @@ install_package = function(package,sessiondata)
end
get_config = function()
- local config = getopts.getoptsfromfile(configfile, "")
+ local config = format.parse_configfile2(fs.read_file(configfile), "")
local source = cfe({ value=config.APK_PATH or "", label="APK Source" })
return cfe({ type="group", value={source=source}, label="APK Config" })
end
set_config = function(newconfig)
-- FIXME - don't know how to validate
- if not getopts.setoptsinfile(configfile, "", "APK_PATH", newconfig.value.source.value) then
+ local success = true
+ if success then
+ fs.write_file(configfile, format.update_configfile2(fs.read_file(configfile) or "", "", "APK_PATH", newconfig.value.source.value))
+ else
newconfig.errtxt = "Failed to update config"
end
+
return newconfig
end