# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tracker
pkgver=3.7.3
pkgrel=0
pkgdesc="Personal search tool and storage system"
url="https://tracker.gnome.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	asciidoc
	bash-completion-dev
	dbus-dev
	glib-dev
	gobject-introspection-dev
	icu-dev
	json-glib-dev
	libsoup3-dev
	libstemmer-dev
	libxml2-dev
	meson
	py3-gobject3
	py3-setuptools
	sqlite-dev
	networkmanager-dev
	vala
	"
checkdepends="
	bash
	dbus
	"
subpackages="
	$pkgname-dbg
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	lib$pkgname:libs
	$pkgname-bash-completion
	$pkgname-testutils:_testutils"
source="https://download.gnome.org/sources/tracker/${pkgver%.*}/tracker-$pkgver.tar.xz"

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddocs=false \
		-Dsystemd_user_services=false \
		-Dtests="$(want_check && echo true || echo false)" \
		. output
	meson compile -C output
}

check() {
	XDG_RUNTIME_DIR="$(mktemp -p "$builddir" -d)" \
	dbus-run-session -- \
	meson test -t 10 --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_testutils() {
	pkgdesc="$pkgname (test utilities)"
	depends="tracker=$pkgver-r$pkgrel py3-gobject3 bash"

	amove usr/lib/tracker-3.0/trackertestutils
}

sha512sums="
e6b074c9942de7e5559f56a5e27df3f8e73de7cd09efd389eed3f615fbbf957ac69e0a2861efbf39f356b91455399b86b73ebb11e9d5fe0ef2afa2a7060fa7af  tracker-3.7.3.tar.xz
"
