# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>

pkgname=shairport-sync
pkgver=3.3.8
pkgrel=1
pkgdesc='Emulates an AirPort Express for the purpose of streaming music from iTunes and compatible iPods and iPhones'
url='https://github.com/mikebrady/shairport-sync'
arch=(x86_64)
license=(GPL)
backup=(etc/shairport-sync.conf)
depends=(openssl avahi libsoxr popt alsa-lib libconfig libpulse jack mosquitto)
makedepends=(xmltoman)
source=(shairport-sync-$pkgver.zip::https://github.com/mikebrady/shairport-sync/archive/$pkgver.zip
        shairport-sync.sysusers
        remove_useradd.patch)
sha1sums=('027b823d959b810ac8a301b297b0364581fbc73c'
          'b806f9cd3eeaf8585a51d79c7b5681e3d3e4748a'
          '2cdd711a21a74748137d2e3894fb0fcb189c41e2')

prepare() {
  cd shairport-sync-$pkgver

  patch -p1 < ../remove_useradd.patch
}

build() {
  cd shairport-sync-$pkgver

  autoreconf -i -f
  ./configure --prefix=/usr --sysconfdir=/etc --with-alsa --with-pa --with-avahi --with-jack --with-stdout --with-pipe --with-ssl=openssl --with-soxr --with-dns_sd --with-pkg-config --with-systemd --with-configfiles --with-metadata --with-mqtt-client
  make

  sed 's|/usr/local/bin/|/usr/bin/|' -i scripts/shairport-sync.service
}

package() {
  cd shairport-sync-$pkgver
  make DESTDIR="$pkgdir" install
  install -D -m644 "$srcdir"/shairport-sync.sysusers "$pkgdir"/usr/lib/sysusers.d/shairport-sync.conf
  install -D -m664 LICENSES "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  rm "$pkgdir"/etc/shairport-sync.conf.sample
}
