# Maintainer (aur): Aoibhinn di Tori <email@aoibh.in>
# Contributor: Lee T. Starnes <lstarnes1024@gmail.com>
# Maintainer: fauno <fauno@parabola.nu>

# parabola changes and rationale:
#  - removed empty fields
#  - install'ing packagefiles instead of cp'ing

pkgname=luadbi
pkgver=0.5
pkgrel=3.1
pkgdesc="Database interface library for Lua"
arch=('i686' 'x86_64' 'armv7h')
url="http://code.google.com/p/luadbi/"
license=('MIT')
depends=('lua')
makedepends=('lua' 'sqlite3' 'libmariadbclient' 'postgresql' 'postgresql-libs')
optdepends=(
  'sqlite3: sqlite backend support'
  'libmariadbclient: MariaDB (or MySQL) backend support'
  'postgresql-libs: PostgreSQL backend support'
)
source=("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname.$pkgver.tar.gz"
        "Makefile.diff")
md5sums=('ede2b003aadddc151aac87050c3d926e'
         '458d1ded068f7923ce6a89660f680d98')

build() {
  cd "$srcdir"
  patch -p1 < Makefile.diff

  # fix suggested by sl1pkn07 on AUR
  # DBI.lua has the path to the lua executable hardcoded
  sed 's|#!/usr/bin/lua5.1|#!/usr/bin/lua|g' -i DBI.lua

  make free
}

package() {
  cd "$srcdir"

  install -Dm644 DBI.lua $pkgdir/usr/share/lua/5.1/DBI.lua
  install -Dm644 COPYING $pkgdir/usr/share/licenses/luadbi/LICENSE

  for i in *.so ; do
    install -Dm755 "$i" $pkgdir/usr/lib/lua/5.1/"${i##*/}"
  done
}

