# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

pkgname=hopenpgp-tools
pkgver=0.23.11
pkgrel=28
pkgdesc="hOpenPGP-based command-line tools"
url="https://salsa.debian.org/clint/hopenpgp-tools"
license=("AGPL3")
arch=('x86_64')
depends=('ghc-libs' 'haskell-aeson' 'haskell-base16-bytestring' 'haskell-binary-conduit'
         'haskell-conduit' 'haskell-conduit-extra' 'haskell-crypton' 'haskell-errors'
         'haskell-fgl' 'haskell-graphviz' 'haskell-hopenpgp' 'haskell-http-client'
         'haskell-http-client-tls' 'haskell-http-types' 'haskell-ixset-typed' 'haskell-lens'
         'haskell-memory' 'haskell-monad-loops' 'haskell-openpgp-asciiarmor'
         'haskell-optparse-applicative' 'haskell-prettyprinter'
         'haskell-prettyprinter-ansi-terminal' 'haskell-resourcet' 'haskell-time-locale-compat'
         'haskell-unordered-containers' 'haskell-vector' 'haskell-yaml')
makedepends=('alex' 'happy' 'ghc')
source=(https://hackage.haskell.org/packages/archive/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('ea4292818b8422680425f21d0f1955e4e01960b6eb7c53a51b41fa8853a59c503fff3e48888700288641dca187adb3f2eaf6af93b8d6fc4c3a2b69cd7ac463f3')

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

    runhaskell Setup configure -O --enable-executable-dynamic --prefix=/usr \
        --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
}

check() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    runhaskell Setup test --show-details=direct
}

package() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    runhaskell Setup copy --destdir="${pkgdir}"

    rm "$pkgdir/usr/share/doc/hopenpgp-tools/LICENSE"
    rmdir "$pkgdir/usr/share/doc/hopenpgp-tools" "$pkgdir/usr/share/doc" "$pkgdir/usr/share"
}
