# Template file for 'elogind'
pkgname=elogind
version=235.2
revision=3
build_style=meson
hostmakedepends="intltool pkg-config gperf docbook-xsl gettext-devel shadow m4 libxslt git"
makedepends="libcap-devel libmount-devel libseccomp-devel libblkid-devel pam-devel gettext-devel eudev-libudev-devel acl-devel glib-devel"
depends="dbus"
short_desc="Standalone logind fork"
maintainer="Enno Boland <gottox@voidlinux.eu>"
license="GPL-2, LGPL-2"
homepage="https://github.com/elogind/elogind"
distfiles="https://github.com/$pkgname/$pkgname/archive/v$version.tar.gz"
checksum=db5d7362ab7fd74a1ea863247f90f3b821cdb3e4433ba049a2fdcf5bf62b0fb9
conf_files="/etc/elogind/logind.conf"
configure_args+="
 -Drootlibexecdir=/usr/libexec/elogind
 -Dhalt-path=/usr/bin/halt
 -Dreboot-path=/usr/bin/reboot
 -Dkexec-path=/usr/bin/kexec"

pre_build() {
	case "$XBPS_TARGET_MACHINE" in
		*-musl) cp build/config.h src/shared;;
	esac
}

pre_check() {
	# test-fs-util checks for /etc/machine-id/foo and expects ENOTDIR
	# since /etc/machine-id is expected to be a file.
	# test-id128 tries to get a id generated by dbus-uuidgen from
	# /etc/machine-id, since we don't want to add a checkdependency
	# on dbus we just provide a string generated from dbus-uuidgen
	# for use in all cases.
	echo 'dcb30309cd6c8b7cc20383d85a5c7012' > /etc/machine-id

	# test-copy searches for /etc/os-release but this file is provided
	# by runit-void, create a dummy file to avoid a dependency on runit-void
	echo 'dummy-file' > /etc/os-release
}

post_check() {
	rm -f /etc/machine-id /etc/os-release
}

post_install() {
	ln -s libelogind.pc $DESTDIR/usr/lib/pkgconfig/libsystemd.pc
	ln -s libelogind.pc $DESTDIR/usr/lib/pkgconfig/libsystemd-logind.pc
	ln -sr $DESTDIR/usr/include/elogind $DESTDIR/usr/include/systemd
	vinstall ./src/systemd/sd-id128.h 644 usr/include
	vinstall ./src/systemd/_sd-common.h 644 usr/include
	vinstall $FILESDIR/elogind.wrapper 755 usr/libexec/elogind
}

elogind-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.so
		vmove usr/share/man/man3
		vmove usr/lib/pkgconfig
	}
}
