# Contributor: Ɓukasz Jendrysik # Maintainer: Natanael Copa _luaversions="5.1 5.2 5.3" _drivers="mysql postgres sqlite3 odbc" pkgname=lua-sql pkgver=2.3.2 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 :' \ 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="eab313c796e46227083d24a1ee72f9dc luasql-2.3.2.tar.gz" sha256sums="d92a6101cc05441cc5285a2eac18d4b4c764749cc7faf583add69885dc8d7e50 luasql-2.3.2.tar.gz" sha512sums="6bfd25c494fa214c2f449d95448966b4872fa46a8df87969a9bd654c4f8c341f2a3a56b2bd6ca6cf09971caf5ab05a0c912fffe97dc782921572039308f7f8fa luasql-2.3.2.tar.gz"