# Contributor: Ted Trask <ttrask01@yahoo.com>
# Maintainer: Ted Trask <ttrask01@yahoo.com>
_luaversion="5.2"
pkgname=acf-core
pkgver=0.21.1
pkgrel=0
pkgdesc="A web-based system administration interface framework"
url="https://git.alpinelinux.org/cgit/acf/acf-core"
arch="noarch"
license="GPL-2.0"
install="$pkgname.post-upgrade"
depends="acf-jquery acf-lib acf-skins haserl-lua$_luaversion lua$_luaversion
	lua$_luaversion-posix lua$_luaversion-md5 lua$_luaversion-json4
	lua$_luaversion-subprocess"
source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.xz"

package() {
	cd "$srcdir/$pkgname-$pkgver"
	sed "s~luadir=.*~luadir=\${prefix}/share/lua/$_luaversion/acf~" -i config.mk \
		|| return 1

	# fix shebang
	sed -i -e "1s:#!/usr/bin/haserl :#!/usr/bin/haserl-lua$_luaversion :" \
		www/cgi-bin/acf || return 1

	sed -i -e "1s:#!/usr/bin/lua.*:#!/usr/bin/lua$_luaversion:" \
		bin/acf-cli || return 1

	make DESTDIR="$pkgdir" install || return 1
	mkdir -p "$pkgdir"/etc/acf/skins
}
sha512sums="21cf8da93e90978c57e166abda2e2cbf922722e86bfeacabebfa16e3f94a130ef45368363d9409e063c4abeba05f6e89b5212f684202e6ef77d1f8019f822acd  acf-core-0.21.1.tar.xz"
