aports.lua: try get vars from env var before parsing abuild.conf

This commit is contained in:
Natanael Copa 2011-09-30 11:56:43 +00:00
parent bbd9f10d24
commit 94c7dfa6b9
1 changed files with 14 additions and 4 deletions

View File

@ -5,11 +5,21 @@ abuild_conf_file = "/etc/abuild.conf"
local abuild_conf = {} local abuild_conf = {}
function get_abuild_conf(var) function get_abuild_conf(var)
if abuild_conf[var] == nil then -- 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(" . "..abuild_conf_file..' ; echo -n "$'..var..'"') local f = io.popen(" . "..abuild_conf_file..' ; echo -n "$'..var..'"')
abuild_conf[var] = f:read("*all") abuild_conf[var] = f:read("*all")
f:close() f:close()
end
return abuild_conf[var] return abuild_conf[var]
end end