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

# Autogenerated by pycargoebuild 0.13.2

EAPI=8

inherit cargo gnome2-utils meson xdg

MY_PN="news_flash_gtk"
DESCRIPTION="Feed Reader written in GTK"
HOMEPAGE="https://gitlab.com/news-flash/news_flash_gtk"
SRC_URI="
	https://gitlab.com/news-flash/${MY_PN}/-/archive/v.${PV}/${MY_PN}.tar.bz2
	https://jroy.ca/dist/${P}-vendor.tar.xz
"
COMMIT="57d461a7dc5069c6f49651e7cd022ef82d987105"
S="${WORKDIR}/${MY_PN}-v.${PV}-${COMMIT}"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD GPL-3+ ISC MIT
	MPL-2.0 Unicode-DFS-2016 Unlicense
"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
	dev-db/sqlite:3
	dev-libs/glib
	dev-libs/openssl:=
	gui-libs/gtk
	gui-libs/libadwaita
	media-video/clapper[mpris]
	net-libs/webkit-gtk:6
	sys-devel/gettext
	x11-misc/xdg-utils
"
BDEPEND="
	>=dev-libs/glib-2.80.0
	dev-libs/appstream-glib
	dev-util/blueprint-compiler
"

# Rust
QA_FLAGS_IGNORED="usr/bin/io.gitlab.news_flash.NewsFlash"

src_unpack() {
	cargo_src_unpack
	ln -s "${WORKDIR}/vendor/" "${S}/vendor" || die
	sed -i "${ECARGO_HOME}/config.toml" \
		-e '/source.crates-io/d' \
		-e '/replace-with = "gentoo"/d' \
		-e '/local-registry = "\/nonexistent"/d' \
		|| die
	cat vendor/vendor-config.toml >> "${ECARGO_HOME}/config.toml" || die
}

src_configure() {
	meson_src_configure
	ln -s "${CARGO_HOME}" "${BUILD_DIR}/cargo-home" || die
	ln -s "${WORKDIR}/vendor/" "${BUILD_DIR}/vendor" || die
}

src_install() {
	meson_src_install
	dosym -r /usr/bin/io.gitlab.news_flash.NewsFlash /usr/bin/newsflash
}

pkg_postinst() {
	xdg_pkg_postinst
	gnome2_schemas_update
	elog "If you want scraper data in order to load some feeds directly in NewsFlash;"
	elog "Clone this repository into ~/.local/share/news-flash/ :"
	elog "https://github.com/fivefilters/ftr-site-config"
}

pkg_postrm() {
	xdg_pkg_postrm
	gnome2_schemas_update
}