# Maintainer: Giancarlo Razzolinit <grazzolini@gmail.com>

_name=keeagent
pkgname=keepass-plugin-keeagent
pkgver=0.12.1
_commit=9e3fefc014889c572e34659ad26619080b5b2443  # refs/tags/0.12.1
pkgrel=4
pkgdesc="SSH Agent Plugin for KeePass"
arch=('any')
url="https://lechnology.com/software/keeagent/"
license=('GPL2' 'BSD' 'MIT' 'custom:MS-LPL' 'custom:WindowsAPICodePack')
makedepends=('git' 'msbuild' 'nuget')
depends=('keepass')
optdepends=(
  'openssh: For integration with ssh-agent'
  'gnupg: For integration with GnuPG SSH agent'
)
source=(
  git+https://github.com/dlech/$_name#tag=$_commit
  git+https://github.com/dlech/sshagentlib
  git+https://github.com/CodesInChaos/chaos.nacl
)
sha512sums=('SKIP'
            'SKIP'
            'SKIP')

prepare() {
  cd $_name
  git submodule init
  git config submodule.SshAgentLib.url "$srcdir/sshagentlib"
  (
    cd SshAgentLib
    git submodule init
    git config submodule."Chaos.NaCl".url "$srcdir/chaos.nacl"
    git -c protocol.file.allow=always submodule update
  )
  git -c protocol.file.allow=always submodule update

  nuget restore
}

build() {
  cd $_name

  msbuild /property:Configuration=ReleasePlgx KeeAgent.sln
}

package() {
  cd $_name
  install -Dm644 KeeAgent/bin/ReleasePlgx/KeeAgent.plgx -t "$pkgdir/usr/share/keepass/plugins/"
  install -vDm 644 SshAgentLib/License.* -t "$pkgdir/usr/share/licenses/$pkgname/"
}
