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

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	aho-corasick@1.1.2
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	anstream@0.6.4
	anstyle-parse@0.2.2
	anstyle-query@1.0.0
	anstyle-wincon@3.0.1
	anstyle@1.0.4
	async-broadcast@0.5.1
	async-channel@2.1.0
	async-executor@1.7.2
	async-fs@1.6.0
	async-io@1.13.0
	async-io@2.2.0
	async-lock@2.8.0
	async-lock@3.1.1
	async-process@1.8.1
	async-recursion@1.0.5
	async-signal@0.2.5
	async-task@4.5.0
	async-trait@0.1.74
	atomic-waker@1.1.2
	autocfg@1.1.0
	backtrace@0.3.69
	base64@0.21.5
	bitflags@1.3.2
	bitflags@2.4.1
	block-buffer@0.10.4
	block@0.1.6
	blocking@1.5.1
	bumpalo@3.14.0
	byteorder@1.5.0
	bytes@1.5.0
	cc@1.0.83
	cfg-if@1.0.0
	chrono@0.4.31
	clap@4.4.8
	clap_builder@4.4.8
	clap_complete@4.4.4
	clap_derive@4.4.7
	clap_lex@0.6.0
	clap_mangen@0.2.15
	color-eyre@0.6.2
	color-spantrace@0.2.1
	colorchoice@1.0.0
	concurrent-queue@2.3.0
	console@0.15.7
	const-random-macro@0.1.16
	const-random@0.1.17
	core-foundation-sys@0.8.4
	core-foundation@0.9.3
	cpufeatures@0.2.11
	crc32fast@1.3.2
	crossbeam-utils@0.8.16
	crunchy@0.2.2
	crypto-common@0.1.6
	deranged@0.3.9
	derivative@2.2.0
	digest@0.10.7
	dirs-next@2.0.0
	dirs-sys-next@0.1.2
	dirs-sys@0.4.1
	dirs@5.0.1
	dlv-list@0.5.2
	either@1.9.0
	encode_unicode@0.3.6
	encoding_rs@0.8.33
	enumflags2@0.7.8
	enumflags2_derive@0.7.8
	equivalent@1.0.1
	errno@0.3.7
	etcetera@0.8.0
	event-listener-strategy@0.3.0
	event-listener@2.5.3
	event-listener@3.1.0
	eyre@0.6.9
	fastrand@1.9.0
	fastrand@2.0.1
	filetime@0.2.22
	flate2@1.0.28
	fnv@1.0.7
	form_urlencoded@1.2.1
	futures-channel@0.3.29
	futures-core@0.3.29
	futures-executor@0.3.29
	futures-io@0.3.29
	futures-lite@1.13.0
	futures-lite@2.0.1
	futures-macro@0.3.29
	futures-sink@0.3.29
	futures-task@0.3.29
	futures-util@0.3.29
	futures@0.3.29
	generic-array@0.14.7
	getrandom@0.2.11
	gimli@0.28.0
	glob@0.3.1
	h2@0.3.24
	hashbrown@0.13.2
	hashbrown@0.14.2
	heck@0.4.1
	hermit-abi@0.3.3
	hex@0.4.3
	home@0.5.5
	http-body@0.4.5
	http@0.2.11
	httparse@1.8.0
	httpdate@1.0.3
	hyper-rustls@0.24.2
	hyper@0.14.27
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.58
	idna@0.5.0
	indenter@0.3.3
	indexmap@2.1.0
	indicatif@0.16.2
	instant@0.1.12
	io-lifetimes@1.0.11
	ipnet@2.9.0
	itoa@1.0.9
	js-sys@0.3.65
	lazy_static@1.4.0
	libc@0.2.150
	libredox@0.0.1
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.11
	log@0.4.20
	mac-notification-sys@0.6.1
	malloc_buf@0.0.6
	matchers@0.1.0
	memchr@2.6.4
	memoffset@0.7.1
	merge@0.1.0
	merge_derive@0.1.0
	mime@0.3.17
	miniz_oxide@0.7.1
	mio@0.8.9
	nix@0.26.4
	nix@0.27.1
	notify-rust@4.10.0
	nu-ansi-term@0.46.0
	num-traits@0.2.17
	num_cpus@1.16.0
	number_prefix@0.4.0
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	object@0.32.1
	once_cell@1.18.0
	option-ext@0.2.0
	ordered-multimap@0.6.0
	ordered-stream@0.2.0
	overload@0.1.1
	owo-colors@3.5.0
	parking@2.2.0
	parselnk@0.1.1
	percent-encoding@2.3.1
	pin-project-lite@0.2.13
	pin-utils@0.1.0
	piper@0.2.1
	polling@2.8.0
	polling@3.3.0
	powerfmt@0.2.0
	ppv-lite86@0.2.17
	proc-macro-crate@1.3.1
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.69
	quick-xml@0.22.0
	quick-xml@0.30.0
	quote@1.0.33
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	redox_syscall@0.3.5
	redox_syscall@0.4.1
	redox_users@0.4.4
	regex-automata@0.1.10
	regex-automata@0.4.3
	regex-split@0.1.0
	regex-syntax@0.6.29
	regex-syntax@0.8.2
	regex@1.10.2
	reqwest@0.11.22
	ring@0.17.5
	roff@0.2.1
	rust-ini@0.19.0
	rustc-demangle@0.1.23
	rustix@0.37.27
	rustix@0.38.25
	rustls-pemfile@1.0.4
	rustls-webpki@0.101.7
	rustls@0.21.9
	rustversion@1.0.14
	ryu@1.0.15
	same-file@1.0.6
	sct@0.7.1
	self_update@0.30.0
	semver@1.0.20
	serde@1.0.193
	serde_derive@1.0.193
	serde_json@1.0.108
	serde_repr@0.1.17
	serde_spanned@0.6.4
	serde_urlencoded@0.7.1
	sha1@0.10.6
	sharded-slab@0.1.7
	shell-words@1.1.0
	shellexpand@3.1.0
	signal-hook-registry@1.4.1
	slab@0.4.9
	smallvec@1.11.2
	socket2@0.4.10
	socket2@0.5.5
	spin@0.9.8
	static_assertions@1.1.0
	strsim@0.10.0
	strum@0.24.1
	strum_macros@0.24.3
	syn@1.0.109
	syn@2.0.39
	system-configuration-sys@0.5.0
	system-configuration@0.5.1
	tar@0.4.40
	tauri-winrt-notification@0.1.3
	tempfile@3.8.1
	thiserror-impl@1.0.50
	thiserror@1.0.50
	thread_local@1.1.7
	time-core@0.1.2
	time-macros@0.2.15
	time@0.3.30
	tiny-keccak@2.0.2
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio-rustls@0.24.1
	tokio-util@0.7.10
	tokio@1.34.0
	toml@0.8.8
	toml_datetime@0.6.5
	toml_edit@0.19.15
	toml_edit@0.21.0
	tower-service@0.3.2
	tracing-attributes@0.1.27
	tracing-core@0.1.32
	tracing-error@0.2.0
	tracing-log@0.2.0
	tracing-subscriber@0.3.18
	tracing@0.1.40
	try-lock@0.2.4
	typenum@1.17.0
	uds_windows@1.0.2
	unicode-bidi@0.3.13
	unicode-ident@1.0.12
	unicode-normalization@0.1.22
	unicode-width@0.1.11
	untrusted@0.9.0
	url@2.5.0
	utf8parse@0.2.1
	valuable@0.1.0
	version_check@0.9.4
	waker-fn@1.1.1
	walkdir@2.4.0
	want@0.3.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen-backend@0.2.88
	wasm-bindgen-futures@0.4.38
	wasm-bindgen-macro-support@0.2.88
	wasm-bindgen-macro@0.2.88
	wasm-bindgen-shared@0.2.88
	wasm-bindgen@0.2.88
	web-sys@0.3.65
	webpki-roots@0.25.3
	which@4.1.0
	widestring@0.4.3
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.6
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-core@0.51.1
	windows-sys@0.45.0
	windows-sys@0.48.0
	windows-targets@0.42.2
	windows-targets@0.48.5
	windows@0.51.1
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.48.5
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.48.5
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.48.5
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.48.5
	winnow@0.5.19
	winreg@0.50.0
	xattr@1.0.1
	xdg-home@1.0.0
	zbus@3.14.1
	zbus_macros@3.14.1
	zbus_names@2.6.0
	zip@0.6.6
	zvariant@3.15.0
	zvariant_derive@3.15.0
	zvariant_utils@1.0.1
"

inherit cargo shell-completion

DESCRIPTION="Upgrade all the things"
HOMEPAGE="https://github.com/topgrade-rs/topgrade"
SRC_URI="
	${CARGO_CRATE_URIS}
	https://github.com/topgrade-rs/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	BSD CC0-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016
	|| ( Apache-2.0 Boost-1.0 )
"
SLOT="0"
KEYWORDS="~amd64"

src_install() {
	cargo_src_install

	# Shell completions
	mkdir -p "${S}/completions"

	# bash
	"${ED}/usr/bin/topgrade" --gen-completion bash > "${S}/completions/${PN}"
	dobashcomp "${S}/completions/${PN}"

	# zsh
	"${ED}/usr/bin/topgrade" --gen-completion zsh > "${S}/completions/_${PN}"
	dozshcomp "${S}/completions/_${PN}"

	# fish
	"${ED}/usr/bin/topgrade" --gen-completion fish > "${S}/completions/${PN}.fish"
	dofishcomp "${S}/completions/${PN}.fish"

	# manpage
	"${ED}/usr/bin/topgrade" --gen-manpage > "${S}/completions/${PN}.1"
	doman "${S}/completions/${PN}.1"
}