From bf7667ecdfd084fc062333ee52f9b96e694d6de0 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 31 Dec 2013 09:16:00 +0000 Subject: abuild: split out abuild conf related functions --- aports/abuild.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 aports/abuild.lua (limited to 'aports/abuild.lua') diff --git a/aports/abuild.lua b/aports/abuild.lua new file mode 100644 index 0000000..a9fe8cc --- /dev/null +++ b/aports/abuild.lua @@ -0,0 +1,26 @@ + +local M = {} +local abuild_conf = {} +M.conf_file = "/etc/abuild.conf" +M.functions = "/usr/share/abuild/functions.sh" + +function M.get_conf(var) + -- check cache + if abuild_conf[var] ~= nil then + return abuild_conf[var] + end + + -- use os env var + abuild_conf[var] = os.getenv(var) + if abuild_conf[var] ~= nil then + return abuild_conf[var] + end + + -- parse config file + local f = io.popen(" . "..M.conf_file..' ; echo -n "$'..var..'"') + abuild_conf[var] = f:read("*all") + f:close() + return abuild_conf[var] +end + +return M -- cgit v1.2.3