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

# Autogenerated by pycargoebuild 0.13.3

EAPI=8

CRATES="
"

declare -A GIT_CRATES=(
	[fix-path-env]='https://github.com/tauri-apps/fix-path-env-rs;8481725b7ebfc56cdb052d522517421242eac36b;fix-path-env-rs-%commit%'
)

inherit cargo desktop xdg

COMMIT="1e604033788c01bae4008fe07479472765f3390d"

DESCRIPTION="A GUI to browse and restore from restic backup repositories"
HOMEPAGE="https://github.com/emuell/restic-browser"
SRC_URI="
	https://github.com/emuell/restic-browser/archive/${COMMIT}.tar.gz
		-> ${P}.tar.gz
	https://gitlab.com/api/v4/projects/64331580/packages/generic/${PN}/${PV}/${P}-node_modules.tar.xz
	https://gitlab.com/api/v4/projects/64331580/packages/generic/${PN}/${PV}/${P}-crates.tar.xz
	${CARGO_CRATE_URIS}
"
S="${WORKDIR}/${PN}-${COMMIT}/src-tauri"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD ISC MIT MPL-2.0
	Unicode-3.0
"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
	app-backup/restic
	dev-libs/glib:2
	net-libs/libsoup:3.0
	net-libs/webkit-gtk:4.1
	x11-base/xorg-server
	x11-libs/cairo
	x11-libs/gdk-pixbuf:2
	x11-libs/gtk+:3[wayland]
	x11-libs/pango
"
DEPEND="${RDEPEND}"
BDEPEND="
	net-libs/nodejs[npm]
"

QA_FLAGS_IGNORED="usr/bin/restic-browser"

src_prepare() {
	pushd .. >/dev/null || die
	default
	popd >/dev/null || die

	mv "${WORKDIR}"/node_modules "${S}"/.. || die
}

src_configure() {
	local myfeatures=(
		custom-protocol
	)
	cargo_src_configure
}

src_compile() {
	pushd .. >/dev/null || die
	npm run build || die
	popd >/dev/null || die

	cargo_src_compile
}

src_install() {
	cargo_src_install

	newicon "${S}/icons/icon.png" "${PN}.png"
	make_desktop_entry "${PN}" Restic-Browser "${PN}"
}