# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Amish <contact at via dot aur>
# Contributor: Victor3D <webmaster@victor3d.com.br>

pkgname=fetchmail
pkgver=6.6.5
pkgrel=1
pkgdesc='A remote-mail retrieval utility'
arch=('x86_64')
url='https://www.fetchmail.info'
license=('GPL')
depends=(
  openssl
)
makedepends=(
  asciidoc
  git
  htmldoc
  meson
  pandoc
  python
  python-docutils
)
optdepends=(
  'tk: for using fetchmailconf'
)
source=(
  "git+https://gitlab.com/fetchmail/fetchmail.git?tag=${pkgver}"
  fetchmail.tmpfiles
  fetchmail.sysusers
  fetchmail@.service
  fetchmail.service
)
b2sums=('SKIP'
        'b4ffb99efe4ab24a5a9ed3a27ad5a4645ef8611d66ca380e6acd36e81b34d2619142d62854fa7bd7716b8013d3ccf75ea3e1e18151ae95ff6c37c839631a5733'
        '0f413bcc148ce342036d780d321cd6303928903f22f819a9920ab5ec66304241f4ed340338042e625dc7c03b845e35b9c06aac566b46d64dfe614af3a9cdb2dc'
        'b8740cab8a59cc6c3082973e60d3eb262e3a76aa2b0517336d8f95fd4214a5ccbb2e292301d9112ede0747335f7f8d2815eb38b958085f702c01be30aa107f72'
        'a86822f27f5f4c7b97f24baebcd383b5cc2a4fa7810226139e2c588368637417dbfa52f884a8fcc04b904fc1ac865189feb2070a215a8abf9c0192584c2dbbef')

build() {
  local meson_options=(
    -D tls_library=openssl
  )

  arch-meson ${pkgname} build "${meson_options[@]}"
  meson compile -C build
}

package() {
  install -D -m644 fetchmail.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/fetchmail.conf
  install -D -m644 fetchmail.sysusers "${pkgdir}"/usr/lib/sysusers.d/fetchmail.conf
  install -D -m644 fetchmail.service "${pkgdir}"/usr/lib/systemd/system/fetchmail.service
  install -D -m644 fetchmail@.service "${pkgdir}"/usr/lib/systemd/system/fetchmail@.service

  meson install -C build --destdir "${pkgdir}"
}
