# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Sertonix <sertonix@posteo.net>
pkgname=brillo
pkgver=1.4.12
pkgrel=3
pkgdesc="Control the brightness of backlight and keyboard LED devices"
url="https://gitlab.com/cameronnemo/brillo"
arch="all"
license="GPL-3.0-only"
makedepends="go-md2man"
checkdepends="valgrind /bin/sh"
subpackages="
	$pkgname-doc
	$pkgname-udev::noarch
	$pkgname-polkit::noarch
	"
source="https://gitlab.com/cameronnemo/brillo/-/archive/v$pkgver/brillo-v$pkgver.tar.gz"
builddir="$srcdir/brillo-v$pkgver"
case "$CARCH" in
	# armhf|riscv64|loongarch64: valgrind not available
	# armv7|ppc64le: check fails
	armhf|riscv64|armv7|ppc64le|loongarch64)
		options="$options !check"
		;;
esac

build() {
	make VERSION="alpine-$pkgver-r$pkgrel"
}

check() {
	BRILLO_BIN=build/brillo sh ./test.sh
}

package() {
	make DESTDIR="$pkgdir" install-dist
}

udev() {
	pkgdesc="$pkgdesc (udev rules)"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel udev"

	amove usr/lib/udev
}

polkit() {
	pkgdesc="$pkgdesc (polkit config)"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel polkit"

	amove usr/share/polkit-1
}

sha512sums="
450e46ac9db70da52f320a9d0683bea15968a7d75c225ace00fcddcd4121af405586d742eca4e7787a5ed7f666ff985bfd46bc353ce1fabcc7f0dbf0c0ec0b3f  brillo-v1.4.12.tar.gz
"
