summaryrefslogtreecommitdiff
path: root/system/lua5.3/APKBUILD
blob: 5786668d5b86c81539b15b55457d3738d7ed0307 (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Maintainer: 
pkgname=lua5.3
_pkgname=lua
pkgver=5.3.5
_luaver=${pkgname#lua}
pkgrel=2
pkgdesc="Embeddable programming language"
url="https://www.lua.org/"
arch="all"
license="MIT"
ldpath="/usr/lib/$pkgname"
depends=""
depends_dev="$pkgname"
makedepends="libtool autoconf automake linenoise-dev"
provides="lua"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="https://www.lua.org/ftp/$_pkgname-$pkgver.tar.gz
	lua-5.3-make.patch
	lua-5.3-module_paths.patch
	linenoise.patch
	CVE-2019-6706.patch
	CVE-2020-24370.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

# secfixes: lua
#   5.3.5-r2:
#     - CVE-2020-24370
#   5.3.5-r1:
#     - CVE-2019-6706

prepare() {
	default_prepare

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

	# we use libtool
	cat > configure.ac <<-EOF
		top_buildir=.

		AC_INIT(src/luaconf.h)
		AC_PROG_LIBTOOL
		AC_OUTPUT()
	EOF
	libtoolize --force --install && aclocal && autoconf
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr

	cd src
	make V=${pkgver%.*} \
		CFLAGS="-DLUA_USE_LINUX -DLUA_COMPAT_5_2 -DLUA_USE_LINENOISE" \
		SYSLDFLAGS="$LDFLAGS" \
		RPATH="/usr/lib" \
		LIB_LIBS="-lpthread -lm -ldl -llinenoise" \
		alpine_all
}

check() {
	make test
}

package() {
	make V=${pkgver%.*} \
		INSTALL_TOP="$pkgdir"/usr \
		INSTALL_INC="$pkgdir"/usr/include/$pkgname \
		INSTALL_LIB="$pkgdir"/usr/lib/$pkgname \
		alpine_install

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

	install -D -m 644 doc/lua.1 "$pkgdir"/usr/share/man/man1/lua.1
	install -D -m 644 doc/luac.1 "$pkgdir"/usr/share/man/man1/luac.1

	install -d "$pkgdir"/usr/lib/pkgconfig
	cat > "$pkgdir"/usr/lib/pkgconfig/lua.pc <<-EOF
		# lua.pc -- pkg-config data for Lua

		# vars from install Makefile

		# grep '^V=' ../Makefile
		V= ${_luaver}
		# grep '^R=' ../Makefile
		R= ${pkgver}

		# 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}

		# canonical vars
		exec_prefix=\${prefix}
		libdir=\${exec_prefix}/lib/$pkgname
		includedir=\${prefix}/include/$pkgname

		Name: Lua
		Description: An Extensible Extension Language
		Version: \${R}
		Requires:
		Libs: -L\${libdir} -llua -lm
		Cflags: -I\${includedir}

		# (end of lua.pc)
	EOF

}

dev() {
	default_dev

	mkdir -p "$subpkgdir"/usr/lib/$pkgname
	mv "$pkgdir"/usr/lib/$pkgname/liblua.so "$subpkgdir"/usr/lib/$pkgname/
}

libs() {
	pkgdesc="Lua dynamic library runtime"
	replaces="lua"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

sha512sums="4f9516acc4659dfd0a9e911bfa00c0788f0ad9348e5724fe8fb17aac59e9c0060a64378f82be86f8534e49c6c013e7488ad17321bafcc787831d3d67406bd0f4  lua-5.3.5.tar.gz
1bc6c623024c1738155b30ff9c0edcce0f336edc25aa20c3a1400c859421ea2015d75175cce8d515e055ac3e96028426b74812e04022af18a0ed4c4601556027  lua-5.3-make.patch
bc68772390dc8d8940176af0b9fbacc0af61891b5d27de5f1466a4e7f9b3291a1c08ba5add829bc96b789a53fa5ec2dadaa096ca6eabe54ec27724fa2810940f  lua-5.3-module_paths.patch
49880d1131b7bd2a3169a26f401769a91d9a6a62cefe68aa5a89097139289588b7ef753535a2d0ba7f45c0369c760554940fd810716b7b1353deace32432fcfe  linenoise.patch
77755c083630d48404178012d5947230675311a15f0f5e30efa72004edf3124615fa9080b739240213c013efb015689e09ee653a41d560964a3df78a8fe0fd8d  CVE-2019-6706.patch
0c28366d352e3e6660413d16c1deaa0b1c6070170c13d95ae7a48b6b39c728a16d3f2a6068f665b3ec3e17f4f69d006625af074a4ddb51c8f3845d567c0dd809  CVE-2020-24370.patch"