# Template file for 'lua54-luarepl'
pkgname=lua54-luarepl
version=0.10
revision=2
metapackage=yes
hostmakedepends="lua51 lua52 lua53 lua54 luarocks-lua54"
depends="lua54"
_desc="Reusable REPL component for Lua, written in Lua"
short_desc="${_desc} (5.4.x)"
maintainer="Luciogi <githubvoidlinux.supremacy429@passinbox.com>"
license="MIT"
homepage="https://github.com/hoelzro/lua-repl"
distfiles="https://github.com/hoelzro/lua-repl/archive/refs/tags/${version}.tar.gz"
checksum=55ba9f032bb4eb0e2e93dc66a368549bcf1a915bdd9f9a467eb778c3133c6373

_rockname=${pkgname#lua54-}
_rocksrel=1
_pkg() {
	luarocks --lua-version="$1" --tree="${PKGDESTDIR}/usr/" \
		make --deps-mode=none --no-manifest "${_rockname}-${version}-${_rocksrel}.rockspec"
		vsed -i "${PKGDESTDIR}/usr/bin/rep.lua" -e "s|$(realpath "${PKGDESTDIR}")||g"
		mv "${PKGDESTDIR}/usr/bin/rep.lua" "${PKGDESTDIR}/usr/bin/rep.lua${1/./}"
		vlicense COPYING
}

do_install() {
	_pkg 5.4
	vsed -i "${PKGDESTDIR}/usr/bin/rep.lua54" -e "s|lua5\.3|lua5\.4|"
}

lua53-luarepl_package() {
	depends="lua53"
	short_desc="${_desc} (5.3.x)"
	pkg_install() {
		_pkg 5.3
	}
}

lua52-luarepl_package() {
	depends="lua52"
	short_desc="${_desc} (5.2.x)"
	pkg_install() {
		_pkg 5.2
	}
}

lua51-luarepl_package() {
	depends="lua51"
	short_desc="${_desc} (5.1.x)"
	pkg_install() {
		_pkg 5.1
	}
}
