# Maintainer: Saijin-Naib <Saijin-Naib_package-maintenance@outlook.com>
pkgname=gtkhash
pkgver=1.5
pkgrel=0
pkgdesc="Utility for computing message digests and checksums"
url="https://gtkhash.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	caja-dev
	cmake
	glib-dev
	gtk+3.0-dev
	gtk-doc
	libb2-dev
	libgcrypt-dev
	librsvg-dev
	meson
	nautilus-dev
	nemo-dev
	openssl-dev>3
	thunar-dev
	zlib-dev
	"
checkdepends="xvfb-run" # Not running properly under CI
subpackages="
	$pkgname-lang
	caja-gtkhash-plugin:_caja
	nemo-gtkhash-plugin:_nemo
	thunar-gtkhash-plugin:_thunar
	"
source="https://github.com/tristanheaven/gtkhash/releases/download/v$pkgver/gtkhash-$pkgver.tar.gz
	gettext-0.22.patch
	"
options="!check" # Disable check until failure under CI fixed

build() {
	abuild-meson \
		-Db_lto=true \
		-Dblake2=true \
		-Dgcrypt=true \
		-Dglib-checksums=true \
		-Dinternal-md6=true \
		-Dlibcrypto=true \
		-Dlinux-crypto=true \
		-Dzlib=true \
		-Dnative-file-chooser=true \
		-Dappstream=true \
		-Dbuild-gtkhash=true \
		-Dbuild-caja=true \
		-Dbuild-nautilus=false \
		-Dbuild-nemo=true \
		-Dbuild-thunar=true \
		. output
	meson compile -C output
}

# https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31622#note_220087
check() {
	xvfb-run meson test -C output
}

_caja() {
	pkgdesc="$pkgdesc (caja plugin)"
	amove usr/lib/caja
	amove usr/share/caja
}

_nautilus() {
	pkgdesc="$pkgdesc (nautilus plugin)"
	amove usr/lib/nautilus
}

_nemo() {
	pkgdesc="$pkgdesc (nemo plugin)"
	amove usr/lib/nemo
}

_thunar() {
	pkgdesc="$pkgdesc (thunar plugin)"
	amove usr/lib/thunarx-3
}

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

sha512sums="
a71ec8780533ecb72f16ae9bc6fdfb5cf58f945c8fab9c16ee5007b04c22af701aaac79895ded9f7b573625020e9597a191fb81a68cec63111c089f1d03e2347  gtkhash-1.5.tar.gz
1be4bf68f15f64910395ee962d7c0747f972e2678487a1f8f2666a0f7ede4d88af417fbecc08c8fb953a34a8289831b9a681402121a6bf53bb2aa2ccbd6c3bf0  gettext-0.22.patch
"
