# Maintainer: bill-auger <bill-auger@programmer.net>


pkgname=beanstalkd
pkgver=1.11
pkgrel=1
pkgdesc="simple, fast work-queue server"
arch=('armv7h' 'i686' 'x86_64')
url=https://beanstalkd.github.io/
license=('MIT')

source=($pkgname-$pkgver::https://github.com/beanstalkd/beanstalkd/archive/v${pkgver}.tar.gz
        beanstalkd@.service
        beanstalkd.service
        fix-warnings.patch)
sha256sums=('5e3414e49d00e9ef9530897983e56bdba98da6f8f1f30f5fe7e6064b2f68c544'
            '57004d06ed38973e4bba47c92d1461e77e58027818c1899352ace95fb400f937'
            '9ea87a132244a7b32a2a59ff55d4f809cb109d9021e00014b18fe9883d96b6b6'
            'fcb9eaba50bd2bc78e8be9fc05a99501fa38bbe35e7e4568cf8363afe0ee4ac4')


prepare()
{
  cd "$srcdir"/$pkgname-$pkgver

  # https://github.com/beanstalkd/beanstalkd/pull/575
  patch -p1 < "$srcdir"/fix-warnings.patch
}

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

  make CFLAGS="${CFLAGS}"
}

check()
{
  cd "$srcdir"/$pkgname-$pkgver

  # check requires network
#   make check
}

package()
{
  cd "$srcdir"/$pkgname-$pkgver

  make DESTDIR="$pkgdir"/ PREFIX=/usr install

  install -Dm644 "${srcdir}"/beanstalkd.service  "${pkgdir}"/usr/lib/systemd/system/beanstalkd.service
  install -Dm644 "${srcdir}"/beanstalkd@.service "${pkgdir}"/usr/lib/systemd/system/beanstalkd@.service
  install -Dm644 adm/systemd/beanstalkd.socket   "${pkgdir}"/usr/lib/systemd/system/beanstalkd.socket
  install -Dm644 doc/beanstalkd.1                "${pkgdir}"/usr/share/man/man1/beanstalkd.1
}
