# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=colord
pkgver=1.4.7
pkgrel=0
pkgdesc="System daemon for managing color devices"
url="https://www.freedesktop.org/software/colord"
arch="all"
license="GPL-2.0-or-later"
pkgusers="colord"
pkggroups="colord"
depends="libcolord=$pkgver-r$pkgrel"
depends_dev="
	dbus-dev
	dconf-dev
	eudev-dev
	gobject-introspection-dev
	libgudev-dev
	polkit-dev
	sane-dev
	sqlite-dev
	vala
	"
makedepends="$depends_dev
	bash-completion-dev
	lcms2-dev
	libgusb-dev
	meson
	"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="
	$pkgname-dev
	$pkgname-lang
	$pkgname-colorhug
	$pkgname-sane
	$pkgname-bash-completion
	libcolord
	"
source="https://www.freedesktop.org/software/colord/releases/colord-$pkgver.tar.xz
	disable-udev-hwdb-tests.patch
	null-free.patch
	"

build() {
	abuild-meson \
		-Dsystemd=false \
		-Dargyllcms_sensor=false \
		-Dman=false \
		-Ddocs=false \
		-Ddaemon_user=colord \
		-Dsane=true \
		-Dvapi=true \
		output .

	meson compile -C output
}

check() {
	# cd-private-test is broken atm
	# meson test

	output/src/cd-self-test
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	chown -R colord:colord "$pkgdir"/var/lib/colord
}

colorhug() {
	pkgdesc="$pkgdesc (ColorHug support)"

	amove usr/lib/libcolorhug.so.*
	amove usr/lib/girepository-1.0/Colorhug-*.typelib
	amove usr/lib/colord-sensors/libcolord_sensor_colorhug.so
}

sane() {
	pkgdesc="$pkgdesc (SANE support)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/libexec/colord-sane
	amove usr/lib/colord-plugins/libcolord_sensor_sane.so
}

libcolord() {
	pkgdesc="$pkgdesc (client library)"
	depends=""

	amove usr/lib/libcolord.so.*
	amove usr/lib/libcolordprivate.so.*
	amove usr/lib/girepository-1.0/Colord-*.typelib
}

sha512sums="
d8a23899c038af980f1b257eace68b682c3f5592d19e2ae1044da749371694052c00e58e4754ebb6ee2f7900b0ef44c01be5fcf857294813c07af94ffbf6d0be  colord-1.4.7.tar.xz
4e306254902658ffe0904b4ee3fdc10c473af909662c08fc66b9070fd698e07e1f804e53ccd94160ac57d268269132683808ff8f2bae64fd2a9070d6f024b800  disable-udev-hwdb-tests.patch
cea40faf9ce23d4877e46dd89a7b51118afb4c92016f1f24dd1b5a6eba5efffb012477dd1a8bb641de72c094702f8ecabfe7659d43b19826def921afe465c279  null-free.patch
"
