# Template file for 'ntpd-rs'
pkgname=ntpd-rs
version=1.7.2
revision=1
build_style=cargo
make_check_args="--
 --skip daemon::keyexchange::tests::client_connection_refused
 --skip daemon::keyexchange::tests::key_exchange_connection_limiter
 --skip daemon::keyexchange::tests::key_exchange_weird_packet
"
make_install_args="--path ntpd"
short_desc="Full-featured implementation of the Network Time Protocol"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0 OR MIT"
homepage="https://github.com/pendulum-project/ntpd-rs"
changelog="https://raw.githubusercontent.com/pendulum-project/ntpd-rs/main/CHANGELOG.md"
distfiles="https://github.com/pendulum-project/ntpd-rs/archive/refs/tags/v${version}.tar.gz"
checksum=f375018e496d0d268dc5ed3c362566afafa239d67369546f9c04b8d2e3163dda

system_accounts="_ntpd_rs"
conf_files="/etc/ntpd-rs/ntp.toml"
provides="ntp-daemon-0_1"
alternatives="
 ntpd:ntpd:/usr/bin/ntp-daemon
 ntpd:ntpd:/etc/sv/ntpd-rs"

case "$XBPS_TARGET_MACHINE" in
	i686|x86_64*)
		make_check_args+="
		 --skip nts::tests::test_key_exchange_roundtrip_no_cookies
		 --skip nts::tests::test_keyexchange_fixed_key_no_permission
		 --skip nts::tests::test_keyexchange_roundtrip_fixed_key
		 --skip nts::tests::test_keyexchange_roundtrip_fixed_key_keep_alive
		 --skip nts::tests::test_keyexchange_roundtrip_fixed_key_no_permit
		 --skip nts::tests::test_keyexchange_roundtrip_no_proto_overlap
		 --skip nts::tests::test_keyexchange_roundtrip_no_upgrade_possible
		 --skip nts::tests::test_keyexchange_roundtrip_supports
		 --skip nts::tests::test_keyexchange_roundtrip_upgrading
		 --skip nts::tests::test_keyexchange_roundtrip_v4
		 --skip nts::tests::test_keyexchange_roundtrip_v5
		 --skip nts::tests::test_keyexchange_supports_no_permission
		 --skip daemon::keyexchange::tests::key_exchange_roundtrip_with_port_server
		"
	;;
esac

post_patch() {
	# apply patched Cargo.toml changes to lockfile
	cargo metadata > /dev/null
}

post_install() {
	vinstall ntp.toml 644 etc/ntpd-rs
	vlicense LICENSE-MIT
	vsv ntpd-rs
	vsv ntpd-rs-metrics

	for manpage in docs/precompiled/man/*; do
		vman ${manpage}
	done
}
