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

# Autogenerated by pycargoebuild 0.13.3

EAPI=8

CRATES="
	alsa-sys@0.4.0
	alsa@0.11.0
	android_system_properties@0.1.5
	anstream@1.0.0
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.14
	autocfg@1.5.0
	bitflags@2.11.1
	bumpalo@3.20.2
	cc@1.2.60
	cfg-if@1.0.4
	chrono@0.4.44
	clap-verbosity-flag@3.0.4
	clap@4.6.1
	clap_builder@4.6.0
	clap_derive@4.6.1
	clap_lex@1.1.0
	colorchoice@1.0.5
	colored@3.1.1
	configparser@3.1.0
	core-foundation-sys@0.8.7
	deranged@0.5.8
	equivalent@1.0.2
	errno@0.3.14
	find-msvc-tools@0.1.9
	hashbrown@0.17.0
	heck@0.5.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.65
	indexmap@2.14.0
	is_terminal_polyfill@1.70.2
	itoa@1.0.18
	js-sys@0.3.95
	libc@0.2.185
	log@0.4.29
	num-conv@0.2.1
	num-traits@0.2.19
	num_threads@0.1.7
	once_cell@1.21.4
	once_cell_polyfill@1.70.2
	pkg-config@0.3.33
	powerfmt@0.2.0
	proc-macro2@1.0.106
	quote@1.0.45
	rustversion@1.0.22
	serde_core@1.0.228
	serde_derive@1.0.228
	shlex@1.3.0
	signal-hook-registry@1.4.8
	signal-hook@0.4.4
	simple_logger@5.2.0
	strsim@0.11.1
	syn@2.0.117
	time-core@0.1.8
	time-macros@0.2.27
	time@0.3.47
	unicode-ident@1.0.24
	utf8parse@0.2.2
	wasm-bindgen-macro-support@0.2.118
	wasm-bindgen-macro@0.2.118
	wasm-bindgen-shared@0.2.118
	wasm-bindgen@0.2.118
	windows-core@0.62.2
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.61.2
"

inherit cargo udev systemd

DESCRIPTION="Speaker protection daemon for embedded Linux systems"
HOMEPAGE="https://github.com/AsahiLinux/speakersafetyd/"
SRC_URI="https://github.com/AsahiLinux/speakersafetyd/archive/refs/tags/${PV}.tar.gz -> ${PN}-${PV}.tar.gz
${CARGO_CRATE_URIS}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~arm64"

DEPEND="
	acct-user/speakersafetyd
	media-libs/alsa-ucm-conf-asahi
"
RDEPEND="${DEPEND}"

QA_FLAGS_IGNORED="usr/bin/${PN}"

src_install() {
	cargo_src_install
	emake DESTDIR="${D}" install-data
	doinitd "${FILESDIR}/speakersafetyd-noroot-${PV}"
}

pkg_postinst() {
	udev_reload
	[[ "${MERGE_TYPE}" == "buildonly" || "$(systemd_is_booted)" == 1 ]] && return
	elog "speakersafetyd must be running for builtin speakers to function"
	elog "To enable as a service in OpenRC:"
	elog "# rc-update add speakersafetyd-noroot default"
	elog "# rc-service speakersafetyd-noroot start"
	elog "On Systemd systems, it should be started automatically via a udev rule."
}

pkg_postrm() {
	udev_reload
}