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

EAPI=8

VALA_MIN_API_VERSION="0.56"

inherit meson vala gnome2-utils xdg

DESCRIPTION="Home Assistant companion app for Linux"
HOMEPAGE="https://github.com/cassidyjames/butler"
SRC_URI="https://github.com/cassidyjames/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="~amd64 ~arm64"

RDEPEND="
	>=dev-libs/glib-2.82.0:2
	>=gui-libs/gtk-4.16.1:4
	>=gui-libs/libadwaita-1.6.0:1
	>=net-libs/webkit-gtk-2.46.0:6
"
DEPEND="${RDEPEND}"
BDEPEND="
	$(vala_depend)
	>=dev-build/meson-1.5.1
	sys-devel/gettext
	dev-util/desktop-file-utils
"

src_configure() {
	vala_setup

	local emesonargs=(
		-Dprofile=release
	)
	meson_src_configure
}

src_install() {
	# Neutralize upstream post_install.py which tries to compile schemas
	# outside the sandbox. Schema compilation is handled by
	# gnome2_schemas_update in pkg_postinst via gnome2-utils eclass.
	echo "#!/usr/bin/env python3" > "${S}/build-aux/meson/post_install.py" || die
	meson_src_install
}

pkg_postinst() {
	xdg_pkg_postinst
	gnome2_schemas_update
}

pkg_postrm() {
	xdg_pkg_postrm
	gnome2_schemas_update
}