# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-date
_rockname=date
pkgver=2.2.1
pkgrel=0
pkgdesc="Date & Time module for Lua 5.x"
url="https://github.com/Tieske/date"
arch="noarch"
license="MIT"
depends="lua"
checkdepends="lua-busted"
source="https://github.com/Tieske/$_rockname/archive/version_$pkgver/lua-date-$pkgver.tar.gz"
builddir="$srcdir/date-version_$pkgver"

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	checkdepends="$checkdepends lua$_v lua$_v-busted"
done

case "$CARCH" in
ppc64le|riscv64|loongarch64) _luajit="" ;;
*) checkdepends="$checkdepends luajit"; _luajit="jit" ;;
esac

check() {
	local lver; for lver in $_luaversions $_luajit; do
		msg "Testing on lua$lver"
		lua$lver /usr/bin/busted --no-coverage
	done
}

package() {
	local rockdir="$pkgdir/usr/lib/luarocks/rocks-common/$_rockname/$pkgver-1"

	install -m 644 -D "$builddir"/src/date.lua \
		"$pkgdir"/usr/share/lua/common/date.lua

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

sha512sums="
c50869c3e0f0880501cb090ec42a6deca51c2b16dc7354005e2b4cf1ed06e116ccea4b9fcf99921b3fc3c07282cc200c9eac891efc39d455bc8eba9ea6e83efb  lua-date-2.2.1.tar.gz
"
