aboutsummaryrefslogtreecommitdiff
path: root/config/init.lua
blob: a6a20449bfb0bb5c5b624f738c8934633be143c6 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local pkgit = require("pkgit")
local cfg = {}

local prefix = os.getenv("HOME").."/.local"
cfg.dirs = {
	prefix	= prefix,
	src		= prefix.."/share/pkgit",
	bin		= prefix.."/bin",
	lib		= prefix.."/lib",
	include	= prefix.."/include",
}

cfg.fetchers = {}
cfg.fetchers.git = {
	get_source = function(url, version) return pkgit.run({
		"git clone --branch "..version.." --recursive --depth 1 "..url
	}) end,
	get_version = function(url) return io.popen(
		"git -c 'versionsort.suffix=-' \
		ls-remote --exit-code --refs --sort='version:refname' \
		--tags "..url.." '*.*.*' \
		| tail --lines=1 \
		| cut --delimiter='/' --fields=3"
	):read("*a") end,
}
cfg.fetchers.default = cfg.fetchers.git

cfg.recipes = {}
cfg.recipes.make = {
	build = function(bldit_build)
		return pkgit.run({"make"})
	end,
	install = function(bldit_install)
		return pkgit.run({"make install PREFIX="..prefix})
	end,
	remove = function(bldit_remove)
		return pkgit.run({"make uninstall PREFIX="..prefix})
	end,
}
local builds = {
	make = {
		files = {
			"makefile",
			"Makefile",
			"Makefile.am",
		},
		recipe = cfg.recipes.make
	}
}
cfg.recipes.default = function(final_dir) return pkgit.autodetect(builds, final_dir) end

cfg.pkgs = {}
cfg.pkgs.pkgit = {
	url = "https://git.symlinx.net/pkgit",
	version = "HEAD",
	fetcher = cfg.fetchers.git,
	dependencies = {
		luajit = {
			url = "https://luajit.org/git/luajit.git",
			version = "v2.1",
			fetcher = cfg.fetchers.git,
		}
	},
	opts = {},
	recipe = cfg.recipes.make,
}

return cfg