aboutsummaryrefslogtreecommitdiffstats
path: root/community/luarocks/APKBUILD
blob: d7dd60a304c54d6d42ad895df672110468acba9a (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
76
77
78
79
80
81
82
83
84
85
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=luarocks
pkgver=2.4.4
pkgrel=0
pkgdesc="Deployment and management system for Lua modules"
url="http://www.luarocks.org/"
arch="noarch"
license="MIT"
depends="curl"
makedepends=""
subpackages=""
triggers=""
source="http://luarocks.org/releases/$pkgname-$pkgver.tar.gz
	fix-tree-rocks_dir.patch
	config.lua"
builddir="$srcdir/$pkgname-$pkgver"

_lua_versions="5.1 5.2 5.3"
for _v in $_lua_versions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages $pkgname${_v}:_subpackage"
	triggers="$triggers $pkgname$_v.trigger=/usr/lib/luarocks/rocks-$_v:/usr/lib/luarocks/rocks-common"
done

prepare() {
	default_prepare

	# Create builddir for each Lua version.
	local lver; for lver in $_lua_versions; do
		cp -r "$builddir" "$builddir-$lver"
	done
}

build() {
	local lver; for lver in $_lua_versions; do
		msg "Building for Lua $lver..."
		cd "$builddir-$lver"

		./configure \
			--prefix=/usr \
			--sysconfdir=/etc/luarocks \
			--rocks-tree=/usr/local \
			--lua-version="$lver" \
			--lua-suffix="$lver" \
			--with-lua-include="$(pkg-config --variable=includedir lua$lver)" \
			--with-lua-lib="$(pkg-config --variable=libdir lua$lver)" \
			--with-downloader=curl \
			--with-md5-checker=md5sum \
			--versioned-rocks-dir
		make
	done
}

package() {
	mkdir -p "$pkgdir"
}

_subpackage() {
	local lver="${subpkgname#$pkgname}"
	pkgdesc="Deployment and management system for Lua $lver modules"
	install_if="lua$lver $pkgname=$pkgver-r$pkgrel"
	depends="lua$lver"

	cd "$builddir-$lver"

	make install DESTDIR="$subpkgdir"

	# Remove default script names which conflict per Lua version.
	rm "$subpkgdir"/usr/bin/luarocks \
		"$subpkgdir"/usr/bin/luarocks-admin

	# Set the correct Lua version.
	sed -i "s/env lua/env lua${lver}/" \
		"$subpkgdir"/usr/bin/luarocks-$lver \
		"$subpkgdir"/usr/bin/luarocks-admin-$lver

	# Config based on:
	#   https://github.com/luarocks/luarocks/wiki/Integrating-distro-modules-with-LuaRocks
	install -D -m 644 "$srcdir"/config.lua "$subpkgdir"/etc/$pkgname/config-$lver.lua
}

sha512sums="cbc6a54aa5077e656dcb4fed915fe8b66cad4ad04f28700e2f67805232a6dc366d4ac03e3a85e27a45b178c362ae8aa905ceab5553252735e049730a28450e19  luarocks-2.4.4.tar.gz
22ca5efa62c592c8395ca8c9ce3c938b5e41cf7d149f45d3666a5370d27e3e8c01d1712217c456d7b54163e375d9841d5f9213b25f4237b0bf3ab498c02864fb  fix-tree-rocks_dir.patch
1f75705af3b1ef57386234195a5d496d554c95473e5b0c0a3319e3c0f905519397b92603c5596d363818df7d94f886b898ba12a3880d3e982d1c63b74c50febe  config.lua"