# Contributor: Max Rees <maxcrees@me.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=physlock
pkgver=13_git20200116
_gitrev=4fbacee834abef613d7f4bd37d52a9f5fe269c82
pkgrel=3
pkgdesc="Lightweight linux console locking tool"
url="https://github.com/muennich/physlock"
arch="all"
license="GPL-2.0-or-later"
makedepends="elogind-dev linux-headers linux-pam-dev"
subpackages="$pkgname-doc $pkgname-elogind"
source="https://github.com/muennich/physlock/archive/$_gitrev/$pkgname-$_gitrev.tar.gz
	physlock.pam
	"
builddir="$srcdir/$pkgname-$_gitrev"
options="!check suid" # No test suite

prepare() {
	default_prepare
	cp -r "$builddir" "$builddir-elogind"
}

build() {
	make HAVE_SYSTEMD=0 HAVE_ELOGIND=0

	cd "$builddir-elogind"
	make HAVE_SYSTEMD=0 HAVE_ELOGIND=1
}

package() {
	make install HAVE_SYSTEMD=0 HAVE_ELOGIND=0 PREFIX="/usr" DESTDIR="$pkgdir"

	install -D -m644 "$srcdir"/physlock.pam "$pkgdir"/etc/pam.d/physlock
}

elogind() {
	pkgdesc="$pkgdesc (with elogind support)"
	replaces="$pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel elogind"

	cd "$builddir-elogind"

	make install HAVE_SYSTEMD=0 HAVE_ELOGIND=1 PREFIX="/usr" DESTDIR="$subpkgdir"
	rm -Rf "$subpkgdir"/usr/share

	install -D -m644 "$srcdir"/physlock.pam "$subpkgdir"/etc/pam.d/physlock
}

sha512sums="
9d18a05f86c58100c050d086215709e7d4d9aeecd15c8e5af404d11950cde664a7bc8c19a746057bc7f8f40a74db4cb66e58a2084666f2cc720b0db488b9817a  physlock-4fbacee834abef613d7f4bd37d52a9f5fe269c82.tar.gz
30e4673a507f859114f99a2ad6b6ce7c719c7deb6d8028d5c9f57bfafc1e611fadb3296f172f448b9936129fcc282f1edba2304ebcbf8b8b78c5190ba16225c3  physlock.pam
"
