# Maintainer: Sébastien Luttringer
# Contributor: Andrea Zucchelli <zukka77@gmail.com>

pkgname=keepalived
pkgver=2.3.4
pkgrel=1
pkgdesc='Failover and monitoring daemon for LVS clusters'
arch=('x86_64')
url='https://www.keepalived.org/'
license=('GPL2')
backup=('etc/keepalived/keepalived.conf'
        'etc/sysconfig/keepalived')
makedepends=('ipset')
depends=('glibc' 'libnl' 'openssl' 'file' 'iptables' 'systemd-libs')
optdepends=('ipset: ipset support')
makedepends=('libnfnetlink' 'ipset' 'systemd')
options=('!emptydirs')
source=("https://www.keepalived.org/software/$pkgname-$pkgver.tar.gz")
sha256sums=('6afd95ddb7d3e0d3b8b8e5b3a489144131b61a01b06d29e883d0c44acc8a36bf')

build() {
  # trick broken ./configure systemctl test
  printf "#!/bin/sh\necho -.mount\n" > systemctl
  chmod +x systemctl
  PATH=$PWD:$PATH

  cd "${pkgname}-${pkgver}"

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --sbindir=/usr/bin \
    --localstatedir=/var \
    --runstatedir=/run \
    --enable-json
  make
}

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

  make DESTDIR="${pkgdir}" install

  # move conf file to correct name
  mv "${pkgdir}"/etc/keepalived/keepalived.conf{.sample,}

  # move examples to /usr/share
  install -d -m 0755 "${pkgdir}/usr/share/${pkgname}"
  mv "${pkgdir}/etc/keepalived/samples" "${pkgdir}/usr/share/$pkgname/samples"
}

# vim:set ts=2 sw=2 et:
