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

EAPI=8
PYTHON_COMPAT=( python3_{12..15} )
UBUNTU_EAUTORECONF="yes"

UVER=+19.04.20190319
UREV=8

inherit gnome2-utils python-single-r1 vala ubuntu-versionator

DESCRIPTION="Library for instrumenting and integrating with all aspects of the Unity shell"
HOMEPAGE="https://launchpad.net/libunity"
SRC_URI="${SRC_URI} ${UURL}-${UREV}.debian.tar.xz"
S="${WORKDIR}"

LICENSE="GPL-3 LGPL-3"
SLOT="0/$(usub)"
KEYWORDS="amd64"
IUSE="test"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RESTRICT="!test? ( test )"

COMMON_DEPEND="
	>=dev-libs/dee-1.2.7:0=[${PYTHON_SINGLE_USEDEP}]
	>=dev-libs/glib-2.43.92:2
	>=dev-libs/libdbusmenu-0.4.90[introspection]
	x11-libs/gtk+:3
"
RDEPEND="${COMMON_DEPEND}
	gnome-base/dconf

	${PYTHON_DEPS}
	$(python_gen_cond_dep '
		dev-python/pygobject:3[${PYTHON_USEDEP}]
		dev-python/zombie-imp[${PYTHON_USEDEP}]
	')
"
DEPEND="${COMMON_DEPEND}"
BDEPEND="
	dev-libs/gobject-introspection
	dev-util/intltool
	sys-devel/gettext
	virtual/pkgconfig

	test? (
		sys-apps/dbus
		x11-misc/xvfb-run
	)

	${PYTHON_DEPS}
	$(python_gen_cond_dep 'dev-python/pygobject:3[${PYTHON_USEDEP}]')

	$(vala_depend)
"

src_configure() {
	local myeconfargs=(
		$(use_enable test headless-tests)

		# Test binaries are linked with -static against internal symbols #
		$(use_enable test static)
	)
	econf "${myeconfargs[@]}"
}

src_install() {
	default
	find "${ED}" \( -name '*.a' -o -name '*.la' \) -delete || die

	python_fix_shebang "${ED}"/usr/share/unity-scopes/scope-runner-dbus.py
}

pkg_postinst() {
	gnome2_schemas_update
	ubuntu-versionator_pkg_postinst
}

pkg_postrm() {
	gnome2_schemas_update
}