# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-gversion
_rockname=gversion
_pkgname=gversion.lua
pkgver=0.2.0
pkgrel=1
pkgdesc="Lua library for Gentoo-style versioning format"
url="https://github.com/jirutka/gversion.lua"
arch="noarch"
license="MIT"
depends=""
makedepends=""
subpackages=""
source="$pkgname-$pkgver.tar.gz::https://github.com/jirutka/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

_luaversions="5.1 5.2 5.3"
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages lua$_v-$_pkgname:_package"
done

package() {
	mkdir -p "$pkgdir"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for lua-$lver)"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-1"

	install -m 644 -D "$builddir"/src/gversion.lua \
		"$subpkgdir"/usr/share/lua/$lver/gversion.lua

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

md5sums="c01c9619c3b82d597e3a71093ca1c40c  lua-gversion-0.2.0.tar.gz"
sha256sums="27554e3bcef9d1e1af3a423e3d0d220a9cc824bad9d18fc9473d3f24b777fb7e  lua-gversion-0.2.0.tar.gz"
sha512sums="1bae8b3d251cdb1ec6b6aab95214b3b456e2fa9b7b0d1c0f3dd7fb6ae1df170f74fb33386362699eb4cb375d4a885c2fb7513d6d084b79bb4947288d14d3643f  lua-gversion-0.2.0.tar.gz"
