diff options
-rw-r--r-- | apk-model.lua | 11 |
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 |