# Maintainer (Parabola:~lukeshu): Luke T. Shumaker <lukeshu@parabola.nu>
# Maintainer (Arch:community): Lukas Fleischer <lfleischer@archlinux.org>
# Contributor (Arch:community): Loui Chang <louipc dot ist at gmail company>
# Contributor (Arch:community): Jeff Mickey <j@codemac.net>
# Contributor (Arch:community): Aaron Griffin <aaron@archlinux.org>

# Forked from community.git 4e6eff0c3f06^ (Drop orphan package, 2020-05-01)

pkgname=esmtp
pkgver=1.2.r7.gdb201bd
pkgrel=1
pkgdesc="An easy SMTP forwarder."
arch=('x86_64')
url='http://esmtp.sourceforge.net'
license=('GPL-2.0-or-later')
depends=('libesmtp' 'openssl')
optdepends=('liblockfile: for esmtp-wrapper script'
            'procmail: for local mail delivery')
provides=('smtp-forwarder')
conflicts=('smtp-forwarder')
source=("https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.bz2")

conflicts+=(esmtp-lukeshu)
replaces+=(esmtp-lukeshu)
depends+=(git python)
source=("git+https://git.lukeshu.com/esmtp/#commit=db201bdc5e8e14f72fec33fd5dae291ef5b6fc79")
sha256sums=('1a5d506c800f08d88ee4e9a9dfe6576a5879f70666bc6db6810d376eb54a3367')

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

  git describe --tags | sed -E -e 's/^v//' -e 's/-([0-9]+)-g/.r\1.g/'
}

prepare() {
  cd "${srcdir}/${pkgname}"

  ./autogen.sh
}

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

  ./configure --prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin
  make
}

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

  make DESTDIR="${pkgdir}" install

  install -Dm0644 README "${pkgdir}/usr/share/doc/esmtp/README"
  install -Dm0644 sample.esmtprc "${pkgdir}/usr/share/doc/esmtp/sample.esmtprc"
  install -Dm0755 esmtp-wrapper "${pkgdir}/usr/share/esmtp/esmtp-wrapper"
}
