summaryrefslogtreecommitdiff
blob: 8febd4a883224f1d5254decf10e6f7e84ff2bb74 (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
69
70
71
72
73
74
75
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

VCS="git"
GITHUB_A="keplerproject"

inherit lua

DESCRIPTION="A deployment and management system for Lua modules"
HOMEPAGE="http://www.luarocks.org"

LICENSE="MIT"
SLOT="0"
KEYWORDS=""
IUSE="curl openssl"

DEPEND="
	curl? ( net-misc/curl )
	!curl? ( net-misc/wget )
	openssl? ( dev-libs/openssl )
	!openssl? ( sys-apps/coreutils )
"
RDEPEND="
	${DEPEND}
	app-arch/unzip
"

all_lua_prepare() {
	# Don't die on gentoo's econf calls!
	sed -r \
		-e "/die.*Unknown flag:/d" \
		-i configure
	lua_default
}

each_lua_configure() {
	local md5 downloader lua incdir
	md5="md5sum"
	downloader="wget"
	lua="$(lua_get_lua)"
	incdir=$(lua_get_pkgvar includedir)

	use curl && downloader="curl"
	use openssl && md5="openssl"

	myeconfargs=()
	myeconfargs+=(
		--prefix=/usr
		--with-lua=/usr
		--with-lua-lib="/usr/$(get_libdir)"
		--rocks-tree=/usr
		--with-downloader="${downloader}"
		--with-md5-checker="${md5}"
		--lua-suffix="${lua//lua}"
		--lua-version="$(lua_get_abi)"
		--with-lua-include="${incdir}"
		--sysconfdir=/etc/${PN}
	)
	lua_default
}

each_lua_compile() {
	lua_default build
}

pkg_preinst() {
	local abi="$(lua_get_abi)"
	find "${D}" -type f | xargs sed -e "s:${D}::g" -i || die "sed failed"
	for l in luarocks{,-admin}; do
		rm "${D}/usr/bin/${l}"
		dosym "${l}-${abi}" "/usr/bin/${l}"
	done
}