# Template file for 'pinentry-gtk'
# NOTE: keep this pkg synchronized with srcpkgs/pinentry.
# NOTE: it's splitted this way to avoid cyclic dependencies.
_desc="PIN or passphrase entry dialogs for GnuPG"

pkgname=pinentry-gtk
version=1.3.1
revision=1
build_style=gnu-configure
configure_args="--without-libcap --enable-fallback-curses
 --disable-pinentry-curses --disable-pinentry-tty
 --disable-pinentry-emacs --enable-pinentry-qt
 --enable-pinentry-gtk2 --enable-pinentry-gnome3
 $(vopt_enable libsecret)"
hostmakedepends="pkg-config qt6-base qt6-tools"
makedepends="ncurses-devel libassuan-devel libgpg-error-devel
 gcr-devel gtk+-devel qt6-base-devel $(vopt_if libsecret libsecret-devel)"
short_desc="${_desc} based on GTK+"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="GPL-2.0-or-later"
homepage="https://www.gnupg.org/related_software/pinentry/index.html"
distfiles="https://gnupg.org/ftp/gcrypt/pinentry/pinentry-${version}.tar.bz2"
checksum=bc72ee27c7239007ab1896c3c2fae53b076e2c9bd2483dc2769a16902bce8c04

alternatives="pinentry:pinentry:/usr/bin/pinentry-gtk-2"

build_options="libsecret"
build_options_default="libsecret"
desc_option_libsecret="Enable support for saving passwords via libsecret"

post_patch() {
	# else it tries to use the target libexecdir
	vsed -i -e 's:qt6libexecdir=.*:qt6libexecdir=/usr/lib/qt6/libexec:' configure
}

post_install() {
	rm -f ${DESTDIR}/usr/bin/pinentry
	rm -rf ${DESTDIR}/usr/share/info
}

pinentry-qt_package() {
	depends="pinentry>=${version}_${revision}"
	short_desc="${_desc} based on Qt"
	alternatives="pinentry:pinentry:/usr/bin/pinentry-qt"
	pkg_install() {
		vmove usr/bin/pinentry-qt
	}
}

pinentry-gnome_package() {
	depends="pinentry>=${version}_${revision}"
	short_desc="${_desc} for the GNOME desktop"
	alternatives="pinentry:pinentry:/usr/bin/pinentry-gnome3"
	pkg_install() {
		vmove usr/bin/pinentry-gnome3
	}
}