# 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 plocale

PLOCALES="de fr it nb nn ru sv"

DESCRIPTION="A password manager that uses the file format of 'pass'"
HOMEPAGE="https://github.com/cortex/ripasso"
SRC_URI="https://github.com/cortex/${PN}/archive/refs/tags/release-${PV}.tar.gz -> ${P}.tar.gz"
DEPS_URI="https://github.com/freijon/${PN}/releases/download/release-${PV}/${P}-crates.tar.xz"
SRC_URI+=" ${DEPS_URI}"

S="${WORKDIR}/${PN}-release-${PV}"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 CC0-1.0 ISC
	LGPL-2+ LGPL-2.1 MIT MPL-2.0 Unicode-3.0 Unicode-DFS-2016 Unlicense
	|| ( GPL-2 GPL-3 LGPL-3 )
"
SLOT="0"
KEYWORDS="~amd64"
IUSE="gtk"

DEPEND="
	app-crypt/gpgme
	dev-libs/gmp
	dev-libs/libgit2:=
	dev-libs/libgpg-error
	dev-libs/nettle
	dev-libs/openssl:0=
	sys-libs/zlib
	gtk? ( gui-libs/gtk )
"
RDEPEND="${DEPEND}"
BDEPEND="
	virtual/pkgconfig
"

# See https://github.com/cortex/ripasso/issues/348
RESTRICT+=" test"

QA_FLAGS_IGNORED="usr/bin/${PN}.*"

src_configure() {
	# high magic to allow system-libs
	export OPENSSL_NO_VENDOR=true
	export LIBGIT2_SYS_USE_PKG_CONFIG=1
	export PKG_CONFIG_ALLOW_CROSS=1

	cargo_src_configure
}

src_install() {
	cargo_src_install --path "cursive"
	use gtk && cargo_src_install --path "gtk"

	dosym "${PN}-cursive" "/usr/bin/${PN}"

	mv "target/man-page/cursive/${PN}-cursive.1" "target/man-page/cursive/${PN}.1" || die
	doman "target/man-page/cursive/${PN}.1"

	plocale_for_each_locale install_translations
}

install_translations() {
	insinto "/usr/share/locale/${1}/LC_MESSAGES/"
	newins "target/translations/cursive/${1}.mo" "${PN}-cursive.mo"
}