# Template file for 'booster'
pkgname=booster
version=0.12
revision=1
build_style=go
go_import_path=github.com/anatol/booster
go_package="${go_import_path}/generator"
hostmakedepends="git ruby-ronn"
depends="busybox-static"
short_desc="Fast and secure initramfs generator"
maintainer="travankor <travankor@tuta.io>"
license="MIT"
homepage="https://github.com/anatol/booster"
distfiles="https://github.com/anatol/booster/archive/${version}.tar.gz"
checksum=a2515923e919c99b69ce50f7828aa5df6e7ff80ea145c93c5a8c981d015d8bd4
conf_files="/etc/booster.yaml"
alternatives="
 initramfs:/etc/kernel.d/post-install/20-initramfs:/usr/libexec/booster/kernel-hook-postinst
 initramfs:/etc/kernel.d/post-remove/20-initramfs:/usr/libexec/booster/kernel-hook-postrm
"

# Tests require system tools (lz4, loadkeys) and kernel modules not available in the build environment,
# moved make_check=ci-skip after alternatives.
make_check=ci-skip
export GOFLAGS="-buildmode=pie"

post_build() {
	( cd init && CGO_ENABLED=0 go install -p "${XBPS_MAKEJOBS}" -mod=readonly -v -buildmode=default )
	ronn docs/manpage.md
	echo "busybox: true" > booster.yaml
}

do_install() {
	local _srcdir="${GOPATH}/bin"

	if [ "$CROSS_BUILD" ]; then
		_srcdir="${_srcdir}/linux_${GOARCH}"
	fi

	vbin "${_srcdir}/generator" booster
	vinstall "${_srcdir}/init" 755 usr/lib/booster

	vman docs/manpage.1 booster.1
	vconf booster.yaml

	vinstall ${FILESDIR}/kernel-hook-postinst 755 usr/libexec/booster
	vinstall ${FILESDIR}/kernel-hook-postrm 755 usr/libexec/booster

	vcompletion contrib/completion/bash bash booster

	vlicense LICENSE
}
