# Copyright 2024-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.13.3

EAPI=8

CRATES="
"

inherit cargo systemd

DESCRIPTION="Full-featured implementation of NTP with NTS support"
HOMEPAGE="https://github.com/pendulum-project/ntpd-rs"
SRC_URI="
	${CARGO_CRATE_URIS}
	https://github.com/pendulum-project/ntpd-rs/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/Gentoo-zh/gentoo-deps/releases/download/${P}/ntpd-${PV}-crates.tar.xz
"

S="${WORKDIR}/${P}/ntpd"
LICENSE="Apache-2.0 MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD ISC MIT MPL-2.0 openssl Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64"
IUSE="metrics"

RDEPEND="
	acct-group/ntpd-rs
	acct-user/ntpd-rs
	metrics? (
		acct-group/ntpd-rs-observe
		acct-user/ntpd-rs-observe
	)
"

src_install(){
	for bin in ntp-ctl ntp-daemon ntp-metrics-exporter; do
		dobin ../$(cargo_target_dir)/${bin}
	done

	for man in ntp-ctl.8  ntp-daemon.8  ntp-metrics-exporter.8  ntp.toml.5; do
		doman ../docs/precompiled/man/${man}
	done

	insinto $(systemd_get_systempresetdir)
	doins ../docs/examples/conf/ntpd-rs.preset

	insinto /etc/ntpd-rs
	doins ../ntp.toml

	systemd_dounit ../docs/examples/conf/ntpd-rs-metrics.service
	systemd_dounit ../docs/examples/conf/ntpd-rs.service
}
