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

pkgname=hopenpgp-tools
pkgver=0.23.7
pkgrel=308
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-prettyprinter-convert-ansi-wl-pprint'
         'haskell-resourcet' 'haskell-time-locale-compat' 'haskell-unordered-containers'
         'haskell-vector' 'haskell-yaml')
makedepends=('uusi' 'alex' 'happy' 'ghc')
source=(https://hackage.haskell.org/packages/archive/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('6710829a097050615a981a903537e08bff5aee7b1e6f3222cf033d953ba08193da3cd7bd2c4aad2afabd9831fe6313135d3efb95742a15826a59a46f77601a0d')

prepare() {
    cd "${srcdir}/${pkgname}-${pkgver}"
    # https://salsa.debian.org/clint/hopenpgp-tools/-/issues/6#note_435444
    rm -r dist
    uusi -r cryptonite:crypton
}

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

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

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"
}
