# sysvinit - The traditional System V init
name=sysvinit
version=3.14
release=2
desc="The traditional System V init"
url="https://github.com/slicer69/sysvinit"
license="GPL-2.0-or-later"
depend="glibc"
makedepend=""
source="https://github.com/slicer69/sysvinit/archive/refs/tags/3.14.tar.gz"
sha256="SKIP"

# Only src/ is built. The top-level Makefile also descends into man/, which
# runs po4a over the translated man pages - that needs perl modules the build
# host does not have, and it fails the whole build over documentation nobody
# asked for.
build() {
	cd "sysvinit-$version/src"
	make
}

package() {
	cd "sysvinit-$version/src"
	make ROOT="$pkgdir" install
	# The install target puts things under /sbin and /usr/bin; ScrapLinux is a
	# merged-/usr system where /sbin is a symlink, so anything that landed
	# in a real /sbin directory has to move.
	if [ -d "$pkgdir/sbin" ] && [ ! -L "$pkgdir/sbin" ]; then
		install -d "$pkgdir/usr/sbin"
		for f in "$pkgdir/sbin"/*; do
			[ -e "$f" ] || continue
			mv -f "$f" "$pkgdir/usr/sbin/"
		done
		rmdir "$pkgdir/sbin" 2>/dev/null || :
	fi
	:
	# util-linux is where these live on Linux, and it is installed on every ScrapLinux
	# system. Shipping a second copy stopped any install that chose sysvinit.
	rm -rf "$pkgdir/usr/bin/last"
	rm -rf "$pkgdir/usr/bin/lastb"
	rm -rf "$pkgdir/usr/bin/mesg"
	rm -rf "$pkgdir/usr/bin/wall"
	rm -rf "$pkgdir/usr/bin/utmpdump"
	rm -rf "$pkgdir/usr/share/man/man1/last.1"
	rm -rf "$pkgdir/usr/share/man/man1/lastb.1"
	rm -rf "$pkgdir/usr/share/man/man1/mesg.1"
	rm -rf "$pkgdir/usr/share/man/man1/wall.1"
	rm -rf "$pkgdir/usr/share/man/man1/utmpdump.1"
	rm -rf "$pkgdir/usr/share/man/man8/sulogin.8"
}
