# Maintainer: Chih-Hsuan Yen <base64_decode("eXUzYWN0eHQydHR0ZmlteEBjaHllbi5jYwo=")>
# Contributor: Daniel Landau <daniel@landau.fi>
# Contributor: Maxqia <contrib@maxqia.com>

# The following people have contributed to keepassx-git package
# Contributor: Lev Lybin <aur@devtrue.net>
# Contributor: Jamie Macdonald <jamie.alban@gmail.com>
# Contributor: Alucryd <alucryd at gmail dot com>
# Contributor: Paolo Stivanin <admin at polslinux dot it>

pkgname=keepassxc-git
_gitname=keepassxc
pkgver=2.7.1.r657.g7c7ca4575
pkgrel=1
pkgdesc="Cross-platform community-driven port of KeePass Password Safe"
arch=('i686' 'x86_64')
url="https://github.com/keepassxreboot/keepassxc"
license=('GPL2')
depends=('qt6-base' 'qt6-translations' 'qt6-imageformats'
  'libxtst' 'shared-mime-info' 'hicolor-icon-theme' 'desktop-file-utils'
  'libusb' 'pcsclite' 'qt6-svg' 'qrencode' 'minizip'
  'zlib' 'botan' 'argon2')
makedepends=('git' 'intltool' 'cmake' 'qt6-tools' 'asciidoctor')
checkdepends=('xorg-server-xvfb' 'xclip')
provides=('org.freedesktop.secrets' "keepassxc=$pkgver")
conflicts=('keepassxc')
replaces=('keepassx-http' 'keepassx-reboot-git')
options=(!emptydirs)
source=(git+https://github.com/keepassxreboot/keepassxc.git#branch=develop)
md5sums=('SKIP')

pkgver() {
  cd "${_gitname}"
  git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "${_gitname}"
  cmake -B build \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_BINDIR=/usr/bin \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DCMAKE_VERBOSE_MAKEFILE=OFF \
    -DWITH_GUI_TESTS=ON \
    -DWITH_XC_ALL=ON \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo
  make -C build
}

#check() {
#    cd "${_gitname}/build"
#    xvfb-run --auto-display make test
#}

package() {
  cd "${_gitname}/build"
  make DESTDIR="${pkgdir}" install
}
