aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-sql/APKBUILD
blob: a536ce3c01861e7b6c5850b20f2c7014c1555073 (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
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
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_luaversions="5.1 5.2 5.3"
_drivers="mysql postgres sqlite3 odbc"

pkgname=lua-sql
pkgver=2.3.3
pkgrel=0
pkgdesc="Lua SQL drivers"
url="http://keplerproject.github.io/luasql/doc/us/"
arch="all"
license="MIT"
depends=""
makedepends="mariadb-dev postgresql-dev sqlite-dev unixodbc-dev"
install=
subpackages=
for _i in $_luaversions; do
	makedepends="$makedepends lua$_i-dev"
	for _j in $_drivers; do
		subpackages="$subpackages lua$_i-sql-$_j:split_${_j}_${_i/./}"
	done
done
for _j in $_drivers; do
	subpackages="$subpackages lua-sql-$_j:split_${_j}"
done

source="luasql-$pkgver.tar.gz::https://github.com/keplerproject/luasql/archive/v$pkgver.tar.gz"

_sdir="$srcdir"/luasql-$pkgver
prepare() {
	cd "$_sdir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done

	# apply patches here

	# The config has DRIVER_INCS but it seems like its not respected
	# so we just fix the .c file
	sed -i -e 's:^\#include "mysql.h":\#include <mysql/mysql.h>:' \
		src/ls_mysql.c || return 1

	cd "$srcdir"
	for _i in $_luaversions; do
		cp -r "$_sdir" "$srcdir"/build-$_i
	done
}

build() {
	for _i in $_luaversions; do
		msg "build for Lua $_i"
		cd "$srcdir"/build-$_i
		make CFLAGS="$CFLAGS $( pkg-config lua$_i --cflags ) -fPIC" \
			DRIVER_LIBS="-lmysqlclient" \
			mysql || return 1

		make CFLAGS="$CFLAGS $( pkg-config lua$_i --cflags ) -fPIC" \
			DRIVER_LIBS="$(pkg-config --libs libpq)" \
			postgres || return 1

		make CFLAGS="$CFLAGS $( pkg-config lua$_i --cflags ) -fPIC" \
			DRIVER_LIBS="$(pkg-config --libs sqlite3)" \
			sqlite3 || return 1

		make CFLAGS="$CFLAGS $( pkg-config lua$_i --cflags ) -fPIC -DUNIXODBC" \
			DRIVER_LIBS="-lodbc"\
			odbc || return 1

	done
}

package() {
	for _i in $_luaversions; do
		local _install_cmod=$(pkg-config --variable INSTALL_CMOD lua$_i)
		cd "$srcdir"/build-$_i
		for _j in $_drivers; do
			install -D src/$_j.so \
				"$pkgdir"/$_install_cmod/luasql/$_j.so \
				|| return 1
		done
	done
}

_split() {
	local d= _ver=$1 _driver=$2
	pkgdesc="Lua $_ver SQL driver for $2"
	install_if="lua$_ver lua-sql-$_driver=$pkgver-r$pkgrel"
	depends=
	replaces=
	mkdir -p "$subpkgdir"/usr/lib/lua/$_ver/luasql
	mv "$pkgdir"/usr/lib/lua/$_ver/luasql/$_driver.so \
		"$subpkgdir"/usr/lib/lua/$_ver/luasql/ || return 1
}

for _i in $_luaversions; do
	for _j in $_drivers; do
		eval "split_${_j}_${_i/./}() { _split $_i $_j; }"
	done
done
for _j in $_drivers; do
	eval "split_$_j() {
		pkgdesc=\"Lua SQL drivers for $_j\";
		mkdir -p \"$subpkgdir\";
	}"
done

md5sums="c247656f60f99e66e08bd1747e5623df  luasql-2.3.3.tar.gz"
sha256sums="6c95d61afb8c8678629a53c559389885205c7be5faba53698fd0dd4bd96f3ac0  luasql-2.3.3.tar.gz"
sha512sums="f8f6d5a60bd101ccdc1fe81f241e355649eb59de9d5c6d9d32d347356f63e88d190c3ff77d2d301f915ffaa8b2a6c36ff8808cbf65b6de7ae6d22807b5d4794a  luasql-2.3.3.tar.gz"