# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
setvar _luaversions = ""5.1 5.2 5.3""
setvar pkgname = 'lua-json4'
setvar _name = 'json4lua'
setvar pkgver = '1.0.0'
setvar pkgrel = '2'
setvar pkgdesc = ""JSON encoding / decoding module for Lua (JSON4lua)""
setvar url = ""https://github.com/craigmj/json4lua""
setvar arch = ""noarch""
setvar license = ""GPL2""
setvar depends = """"
setvar subpackages = """"
for _i in $_luaversions {
	setvar subpackages = ""$subpackages lua$_i-json4:split_${_i/./_}""
}
setvar source = ""json4lua_$pkgver.tar.gz::https://github.com/craigmj/json4lua/archive/$pkgver.tar.gz""

setvar _builddir = ""$srcdir"/json4lua-$pkgver"
proc build {
	# do nothing, but keep it to make abuild happy
	:
}

proc package {
	for _i in $_luaversions {
		install -D "$_builddir"/json/json.lua \
			"$pkgdir"/usr/share/lua/$_i/json.lua
	}
}

proc _split {
	local d= _ver=$1
	setvar pkgdesc = ""JSON encoding / decoding module for Lua $_ver (JSON4lua)""
	setvar install_if = ""lua$_ver $pkgname=$pkgver-r$pkgrel""
	for d in usr/lib/lua usr/share/lua {
		if test -d "$pkgdir"/$d/$_ver {
			mkdir -p "$subpkgdir"/$d
			mv "$pkgdir"/$d/$_ver "$subpkgdir"/$d/ || return 1
		}
	}
}

for _i in $_luaversions {
	eval "split_${_i/./_}() { _split $_i; }"
}

setvar md5sums = ""ddb5ddec7f7cd4abc8d074e394572edb  json4lua_1.0.0.tar.gz""
setvar sha256sums = ""e502541a0090875deb834c1195ac08fdfce736473a83102d9ed78f0b6d723e69  json4lua_1.0.0.tar.gz""
setvar sha512sums = ""b42e0848af5284950327ad6986fb651650f84d8287b0c75084e022f6468019e82e9bbc4ce165089582f06a082972e63fe5b8ba1cf6d040fbfdb704db430f3547  json4lua_1.0.0.tar.gz""