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

# Auto-Generated by cargo-ebuild 0.5.4-r1

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	aes@0.7.5
	ahash@0.7.6
	aho-corasick@1.0.5
	anstream@0.5.0
	anstyle@1.0.3
	anstyle-parse@0.2.1
	anstyle-query@1.0.0
	anstyle-wincon@2.1.0
	assert_matches@1.5.0
	async-broadcast@0.5.1
	async-channel@1.9.0
	async-executor@1.5.1
	async-fs@1.6.0
	async-io@1.13.0
	async-lock@2.8.0
	async-process@1.7.0
	async-recursion@1.0.5
	async-task@4.4.0
	async-trait@0.1.73
	atomic-waker@1.1.1
	atty@0.2.14
	autocfg@1.1.0
	backtrace@0.3.69
	base64@0.13.1
	base64@0.21.4
	bincode@1.3.3
	bindgen@0.68.1
	bitflags@1.3.2
	bitflags@2.4.0
	block@0.1.6
	block-buffer@0.10.4
	block-buffer@0.9.0
	blocking@1.3.1
	block-modes@0.8.1
	block-padding@0.2.1
	bumpalo@3.13.0
	byteorder@1.4.3
	bytes@1.5.0
	cc@1.0.83
	cexpr@0.6.0
	cfg-if@1.0.0
	cipher@0.3.0
	clang-sys@1.6.1
	clap@3.2.25
	clap@4.4.2
	clap_builder@4.4.2
	clap_lex@0.2.4
	clap_lex@0.5.1
	colorchoice@1.0.0
	concurrent-queue@2.2.0
	core-foundation@0.9.3
	core-foundation-sys@0.8.4
	cpufeatures@0.2.9
	crossbeam@0.8.2
	crossbeam-channel@0.5.8
	crossbeam-deque@0.8.3
	crossbeam-epoch@0.9.15
	crossbeam-queue@0.3.8
	crossbeam-utils@0.8.16
	crypto-common@0.1.6
	crypto-mac@0.11.1
	deranged@0.3.8
	derivative@2.2.0
	devd-rs@0.3.6
	digest@0.10.7
	digest@0.9.0
	directories@4.0.1
	dirs@4.0.0
	dirs-next@2.0.0
	dirs-sys@0.3.7
	dirs-sys-next@0.1.2
	educe@0.4.23
	either@1.9.0
	enumflags2@0.6.4
	enumflags2@0.7.7
	enumflags2_derive@0.6.4
	enumflags2_derive@0.7.7
	enum-ordinalize@3.1.13
	env_logger@0.9.3
	equivalent@1.0.1
	errno@0.3.3
	errno-dragonfly@0.1.2
	event-listener@2.5.3
	fastrand@1.9.0
	fastrand@2.0.0
	foreign-types@0.3.2
	foreign-types-shared@0.1.1
	fuchsia-cprng@0.1.1
	futures@0.1.31
	futures@0.3.28
	futures-channel@0.3.28
	futures-core@0.3.28
	futures-cpupool@0.1.8
	futures-executor@0.3.28
	futures-io@0.3.28
	futures-lite@1.13.0
	futures-macro@0.3.28
	futures-sink@0.3.28
	futures-task@0.3.28
	futures-util@0.3.28
	generic-array@0.14.7
	getopts@0.2.21
	getrandom@0.1.16
	getrandom@0.2.10
	gimli@0.28.0
	glob@0.3.1
	hashbrown@0.12.3
	hashbrown@0.14.0
	hermit-abi@0.1.19
	hermit-abi@0.3.2
	hex@0.4.3
	hkdf@0.11.0
	hmac@0.11.0
	hmac@0.12.1
	home@0.5.5
	hostname@0.3.1
	humantime@2.1.0
	indexmap@1.9.3
	indexmap@2.0.0
	instant@0.1.12
	io-lifetimes@1.0.11
	itertools@0.11.0
	itoa@1.0.9
	js-sys@0.3.64
	lazycell@1.3.0
	lazy_static@1.4.0
	libc@0.2.147
	libloading@0.7.4
	libsystemd@0.5.0
	libsystemd@0.6.0
	libudev@0.2.0
	libudev-sys@0.1.4
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.7
	lock_api@0.4.10
	log@0.4.20
	mac-notification-sys@0.6.1
	malloc_buf@0.0.6
	match_cfg@0.1.0
	matchers@0.1.0
	memchr@2.6.3
	memoffset@0.6.5
	memoffset@0.7.1
	memoffset@0.9.0
	minimal-lexical@0.2.1
	miniz_oxide@0.7.1
	mio@0.8.8
	nanoid@0.4.0
	nb-connect@1.2.0
	nix@0.22.3
	nix@0.23.2
	nix@0.26.4
	nom@7.1.3
	notify-rust@4.9.0
	nu-ansi-term@0.46.0
	num@0.4.1
	num-bigint@0.4.4
	num-complex@0.4.4
	num_cpus@1.16.0
	num-integer@0.1.45
	num-iter@0.1.43
	num-rational@0.4.1
	numtoa@0.1.0
	num-traits@0.2.16
	objc@0.2.7
	objc-foundation@0.1.1
	objc_id@0.1.1
	object@0.32.1
	once_cell@1.18.0
	opaque-debug@0.3.0
	openssl@0.10.57
	openssl-macros@0.1.1
	openssl-sys@0.9.93
	ordered-stream@0.2.0
	os_str_bytes@6.5.1
	overload@0.1.1
	parking@2.1.0
	parking_lot@0.12.1
	parking_lot_core@0.9.8
	peeking_take_while@0.1.2
	pin-project@1.1.3
	pin-project-internal@1.1.3
	pin-project-lite@0.2.13
	pin-utils@0.1.0
	pkg-config@0.3.27
	pkg-version@1.0.0
	pkg-version-impl@0.1.1
	polling@2.8.0
	ppv-lite86@0.2.17
	prettyplease@0.2.15
	proc-macro2@1.0.66
	proc-macro-crate@0.1.5
	proc-macro-crate@1.3.1
	proc-macro-hack@0.5.20+deprecated
	quick-xml@0.23.1
	quote@1.0.33
	rand@0.4.6
	rand@0.7.3
	rand@0.8.5
	rand_chacha@0.2.2
	rand_chacha@0.3.1
	rand_core@0.3.1
	rand_core@0.4.2
	rand_core@0.5.1
	rand_core@0.6.4
	rand_hc@0.2.0
	rdrand@0.4.0
	redox_syscall@0.2.16
	redox_syscall@0.3.5
	redox_termios@0.1.2
	redox_users@0.4.3
	regex@1.9.5
	regex-automata@0.1.10
	regex-automata@0.3.8
	regex-syntax@0.6.29
	regex-syntax@0.7.5
	remove_dir_all@0.5.3
	ring@0.16.20
	runloop@0.1.0
	rustc-demangle@0.1.23
	rustc-hash@1.1.0
	rustix@0.37.23
	rustix@0.38.13
	ryu@1.0.15
	scoped-tls@1.0.1
	scopeguard@1.2.0
	secret-service@2.0.2
	serde@1.0.188
	serde_derive@1.0.188
	serde_json@1.0.106
	serde_repr@0.1.16
	sha1@0.10.5
	sha2@0.10.7
	sha2@0.9.9
	sharded-slab@0.1.4
	shlex@1.2.0
	signal-hook@0.3.17
	signal-hook-registry@1.4.1
	slab@0.4.9
	smallvec@1.11.0
	socket2@0.4.9
	socket2@0.5.4
	spin@0.5.2
	static_assertions@1.1.0
	strsim@0.10.0
	subtle@2.4.1
	syn@1.0.109
	syn@2.0.32
	take_mut@0.2.2
	tauri-winrt-notification@0.1.2
	tempdir@0.3.7
	tempfile@3.8.0
	termcolor@1.2.0
	termion@1.5.6
	textwrap@0.16.0
	thiserror@1.0.48
	thiserror-impl@1.0.48
	thread_local@1.1.7
	time@0.3.28
	time-core@0.1.1
	tokio@1.32.0
	tokio-macros@2.1.0
	tokio-serde@0.8.0
	tokio-stream@0.1.14
	tokio-tower@0.6.0
	tokio-util@0.7.8
	toml@0.5.11
	toml_datetime@0.6.3
	toml_edit@0.19.15
	tower@0.4.13
	tower-layer@0.3.2
	tower-service@0.3.2
	tracing@0.1.37
	tracing-attributes@0.1.26
	tracing-core@0.1.31
	tracing-journald@0.2.4
	tracing-journald@0.3.0
	tracing-log@0.1.3
	tracing-subscriber@0.3.17
	typenum@1.16.0
	uds_windows@1.0.2
	unicode-ident@1.0.11
	unicode-width@0.1.10
	untrusted@0.7.1
	users@0.11.0
	utf8parse@0.2.1
	uuid@0.8.2
	uuid@1.4.1
	valuable@0.1.0
	vcpkg@0.2.15
	version_check@0.9.4
	waker-fn@1.1.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.9.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.87
	wasm-bindgen-backend@0.2.87
	wasm-bindgen-macro@0.2.87
	wasm-bindgen-macro-support@0.2.87
	wasm-bindgen-shared@0.2.87
	web-sys@0.3.64
	which@4.4.2
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.5
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows@0.39.0
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_msvc@0.39.0
	windows_aarch64_msvc@0.48.5
	windows_i686_gnu@0.39.0
	windows_i686_gnu@0.48.5
	windows_i686_msvc@0.39.0
	windows_i686_msvc@0.48.5
	windows-sys@0.48.0
	windows-targets@0.48.5
	windows_x86_64_gnu@0.39.0
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_msvc@0.39.0
	windows_x86_64_msvc@0.48.5
	winnow@0.5.15
	xdg-home@1.0.0
	zbus@1.9.3
	zbus@3.14.1
	zbus_macros@1.9.3
	zbus_macros@3.14.1
	zbus_names@2.6.0
	zvariant@2.10.0
	zvariant@3.15.0
	zvariant_derive@2.10.0
	zvariant_derive@3.15.0
	zvariant_utils@1.0.1
"

declare -A GIT_CRATES=(
	[authenticator]='https://github.com/mozilla/authenticator-rs;660a701b45977cb5d184380061dfc8cec4f696be;authenticator-rs-%commit%'
)

inherit cargo systemd tmpfiles

DESCRIPTION="A software-only Universal 2nd Factor token"
HOMEPAGE="https://github.com/danstiner/rust-u2f"

COMMIT="da1c12db6167f51c46091d45a274a56ab67e45e7"
# SRC_URI="https://github.com/danstiner/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
SRC_URI="https://github.com/danstiner/${PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}"

# S=${WORKDIR}/${P}/linux
S=${WORKDIR}/${PN}-${COMMIT}/linux

# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"

SLOT="0"
KEYWORDS="~amd64"
IUSE="+debug"
RESTRICT="mirror"

# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="/usr/bin/${PN}"

src_unpack() {
	cargo_src_unpack
	cd "${S}/.."
# 	eapply "${FILESDIR}/deps-no-git.patch"
}

src_install() {
	cp ../target/$(usex debug debug release)/{softu2f-,}user-daemon
	cp ../target/$(usex debug debug release)/{softu2f-,}system-daemon
	exeinto /usr/lib/softu2f
	doexe ../target/$(usex debug debug release)/{user,system}-daemon

	systemd_dounit system-daemon/softu2f.{service,socket}
	systemd_douserunit user-daemon/softu2f.service
	newtmpfiles system-daemon/softu2f-tmpfiles.conf softu2f.conf

	einstalldocs
}

pkg_postinst() {
	tmpfiles_process softu2f.conf
}