# Maintainer: KokaKiwi <kokakiwi+aur [at] kokakiwi.net>

pkgname=php-luasandbox
pkgver=4.1.4
pkgrel=1
pkgdesc='PHP extension that provides a sandboxed environment to run Lua scripts in'
arch=('i686' 'x86_64')
url='https://www.mediawiki.org/wiki/LuaSandbox'
license=('MIT')
depends=('php' 'lua51')
backup=('etc/php/conf.d/luasandbox.ini')
source=("$pkgname-$pkgver.tar.gz::https://github.com/wikimedia/mediawiki-php-luasandbox/archive/refs/tags/$pkgver.tar.gz")
sha256sums=('154571b700b7534a083b002df583e0da95450b1a39f8685f50aa4cafded8e28a')
b2sums=('0de8a9cfd46a5d5b5c8d617b6e36ae49e82a3a11d62117dddc150f0d44e46d4b881c7d30f50eb49657170300c74a7ebff22a260d65e11ad7461d15f00d3abe3d')

build() {
  cd "mediawiki-php-luasandbox-$pkgver"

  phpize
  ./configure \
    --prefix=/usr

  make
}

check() {
  cd "mediawiki-php-luasandbox-$pkgver"

  NO_INTERACTION=1 make test
}

package() {
  cd "mediawiki-php-luasandbox-$pkgver"

  make install INSTALL_ROOT="$pkgdir"

  install -dm0755 "$pkgdir/etc/php/conf.d"
  echo ';extension=luasandbox.so' > "$pkgdir/etc/php/conf.d/luasandbox.ini"

  install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname" COPYING
}
