APKBUILD 3.9 KB
Newer Older
Natanael Copa's avatar
Natanael Copa committed
1 2
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lua5.3
Jakub Jirutka's avatar
Jakub Jirutka committed
3
_pkgname=lua
4
pkgver=5.3.5
Natanael Copa's avatar
Natanael Copa committed
5
_luaver=${pkgname#lua}
6
pkgrel=0
Natanael Copa's avatar
Natanael Copa committed
7
pkgdesc="Powerful light-weight programming language"
8
url="https://www.lua.org/"
Natanael Copa's avatar
Natanael Copa committed
9 10 11
arch="all"
license="MIT"
ldpath="/usr/lib/$pkgname"
Jakub Jirutka's avatar
Jakub Jirutka committed
12
depends_dev="$pkgname"
Natanael Copa's avatar
Natanael Copa committed
13
makedepends="libtool autoconf automake linenoise-dev"
Natanael Copa's avatar
Natanael Copa committed
14
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
15
source="https://www.lua.org/ftp/$_pkgname-$pkgver.tar.gz
Natanael Copa's avatar
Natanael Copa committed
16 17
	lua-5.3-make.patch
	lua-5.3-module_paths.patch
18
	linenoise.patch
19
	CVE-2019-6706-use-after-free-lua_upvaluejoin.patch
Natanael Copa's avatar
Natanael Copa committed
20
	"
Jakub Jirutka's avatar
Jakub Jirutka committed
21
builddir="$srcdir/$_pkgname-$pkgver"
Natanael Copa's avatar
Natanael Copa committed
22

23 24 25 26
# secfixes:
#   5.3.5-r0:
#   - CVE-2019-6706

Natanael Copa's avatar
Natanael Copa committed
27
prepare() {
Jakub Jirutka's avatar
Jakub Jirutka committed
28 29
	default_prepare || return 1
	cd "$builddir"
Natanael Copa's avatar
Natanael Copa committed
30 31 32 33 34

	# disable readline
	sed -i -e '/#define LUA_USE_READLINE/d' src/luaconf.h

	# we use libtool
Jakub Jirutka's avatar
Jakub Jirutka committed
35 36
	cat > configure.ac <<-EOF
		top_buildir=.
Natanael Copa's avatar
Natanael Copa committed
37

Jakub Jirutka's avatar
Jakub Jirutka committed
38 39 40 41
		AC_INIT(src/luaconf.h)
		AC_PROG_LIBTOOL
		AC_OUTPUT()
	EOF
Natanael Copa's avatar
Natanael Copa committed
42 43 44 45
	libtoolize --force --install && aclocal && autoconf
}

build() {
Jakub Jirutka's avatar
Jakub Jirutka committed
46
	cd "$builddir"
Natanael Copa's avatar
Natanael Copa committed
47 48 49 50 51
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		|| return 1
Jakub Jirutka's avatar
Jakub Jirutka committed
52

Natanael Copa's avatar
Natanael Copa committed
53 54
	cd src
	make V=${pkgver%.*} \
55
		CFLAGS="-DLUA_USE_LINUX -DLUA_COMPAT_5_2 -DLUA_USE_LINENOISE" \
Natanael Copa's avatar
Natanael Copa committed
56 57
		SYSLDFLAGS="$LDFLAGS" \
		RPATH="/usr/lib" \
58
		LIB_LIBS="-lpthread -lm -ldl -llinenoise" \
Natanael Copa's avatar
Natanael Copa committed
59 60 61 62
		alpine_all || return 1
}

package() {
Jakub Jirutka's avatar
Jakub Jirutka committed
63 64 65
	local i
	cd "$builddir"

Natanael Copa's avatar
Natanael Copa committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
	make V=${pkgver%.*} \
		INSTALL_TOP="$pkgdir"/usr \
		INSTALL_INC="$pkgdir"/usr/include/$pkgname \
		INSTALL_LIB="$pkgdir"/usr/lib/$pkgname \
		alpine_install || return 1

	for i in "$pkgdir"/usr/bin/* ; do
		mv $i ${i}${_luaver} || return 1
	done

	for i in "$pkgdir"/usr/lib/$pkgname/*.so.*; do
		ln -s $pkgname/${i##*/} "$pkgdir"/usr/lib/${i##*/} || return 1
	done

	install -D -m 644 doc/lua.1 "$pkgdir"/usr/share/man/man1/lua$_luaver.1 \
		&& install -D -m 644 doc/luac.1 \
			"$pkgdir"/usr/share/man/man1/luac$_luaver.1 \
		|| return 1

	install -d "$pkgdir"/usr/lib/pkgconfig
Jakub Jirutka's avatar
Jakub Jirutka committed
86 87
	cat > "$pkgdir"/usr/lib/pkgconfig/lua$_luaver.pc <<-EOF
		# lua.pc -- pkg-config data for Lua
88

Jakub Jirutka's avatar
Jakub Jirutka committed
89
		# vars from install Makefile
90

Jakub Jirutka's avatar
Jakub Jirutka committed
91 92 93 94
		# grep '^V=' ../Makefile
		V= ${_luaver}
		# grep '^R=' ../Makefile
		R= ${pkgver}
95

Jakub Jirutka's avatar
Jakub Jirutka committed
96 97 98 99 100 101 102 103
		# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
		prefix= /usr
		INSTALL_BIN= \${prefix}/bin
		INSTALL_INC= \${prefix}/include
		INSTALL_LIB= \${prefix}/lib
		INSTALL_MAN= \${prefix}/man/man1
		INSTALL_LMOD= \${prefix}/share/lua/\${V}
		INSTALL_CMOD= \${prefix}/lib/lua/\${V}
104

Jakub Jirutka's avatar
Jakub Jirutka committed
105 106 107 108
		# canonical vars
		exec_prefix=\${prefix}
		libdir=\${exec_prefix}/lib/$pkgname
		includedir=\${prefix}/include/$pkgname
109

Jakub Jirutka's avatar
Jakub Jirutka committed
110 111 112 113 114 115
		Name: Lua
		Description: An Extensible Extension Language
		Version: \${R}
		Requires:
		Libs: -L\${libdir} -llua -lm
		Cflags: -I\${includedir}
116

Jakub Jirutka's avatar
Jakub Jirutka committed
117 118
		# (end of lua$_luaver.pc)
	EOF
Natanael Copa's avatar
Natanael Copa committed
119 120 121 122

}

dev() {
Jakub Jirutka's avatar
Jakub Jirutka committed
123 124
	default_dev || return 1

125
	mkdir -p "$subpkgdir"/usr/$pkgname "$subpkgdir"/usr/lib/$pkgname
Natanael Copa's avatar
Natanael Copa committed
126 127
	ln -s ../include/$pkgname "$subpkgdir"/usr/$pkgname/include || return 1
	ln -s ../lib/$pkgname "$subpkgdir"/usr/$pkgname/lib || return 1
128 129
	mv "$pkgdir"/usr/lib/$pkgname/liblua.so "$subpkgdir"/usr/lib/$pkgname/ \
		|| return 1
Natanael Copa's avatar
Natanael Copa committed
130 131 132 133 134
}

libs() {
	pkgdesc="Lua dynamic library runtime"
	replaces="lua"
Jakub Jirutka's avatar
Jakub Jirutka committed
135

Natanael Copa's avatar
Natanael Copa committed
136 137 138 139
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

140
sha512sums="4f9516acc4659dfd0a9e911bfa00c0788f0ad9348e5724fe8fb17aac59e9c0060a64378f82be86f8534e49c6c013e7488ad17321bafcc787831d3d67406bd0f4  lua-5.3.5.tar.gz
Natanael Copa's avatar
Natanael Copa committed
141
1bc6c623024c1738155b30ff9c0edcce0f336edc25aa20c3a1400c859421ea2015d75175cce8d515e055ac3e96028426b74812e04022af18a0ed4c4601556027  lua-5.3-make.patch
142
313ff823ed871f380a2cb0ba1f0afbba5cfa9b98da40e6e5e8f3c7a2e5993b13c2577efbe7147b79e3903ff27d5a814fa782c1c925092b08510cb4ce02abf464  lua-5.3-module_paths.patch
143 144
49880d1131b7bd2a3169a26f401769a91d9a6a62cefe68aa5a89097139289588b7ef753535a2d0ba7f45c0369c760554940fd810716b7b1353deace32432fcfe  linenoise.patch
fde7f5f5a184cd393665c7c8c7ba3c728e1413df5f63dbe60855af13ddd313d9300720298534f4312638ddf59fa678a38f708bce622dd7a2298b4ed87c068ae7  CVE-2019-6706-use-after-free-lua_upvaluejoin.patch"