From b9d7a2991f19d0b99dc315dcef95d8f69e4faa76 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 29 Sep 2008 18:01:28 +0000 Subject: 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 --- apk-model.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'apk-model.lua') 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 -- cgit v1.2.3