# Maintainer: Florian Pritz <bluewind@xinu.at>
# Contributor: Christos Nouskas nous <nous at archlinux.us>

pkgname=smokeping
pkgver=2.6.9
pkgrel=2
pkgdesc="A tool to keep track of your network latency"
arch=('any')
url="http://oss.oetiker.ch/smokeping/"
license=('GPL2')
depends=('perl-config-grammar' 'perl-digest-hmac' 'perl-libwww' 'rrdtool' 'perl-fcgi')
source=(http://oss.oetiker.ch/smokeping/pub/smokeping-${pkgver}.tar.gz
        service
        htdocs-makefile.patch)
sha256sums=('cd551d4384d8b19879d128ea0566bd680c19bb4ad8664a3c5a304604746f8863'
            '312e9c7a9d4a2e56da823bcbfa39c4e38a66bbe1da365dae8d11774d9eb2ee28'
            'd044f421ea9b7fac147b9da69dd16c0e45bb534c500ebac6e011f1cfecc9bb8f')
install=install

prepare() {
  cd "$srcdir"/${pkgname}-${pkgver}
	sed -i 's#the master/slave mode|smokeping_master_slave#the masterE<sol>slave mode|smokeping_master_slave#' \
		lib/Smokeping.pm
	patch -p1 -i "$srcdir/htdocs-makefile.patch"
}

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

  ./configure --prefix=/usr --sysconfdir=/etc/smokeping --with-htdocs-dir=/srv/http/smokeping
  make
}

package() {
  cd "$srcdir"/${pkgname}-${pkgver}
  make DESTDIR="$pkgdir" install

  install -Dm644 "$srcdir/service" "$pkgdir/usr/lib/systemd/system/smokeping.service"
  chmod 700 "$pkgdir/etc/smokeping"
}

