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

# Autogenerated by pycargoebuild 0.13.5

EAPI=8

CRATES="
"

inherit cargo systemd shell-completion

DESCRIPTION="A distinctive utility file server"
HOMEPAGE="https://github.com/sigoden/dufs"
SRC_URI="
	https://github.com/sigoden/dufs/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/gentoo-zh-drafts/dufs/releases/download/v${PV}/${P}-crates.tar.xz
	${CARGO_CRATE_URIS}
"

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

RDEPEND="
	acct-group/${PN}
	acct-user/${PN}
"

src_compile() {
	cargo_src_compile

	mkdir -v completions
	"$(cargo_target_dir)/${PN}" --completions bash > "completions/${PN}" || die
	"$(cargo_target_dir)/${PN}" --completions fish > "completions/${PN}.fish" || die
	"$(cargo_target_dir)/${PN}" --completions zsh > "completions/_${PN}" || die
}

src_install() {
	cargo_src_install

	insinto "/etc/${PN}"
	newins "${FILESDIR}/${PN}-config.yaml" "config.yaml.example"

	systemd_dounit "${FILESDIR}/${PN}.service"
	systemd_newunit "${FILESDIR}/${PN}_at.service" "${PN}@.service"

	dobashcomp "completions/${PN}"
	dofishcomp "completions/${PN}.fish"
	dozshcomp "completions/_${PN}"
}