pkgbase=libssh
pkgname=('libssh' 'libssh-devel')
pkgver=0.11.3
pkgrel=1
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
msys2_repository_url="https://git.libssh.org/projects/libssh.git"
msys2_references=(
  "cpe: cpe:/a:libssh:libssh"
)
license=('spdx:LGPL-2.1+')
arch=('i686' 'x86_64')
depends=('zlib' 'libopenssl')
makedepends=('cmake' 'python' 'openssl-devel' 'gcc' 'zlib-devel' 'ninja')
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc})
sha256sums=('7d8a1361bb094ec3f511964e78a5a4dba689b5986e112afabe4f4d0d6c6125c3'
            'SKIP')
validpgpkeys=('8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D'  # Andreas Schneider <asn@cryptomilk.org>
              '88A228D89B07C2C77D0C780903D5DF8CFDD3E8E7') # libssh release key (release key) <libssh@libssh.org>

build() {
  mkdir -p build && cd build

  cmake -GNinja ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_GSSAPI=OFF \
    -DUNIT_TESTING=OFF

  cmake --build .
  DESTDIR="$srcdir/dest" cmake --install .
}

package_libssh() {
  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin/* $pkgdir/usr/bin/
}

package_libssh-devel() {
  mkdir -p $pkgdir/usr/include
  cp -rf $srcdir/dest/usr/include/* $pkgdir/usr/include/

  mkdir -p $pkgdir/usr/lib
  cp -rf $srcdir/dest/usr/lib/* $pkgdir/usr/lib/
}
