aboutsummaryrefslogtreecommitdiff
path: root/config/pkgit.lua
blob: 718e7615142efff6a85025a2a06a9f15acb8bfdb (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- std pkgit functions

local M = {}

function M.run(items, verbose)
	local cmd = io.popen('set -e &&\n'..table.concat(items,"&&\n"))
	if cmd == nil then return 1 end
	if verbose then print(cmd:read("*a")) end
	local rc = {cmd:close()}
	if rc[1] then return 0
	else return 1
	end
end

function M.join(t1, ...)
	local new = t1
	local tables = { ... }
	for _, new_table in ipairs(tables) do
		for index, val in ipairs(new_table) do
			if val ~= nil then
				new[index] = val
			end 
		end
	end
	return new
end

function M.exists(s)
	local file = io.open(s, "r")
	if file ~= nil then
		io.close(file)
		return true
	else
		return false
	end
end

function M.autodetect(builds, final_dir)
	for k, system in pairs(builds) do
		for i, file in pairs(system.files) do
			if M.exists(final_dir.."/"..file) then
				return system.step
			end
		end
	end
end

function M.destdir(name, version)
	if version == nil then version = "HEAD" end
	return cfg.dirs.src.."/"..name.."/"..version
end

return M