# Copyright 2017-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Auto-Generated by cargo-ebuild 0.3.1

EAPI=8

if [[ ${PV} == *9999 ]] ; then
    SCM="git-r3"
    EGIT_REPO_URI="https://github.com/SFTtech/${PN}.git"
fi

if [[ ${PV} == *9999 ]] ; then
    SRC_URI=""
    KEYWORDS=""
else
    SRC_URI="https://github.com/SFTtech/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
    KEYWORDS="~amd64 ~x86"
fi


CRATES="
	aead-0.5.1
	ahash-0.7.6
	aho-corasick-0.7.20
	anyhow-1.0.68
	async-recursion-1.0.0
	async-stream-0.3.3
	async-stream-impl-0.3.3
	async-trait-0.1.61
	atoi-1.0.0
	autocfg-1.1.0
	axum-0.6.2
	axum-core-0.3.1
	backoff-0.4.0
	base64-0.13.1
	base64-0.21.0
	bitflags-1.3.2
	blake2-0.10.6
	block-buffer-0.10.3
	boringtun-0.5.2
	buffering-0.3.4
	bumpalo-3.12.0
	bytecodec-0.4.15
	byteorder-1.4.3
	bytes-1.3.0
	cc-1.0.78
	cfg-if-1.0.0
	chacha20-0.9.0
	chacha20poly1305-0.10.1
	cipher-0.4.3
	clap-4.1.1
	clap_complete-4.1.0
	clap_derive-4.1.0
	clap_lex-0.3.1
	cpufeatures-0.2.5
	crc-2.1.0
	crc-3.0.0
	crc-catalog-1.1.1
	crc-catalog-2.2.0
	crossbeam-queue-0.3.8
	crossbeam-utils-0.8.14
	crypto-common-0.1.6
	curve25519-dalek-3.2.0
	darling-0.12.4
	darling_core-0.12.4
	darling_macro-0.12.4
	derive_builder-0.10.2
	derive_builder_core-0.10.2
	derive_builder_macro-0.10.2
	digest-0.9.0
	digest-0.10.6
	dotenvy-0.15.6
	either-1.8.0
	errno-0.2.8
	errno-dragonfly-0.1.2
	eui48-1.1.0
	event-listener-2.5.3
	fastrand-1.8.0
	fixedbitset-0.4.2
	flume-0.10.14
	fnv-1.0.7
	form_urlencoded-1.1.0
	futures-0.3.25
	futures-channel-0.3.25
	futures-core-0.3.25
	futures-executor-0.3.25
	futures-intrusive-0.4.2
	futures-io-0.3.25
	futures-macro-0.3.25
	futures-sink-0.3.25
	futures-task-0.3.25
	futures-util-0.3.25
	generic-array-0.14.6
	getrandom-0.1.16
	getrandom-0.2.8
	h2-0.3.15
	hashbrown-0.12.3
	hashlink-0.8.1
	heck-0.4.0
	hermit-abi-0.2.6
	hex-0.4.3
	hmac-0.12.1
	hmac-sha1-0.1.3
	http-0.2.8
	http-body-0.4.5
	http-range-header-0.3.0
	httparse-1.8.0
	httpdate-1.0.2
	hyper-0.14.23
	hyper-timeout-0.4.1
	ident_case-1.0.1
	idna-0.3.0
	indexmap-1.9.2
	inout-0.1.3
	instant-0.1.12
	io-lifetimes-1.0.4
	ip_network-0.4.1
	ip_network_table-0.2.0
	ip_network_table-deps-treebitmap-0.5.0
	ipnet-2.7.1
	iprange-0.6.7
	is-terminal-0.4.2
	itertools-0.10.5
	itoa-1.0.5
	js-sys-0.3.60
	lazy_static-1.4.0
	libc-0.2.139
	libsqlite3-sys-0.24.2
	linux-raw-sys-0.1.4
	lock_api-0.4.9
	log-0.4.17
	matchit-0.7.0
	md5-0.7.0
	memchr-2.5.0
	memoffset-0.6.5
	miette-5.5.0
	miette-derive-5.5.0
	mime-0.3.16
	minimal-lexical-0.2.1
	mio-0.8.5
	multimap-0.8.3
	neli-0.4.3
	network-interface-0.1.4
	nix-0.24.3
	nom-7.1.3
	nu-ansi-term-0.46.0
	num-traits-0.2.15
	num_cpus-1.15.0
	once_cell-1.17.0
	opaque-debug-0.3.0
	os_str_bytes-6.4.1
	overload-0.1.1
	parking_lot-0.11.2
	parking_lot-0.12.1
	parking_lot_core-0.8.6
	parking_lot_core-0.9.6
	paste-1.0.11
	percent-encoding-2.2.0
	petgraph-0.6.2
	pin-project-1.0.12
	pin-project-internal-1.0.12
	pin-project-lite-0.2.9
	pin-utils-0.1.0
	pkg-config-0.3.26
	poly1305-0.8.0
	ppv-lite86-0.2.17
	prettyplease-0.1.23
	proc-macro-error-1.0.4
	proc-macro-error-attr-1.0.4
	proc-macro2-1.0.50
	prost-0.11.6
	prost-build-0.11.6
	prost-derive-0.11.6
	prost-types-0.11.6
	quote-1.0.23
	rand-0.8.5
	rand_chacha-0.3.1
	rand_core-0.5.1
	rand_core-0.6.4
	redox_syscall-0.2.16
	regex-1.7.1
	regex-syntax-0.6.28
	remove_dir_all-0.5.3
	ring-0.16.20
	rustc-serialize-0.3.24
	rustix-0.36.7
	rustls-0.20.8
	rustls-pemfile-1.0.2
	rustversion-1.0.11
	scopeguard-1.1.0
	sct-0.7.0
	serde-1.0.152
	sha1-0.2.0
	sha2-0.10.6
	sharded-slab-0.1.4
	signal-hook-registry-1.4.0
	slab-0.4.7
	smallvec-1.10.0
	socket2-0.4.7
	spin-0.5.2
	spin-0.9.4
	sqlformat-0.2.1
	sqlx-0.6.2
	sqlx-core-0.6.2
	sqlx-macros-0.6.2
	sqlx-rt-0.6.2
	stringprep-0.1.2
	strsim-0.10.0
	stun_codec-0.2.0
	subtle-2.4.1
	syn-1.0.107
	sync_wrapper-0.1.1
	synstructure-0.12.6
	tempfile-3.3.0
	termcolor-1.2.0
	thiserror-1.0.38
	thiserror-impl-1.0.38
	thread_local-1.1.4
	tinyvec-1.6.0
	tinyvec_macros-0.1.0
	tokio-1.24.2
	tokio-graceful-shutdown-0.12.1
	tokio-io-timeout-1.2.0
	tokio-macros-1.8.2
	tokio-rustls-0.23.4
	tokio-stream-0.1.11
	tokio-util-0.7.4
	tonic-0.8.3
	tonic-build-0.8.4
	tower-0.4.13
	tower-http-0.3.5
	tower-layer-0.3.2
	tower-service-0.3.2
	tracing-0.1.37
	tracing-attributes-0.1.23
	tracing-core-0.1.30
	tracing-error-0.2.0
	tracing-futures-0.2.5
	tracing-log-0.1.3
	tracing-subscriber-0.3.16
	tracing-unwrap-0.10.0
	trackable-0.2.24
	trackable-1.2.0
	trackable_derive-1.0.0
	try-lock-0.2.4
	typed-builder-0.11.0
	typenum-1.16.0
	unicode-bidi-0.3.8
	unicode-ident-1.0.6
	unicode-normalization-0.1.22
	unicode-segmentation-1.10.0
	unicode-width-0.1.10
	unicode-xid-0.2.4
	unicode_categories-0.1.1
	universal-hash-0.5.0
	untrusted-0.7.1
	untrusted-0.9.0
	url-2.3.1
	uuid-1.2.2
	valuable-0.1.0
	vcpkg-0.2.15
	version_check-0.9.4
	want-0.3.0
	wasi-0.9.0+wasi-snapshot-preview1
	wasi-0.11.0+wasi-snapshot-preview1
	wasm-bindgen-0.2.83
	wasm-bindgen-backend-0.2.83
	wasm-bindgen-macro-0.2.83
	wasm-bindgen-macro-support-0.2.83
	wasm-bindgen-shared-0.2.83
	web-sys-0.3.60
	webpki-0.22.0
	webpki-roots-0.22.6
	which-4.3.0
	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-sys-0.42.0
	windows_aarch64_gnullvm-0.42.1
	windows_aarch64_msvc-0.42.1
	windows_i686_gnu-0.42.1
	windows_i686_msvc-0.42.1
	windows_x86_64_gnu-0.42.1
	windows_x86_64_gnullvm-0.42.1
	windows_x86_64_msvc-0.42.1
	wireguard-uapi-2.0.5
	x25519-dalek-2.0.0-pre.1
	zeroize-1.5.7
	zeroize_derive-1.3.3
"

inherit cargo ${SCM}

DESCRIPTION="Wirespider allows distributing wireguard tunnels and routes"
# Double check the homepage as the cargo_metadata crate
# does not provide this value so instead repository is used
HOMEPAGE="https://github.com/SFTtech/wirespider"
SRC_URI="${SRC_URI} $(cargo_crate_uris ${CRATES})"
RESTRICT="mirror"
# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 GPL-3 ISC MIT MPL-2.0 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

BDEPEND=">=virtual/rust-1.59[rustfmt]
	dev-libs/protobuf"
DEPEND=""
RDEPEND="acct-user/wirespider"


src_install() {
    cargo_src_install
    insinto /lib/systemd/system/
    doins systemd/system/wirespider-server.service
    doins systemd/system/wirespider-client@.service

    insinto /etc/wirespider/
    newins systemd/wirespider/wg0 example

	insinto /usr/share/bash-completion/completions/
	newins completions/wirespider.bash wirespider

	insinto /usr/share/zsh/site-functions/
	doins completions/_wirespider

    dodoc README.md CHANGELOG.md LICENSE
}