summaryrefslogtreecommitdiffstats
path: root/aports/abuild.lua
blob: 1626b2991b54680348e45786da778c4662486559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

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

function M.get_arch()
	if abuild_conf.CARCH then
		return abuild_conf.CARCH
	end
	local f = io.popen(" . "..M.functions..' ; echo -n "$CARCH"')
	abuild_conf.CARCH = f:read("*all")
	f:close()
	return abuild_conf.CARCH
end

return M