# Copyright 2024 Robert Günzler
# Distributed under the terms of the GNU General Public License v2

EAPI=8

RUST_MIN_VER="1.88.0"
inherit cargo

DESCRIPTION="synchronize calendars and contacts"
HOMEPAGE="https://git.sr.ht/~whynothugo/pimsync"

if [[ ${PV} = *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://git.sr.ht/~whynothugo/pimsync"
	RESTRICT="network-sandbox"
else
	SRC_URI="https://git.sr.ht/~whynothugo/pimsync/archive/v${PV}.tar.gz -> ${P}.tar.gz
		$(cargo_crate_uris ${CRATES})"
	KEYWORDS="~amd64"
fi

LICENSE="EUPL-1.2"
SLOT="0"
IUSE="jmap"

DEPEND="
	dev-db/sqlite:3
"
RDEPEND="${DEPEND}"
BDEPEND=""

src_unpack() {
	if [[ ${PV} = *9999* ]]; then
		git-r3_src_unpack
		cargo_live_src_unpack
	else
		cargo_src_unpack
	fi
}

src_configure() {
	local myfeatures=(
		$(usev jmap)
	)
	cargo_src_configure --no-default-features
}

src_compile() {
	cargo_src_compile --package ${PN}
}

src_install() {
	cargo_src_install

	doman pimsync.1
	doman pimsync.conf.5
	doman pimsync-migration.7

	dodoc docs/source/*.rst
}