# Contributor: Adrian C. (anrxc) <anrxc..sysphere.org>
# Contributor: Jose Riha jose1711 gmail com
# Maintainer: Erich Eckner <arch at eckner dot net>

pkgname=topal
pkgver=81
pkgrel=1
pkgdesc='glue program that links GnuPG and Alpine'
arch=('i686' 'pentium4' 'x86_64')
url="https://zircon.org.uk/topal/rel-${pkgver}/"
license=("GPL3")
makedepends=("gcc-ada" "make" "lynx")
_pinned_dependencies=(
  'glibc>=2.35'
  'libreadline.so=8'
)
depends=("${_pinned_dependencies[@]}" procmail)
optdepends=("alpine: for which topal was mainly written for"
            "re-alpine: fork of alpine for which topal was mainly written for"
            "gnupg: to encrypt, decrypt, sign and verify e-mail"
            "metamail: to display and process MIME messages"
            "mime-support: its run-mailcap tool as alternative to metamail"
            "openssh: for remote and server mode of operation"
            "procmail: to use formail")
install="${pkgname}.install"
options=("!makeflags")
source=("https://zircon.org.uk/topal/rel-${pkgver}/topal-package-${pkgver}.tgz"{,.asc})
sha512sums=('732cebaf541ff388b20e07fbf22b28586da10ccf4f115bc66feb32a8f89d3a9922dc55a019d9a28bc700ccf4f90d02582e50560d050325bf790d7eb8c9ba2365'
            'SKIP')
validpgpkeys=('D312B4FF825FCA97472A558F9623D47747DC67A1') # Phil Brooke

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

# Remove PDF build stuff
  sed -i 's/binary topal.pdf/binary/' Makefile

# Build Topal and MIME-tool
  make distclean
  make
}

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

# Install Topal binary, manual page and documentation
  install -D -m755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -D -m644 "${pkgname}.man" "${pkgdir}/usr/share/man/man1/${pkgname}.1"
# Replaced by some PDF stuff which we will not build
  #install -D -m644 README.txt "${pkgdir}/usr/share/doc/${pkgname}/README"

# Install Topal's version of MIME-tool and manual page
  install -D -m755 MIME-tool/mime-tool "${pkgdir}/usr/bin/mime-tool"
  install -D -m644 MIME-tool/mime-tool.man "${pkgdir}/usr/share/man/man1/mime-tool.1"
}