# Template file for 'runit'
pkgname=runit
version=2.2.0
revision=1
build_style="gnu-makefile"
short_desc="UNIX init scheme with service supervision"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-3-Clause"
homepage="https://smarden.org/runit/"
distfiles="https://smarden.org/runit/runit-${version}.tar.gz"
checksum=95ef4d2868b978c7179fe47901e5c578e11cf273d292bd6208bd3a7ccb029290
# FIXME: this is caused by some bonk tests that should be fixed in void-linux/runit at some point
make_check=no

build_options="static"

if [ "$build_option_static" ]; then
	CFLAGS="-static"
	LDFLAGS="-static"
fi

post_extract() {
	mv runit-${version}/* .
}

do_configure() {
	cd src
	vsed -e 's,sbin/runit,usr/bin/runit,g' -i runit.h

	echo "$CC -D_GNU_SOURCE $CFLAGS" >conf-cc
	echo "$CC $LDFLAGS -Wl,-z -Wl,noexecstack" >conf-ld
	# set default service path to /var/service
	vsed -e 's:^char \*varservice ="/service/";$:char \*varservice ="/var/service/";:' -i sv.c
	make ${makejobs} sysdeps
}

do_build() {
	make -C src ${makejobs}
}

do_install() {
	vlicense package/COPYING

	# default services
	vmkdir var
	ln -s ../run/runit/runsvdir/current ${DESTDIR}/var/service

	local f
	for f in chpst runit runit-init runsv runsvchdir runsvdir \
		sv svlogd utmpset; do
		vbin src/$f
	done

	for f in man/*; do
		vman $f
	done

	vinstall ${FILESDIR}/sv  644 usr/share/bash-completion/completions
}
