summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-30 11:56:43 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-12-16 13:39:46 +0000
commit516a6ecd6c5b627d351b3594e97121369f1f3ced (patch)
tree08eccea3640ca9aec860894a59d82aa705431f61
parent6154adbc888a9912a434dc50bfeb5d9ecc3889cb (diff)
downloadlua-aports-516a6ecd6c5b627d351b3594e97121369f1f3ced.tar.bz2
lua-aports-516a6ecd6c5b627d351b3594e97121369f1f3ced.tar.xz
aports.lua: try get vars from env var before parsing abuild.conf
-rwxr-xr-xaports.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/aports.lua b/aports.lua
index a553c60..1959097 100755
--- a/aports.lua
+++ b/aports.lua
@@ -5,11 +5,21 @@ abuild_conf_file = "/etc/abuild.conf"
local abuild_conf = {}
function get_abuild_conf(var)
- if abuild_conf[var] == nil then
- local f = io.popen(" . "..abuild_conf_file..' ; echo -n "$'..var..'"')
- abuild_conf[var] = f:read("*all")
- f:close()
+ -- 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..'"')
+ abuild_conf[var] = f:read("*all")
+ f:close()
return abuild_conf[var]
end