# Template file for 'qutebrowser'
pkgname=qutebrowser
version=3.4.0
revision=1
build_style=python3-module
hostmakedepends="python3-setuptools asciidoc"
depends="python3-Jinja2 python3-yaml"
short_desc="Keyboard-focused browser with a minimal GUI"
maintainer="Daniel Eyßer <daniel.eysser@gmail.com>"
license="GPL-3.0-or-later"
homepage="https://qutebrowser.org/"
changelog="https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/changelog.asciidoc"
distfiles="https://github.com/qutebrowser/qutebrowser/releases/download/v${version}/qutebrowser-${version}.tar.gz"
checksum=814124c0ed337430e613a1da366d5e38904cb2049afb1505971456ca5ca6223e
nostrip=yes
# testing requires unpackaged plugins:
# pytest-bdd, pytest-benchmark, pytest-instafail, pytest-rerunfailures
make_check=no

build_options="qt6 webkit"
desc_option_qt6="Use Qt6 GUI and WebEngine backend"
desc_option_webkit="Use Qt5 WebKit backend"

vopt_conflict qt6 webkit

# WebEngine is unavailable on BE systems or when host & target word sizes differ
if [ "$XBPS_TARGET_ENDIAN" != "le" ]; then
	build_options_default="webkit"
elif [ "$XBPS_WORDSIZE" != "$XBPS_TARGET_WORDSIZE" ]; then
	build_options_default="webkit"
elif [ "$XBPS_WORDSIZE" != 32 ]; then
	# qt6-webengine is broken on 32-bit systems
	build_options_default="qt6"
fi

if [ "$build_option_qt6" ]; then
	depends+=" python3-pyqt6-declarative python3-pyqt6-gui python3-pyqt6-pdf
	 python3-pyqt6-sql python3-pyqt6-webengine python3-pyqt6-webchannel
	 python3-pyqt6-widgets python3-pyqt6-network python3-pyqt6-dbus
	 python3-pyqt6-printsupport qt6-plugin-sqlite"
else
	depends+=" python3-PyQt5-quick python3-PyQt5-opengl
	 python3-PyQt5-sql qt5-plugin-sqlite
	 $(vopt_if webkit python3-PyQt5-webkit python3-PyQt5-webengine)"
fi

pre_build() {
	a2x -f manpage doc/qutebrowser.1.asciidoc
}

post_install() {
	vman doc/qutebrowser.1
	vinstall misc/org.qutebrowser.qutebrowser.desktop 644 usr/share/applications

	vmkdir usr/share/qutebrowser
	vcopy misc/userscripts usr/share/qutebrowser
	vcopy scripts usr/share/qutebrowser

	local dim
	for dim in 16 24 32 48 64 96 128 256 512; do
		vinstall qutebrowser/icons/qutebrowser-${dim}x${dim}.png 644 \
			usr/share/icons/hicolor/${dim}x${dim}/apps qutebrowser.png
	done

	vinstall qutebrowser/icons/qutebrowser.svg 644 \
		usr/share/icons/hicolor/scalable/apps qutebrowser.svg
}
