# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=pinentry
pkgver=1.1.1
pkgrel=1
pkgdesc='A collection of simple PIN or passphrase entry dialogs which utilize the Assuan protocol'
url='https://gnupg.org/related_software/pinentry/'
license=('GPL')
arch=('i686' 'x86_64')
makedepends=('ncurses-devel' 'libassuan-devel' 'libgpg-error-devel')
depends=('ncurses' 'libassuan' 'libgpg-error')
source=(https://gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2{,.sig}
        pinentry-0.9.1-msysize.patch
        1.1.0-w32.patch
        1.0.0-libiconv.patch)
sha256sums=('cd12a064013ed18e2ee8475e669b9f58db1b225a0144debdb85a68cecddba57f'
            'SKIP'
            '346cf3d9245c87151fd6e3dd88c9f5d4cb47a627cb36cab2d0d993338a0e5a75'
            '0222e625b39f2acd75e718d65ee4eb86f90766cd36e26b9460676766738bc93d'
            '7723a10cfc9f8a711b118ad9bd06e96c2acb9860f91b635b1253588c2a42811c')
validpgpkeys=('D8692123C4065DEA5E0F3AB5249B39D24F25E3B6' # Werner Koch (dist sig)
              '6DAA6E64A76D2840571B4902528897B826403ADA') # Werner Koch (dist signing 2020)

install=${pkgname}.install

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/pinentry-0.9.1-msysize.patch
  patch -p1 -i ${srcdir}/1.1.0-w32.patch
  patch -p2 -i ${srcdir}/1.0.0-libiconv.patch
  ./autogen.sh
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --disable-pinentry-tty \
    --disable-fallback-curses \
    --disable-pinentry-curses \
    --disable-pinentry-gtk2 \
    --disable-pinentry-qt \
    --disable-libsecret \
    --without-libcap

  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
