# Template file for 'network-ups-tools'
pkgname=network-ups-tools
version=2.8.2
revision=2
build_style=gnu-configure
configure_args="
 --sysconfdir=/etc/ups --with-doc=man --disable-static
 --datadir=/usr/share/ups --with-user=nut --with-group=nut --with-ssl
 --with-usb --with-dev --with-serial -with-avahi --with-udev-dir=/usr/lib/udev
 --with-libltdl --without-ipmi --without-freeipmi --without-systemdsystemunitdir
 --with-snmp --with-drvpath=/usr/libexec/nut $(vopt_with cgi) --with-statepath=/run/ups"
hostmakedepends="pkg-config asciidoc"
makedepends="avahi-libs-devel openssl-devel libusb-compat-devel neon-devel
 net-snmp-devel $(vopt_if cgi gd-devel) libltdl-devel"
conf_files="
	/etc/ups/ups.conf
	/etc/ups/upsd.users
	/etc/ups/upsmon.conf
	/etc/ups/upsd.conf
	/etc/ups/upssched.conf
	/etc/ups/nut.conf"
short_desc="UPS control and monitoring features (NUT)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="http://www.networkupstools.org/"
distfiles="${homepage}source/${version%.*}/nut-${version}.tar.gz"
checksum=e4b4b0cbe7dd39ba9097be7f7d787bb2fffbe35df64dff53b5fe393d659c597d
system_accounts="nut"

nopie=yes
build_options="cgi"
desc_option_cgi="Build and install the CGI programs"

post_install() {
	# Prepare configuration files
	for f in ups upsd upsmon upssched nut; do
		mv ${DESTDIR}/etc/ups/${f}.conf{.sample,}
	done
	mv ${DESTDIR}/etc/ups/upsd.users{.sample,}

	# runit services
	vsv upsd
	vsv upsmon
	vsv upsdrvctl
	vdoc "${FILESDIR}/README.voidlinux"
}

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