SUMMARY="Qt password manager"
DESCRIPTION="KeePassXC is an application for people with extremly high \
demands on secure personal data management. It has a light interface, is \
cross platform and published under the terms of the GNU General Public License.
KeePassXC saves many different information e.g. user names, passwords, urls, \
attachments and comments in one single database. For a better management \
user-defined titles and icons can be specified for each single entry. \
Furthermore the entries are sorted in groups, which are customizable as well. \
The integrated search function allows to search in a single group or the \
complete database.
KeePassXC offers a little utility for secure password generation. The \
password generator is very customizable, fast and easy to use. Especially \
someone who generates passwords frequently will appreciate this feature.
KeePassXC is a community fork of KeePassX which aims to incorporate stalled \
pull requests, features, and bug fixes that have never made it into the main \
KeePassX repository."
HOMEPAGE="https://keepassxc.org/"
COPYRIGHT="
	2010-2012, Felix Geyer
	2011-2012, Florian Geyer
	2012, Tobias Tangemann
	2007, Trolltech ASA
	2012, Intel Corporation
	2012, Nokia Corporation and/or its subsidiary(-ies)
	2000-2008, Tom Sato
	2013, Laszlo Papp
	2013, David Faure
	2016-2020, KeePassXC Team
	"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/keepassxreboot/keepassxc/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="9387caeadabb5e66190f1ccae4eb26887ba872125620e22bba8c79615349cf81"
PATCHES="keepassxc-$portVersion.patchset"
ADDITIONAL_FILES="
	keepassxc.rdef.in
	icons.zip
	"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	keepassxc$secondaryArchSuffix = $portVersion
	cmd:keepassxc_cli
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libargon2$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix
	lib:libmicrohttpd$secondaryArchSuffix
	lib:libqrencode$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libsodium$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Test$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libquazip5$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libargon2$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libgpg_error$secondaryArchSuffix
	devel:libmicrohttpd$secondaryArchSuffix
	devel:libqrencode$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix >= 8
	devel:libsodium$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Test$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libquazip5$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	cmd:zip
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/icons.zip -d $sourceDir/share/icons
}

BUILD()
{
	mkdir -p build ; cd build

	cmake .. -DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_INSTALL_DATAROOTDIR=$dataDir \
		-DKEEPASSXC_BUILD_TYPE=Release \
		-DCMAKE_BUILD_TYPE=Release \
		-DWITH_XC_NETWORKING=on \
		-DWITH_XC_SSHAGENT=on \
		-DWITH_XC_KEESHARE=on \
		-DWITH_XC_AUTOTYPE=on \
		-DWITH_XC_DOCS=off \
		-DWITH_XC_UPDATECHECK=off \
		-DWITH_TESTS=on \
		-DCMAKE_CXX_FLAGS="-D_GNU_SOURCE"

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $appsDir
	mv $prefix/bin/keepassxc $appsDir/KeePassXC

	local APP_SIGNATURE="application/x-vnd.qt5-keepassxc"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/keepassxc.rdef.in > keepassxc.rdef

	addResourcesToBinaries keepassxc.rdef $appsDir/KeePassXC
	addAppDeskbarSymlink $appsDir/KeePassXC
}

TEST()
{
	cd build
	make test
}
