From 94c7dfa6b90082b90c8efd88e2fa178ef28ab47b Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 30 Sep 2011 11:56:43 +0000
Subject: [PATCH] aports.lua: try get vars from env var before parsing
 abuild.conf

---
 aports.lua | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/aports.lua b/aports.lua
index a553c60b3145..1959097a3a6e 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
 
-- 
GitLab