maintainer="Johannes Marbach <n0-0ne+gitlab@mailbox.org>"
pkgname=unl0kr
pkgver=3.2.0
pkgrel=8
_commit_lvgl=ceadda8a468b7d5fa6ba973bd82cf610166278d8
pkgdesc="Framebuffer-based disk unlocker for the initramfs based on LVGL"
url="https://gitlab.postmarketos.org/postmarketOS/buffybox"
arch="all"
license="GPL-3.0-or-later"
depends="
	cryptsetup
	inih
	libdrm
	libinput-libs
	libxkbcommon
	"
makedepends="
	eudev-dev
	inih-dev
	libdrm-dev
	libinput-dev
	libxkbcommon-dev
	linux-headers
	meson
	scdoc
	"
source="
	https://gitlab.postmarketos.org/postmarketOS/buffybox/-/archive/$pkgver/buffybox-$pkgver.tar.gz
	lvgl-$_commit_lvgl.tar.gz::https://github.com/lvgl/lvgl/archive/$_commit_lvgl.tar.gz
	unl0kr.conf
	unl0kr.files
	unlock.sh
	10-fb-force-refresh.conf
	"
options="!check" # No tests
# "providing" osk-sdl, since it was dropped from pmaports
provides="postmarketos-fde-unlocker osk-sdl=$pkgver-r$pkgrel"
provider_priority=1000
subpackages="$pkgname-doc $pkgname-fbforcerefresh"
builddir="$srcdir/buffybox-$pkgver/unl0kr"

prepare() {
	default_prepare
	mkdir -p ../lvgl
	mv "$srcdir/lvgl-$_commit_lvgl"/* ../lvgl
}

build() {
	abuild-meson build
	meson compile ${JOBS:+-j ${JOBS}} -C build
}

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

	install -Dm644 "$srcdir"/unl0kr.conf -t "$pkgdir"/etc/

	install -Dm755 "$srcdir"/unlock.sh \
		"$pkgdir"/usr/bin/fde-unlock

	touch unl0kr
	install -Dm644 unl0kr \
		"$pkgdir"/usr/share/mkinitfs-triggers/unl0kr

	install -dm755 "$pkgdir"/etc/unl0kr.conf.d/

	install -Dm644 "$srcdir"/unl0kr.files \
		"$pkgdir"/usr/share/mkinitfs/files-extra/30-unl0kr.files
}

fbforcerefresh() {
	pkgdesc="$pkgdesc (force refresh quirk)"

	install -Dm644 "$srcdir"/10-fb-force-refresh.conf \
		-t "$subpkgdir"/etc/unl0kr.conf.d/
}

sha512sums="
83d6724750e6f7e048063863e78251d32a23b1c7aa9e3529a0b176c415bda70c91b83924f6a71cc7f5ca29f019e7a974b406f6e83ff038dae92430b53183d5fa  buffybox-3.2.0.tar.gz
d3611fe9d55ed105d9567b6019dc49fc0510ac4ed6ca6e15ba0c1bae47f2833d8784b3e008a4dec76dce55bf3809531d07c62e4ba24bafad69c6c54fdd0b70c0  lvgl-ceadda8a468b7d5fa6ba973bd82cf610166278d8.tar.gz
7155c2f95dcf3716c0f392cf5717e96f1414c383a1f7c2ed30a1f8518dfe0b17c3c0e0e93f6476a342504aa855404099e2f5444eeb099023491c9a9a26fa3d90  unl0kr.conf
b57260da131a4f40a0a3ee045e8394d4ab79caede9926d77f241afe79c1813fa77f4e312fa3b5e2e5c9fc1b9af082e7c59717abdaf30d512a7eb838a5f623ef8  unl0kr.files
5386f434cd4f1fb9e0d561a8689e5e85d6a8b3c562823122c082d4932d2fb0ad4edcd635f14f0c61e5c8b5e53648c9937b042409c21683007700faea8894c750  unlock.sh
f700af3145b79d1ef9edfb22982899b25cabfb212f9620dcbd3a2e6f44b5ad591e0a66056c6fcd66c3fde89a2b5f551e8a8fe2e65cf0e2a48adec57c027d7825  10-fb-force-refresh.conf
"
