# Maintainer:  Christian Hesse <mail@eworm.de>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: kfgz <kfgz at interia dot pl>
# Contributor: pootzko <pootzko at gmail dot com>

pkgname=haveged
pkgver=1.9.14
pkgrel=2
pkgdesc='Entropy harvesting daemon using CPU timings'
arch=('x86_64')
url='https://github.com/jirka-h/haveged'
license=('GPL')
depends=('glibc')
validpgpkeys=('8F6B7293B03E5AC5762B65CE2E2F252B05CCA168') # Jirka Hladky <hladky.jiri@gmail.com>
source=("$pkgname-$pkgver.tar.gz::https://github.com/jirka-h/$pkgname/archive/v$pkgver.tar.gz"
        '0001-Updated-systemd-service-files-to-not-start-haveged-s.patch')
        #"https://github.com/jirka-h/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz.asc"
sha256sums=('938cb494bcad7e4f24e61eb50fab4aa0acbc3240c80f3ad5c6cf7e6e922618c3'
            'cc2122a7c954bcd2fb856799abf01730d9c58a5e70065a4f66ae838a6b3beac5')

prepare() {
  cd $pkgname-$pkgver

  sed -i 's/@SBIN_DIR@/\/usr\/bin/' contrib/Fedora/haveged.service

  patch -Np1 < ../0001-Updated-systemd-service-files-to-not-start-haveged-s.patch
}

build() {
  cd $pkgname-$pkgver

  ./configure \
      --prefix=/usr \
      --bindir=/usr/bin \
      --sbindir=/usr/bin
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" install

  install -D -m0644 contrib/Fedora/haveged.service "$pkgdir"/usr/lib/systemd/system/haveged.service
}
