# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=luapak
pkgver=0.1.0_beta5
_pkgver=${pkgver/_/.}
pkgrel=0
pkgdesc="Easily build a standalone executable for any Lua program"
url="https://github.com/jirutka/luapak"
arch="noarch"
license="MIT"
_luaver=5.3
depends="lua$_luaver
	lua$_luaver-brieflz
	lua$_luaver-depgraph
	lua$_luaver-glob-pattern
	lua$_luaver-filesystem
	lua$_luaver-optparse
	luarocks$_luaver
	binutils
	gcc
	libc-dev
	lua$_luaver-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/jirutka/$pkgname/archive/v$_pkgver.tar.gz"
builddir="$srcdir/$pkgname-$_pkgver"
options="!check"  # upstream does not provide tests yet

prepare() {
	default_prepare

	cd "$builddir"
	sed -i "s|#!/usr/bin/env lua|#!/usr/bin/lua$_luaver|" bin/luapak
}

package() {
	local lmod_dir="$pkgdir/usr/share/lua/$_luaver"
	cd "$builddir"

	mkdir -p "$lmod_dir"
	cp -r luapak "$lmod_dir"/

	install -m 755 -D bin/luapak "$pkgdir"/usr/bin/luapak
}

sha512sums="72228930d02c38384b808d6559e435fc2392c7e6a26e460b741e5da7cf9a52586d7621bb791742be61d217786a77d91cc82b8e5bbf16c8ab514308be84c09425  luapak-0.1.0_beta5.tar.gz"
