#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=mpd
pkgver=0.23.12
pkgrel=03
pkgdesc="Flexible, powerful, server-side application for playing music w/o systemd"
url="https://www.musicpd.org/"
depends=(bzip2 chromaprint gcc-libs glibc lame libcdio libcdio-paranoia
libgcrypt libgme libmad libmms libmodplug libmpcdec libnfs libshout
libsidplayfp libsoxr openal opus sqlite wavpack wildmidi zlib
zziplib)
#  smbclient # disabled because of https://bugzilla.samba.org/show_bug.cgi?id=11413
makedepends=(alsa-lib audiofile avahi boost curl dbus expat faad2 ffmpeg flac
fluidsynth fmt icu jack libao libid3tag libmikmod libmpdclient libogg
libopenmpt libpulse libsamplerate libsndfile libupnp liburing libvorbis meson
mpg123 libpipewire python-sphinx twolame yajl)
backup=(etc/$pkgname.conf)
# options=(debug)  ## uncomment this to produce the debug pkg
source=(
  https://www.musicpd.org/download/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.xz{,.sig}
  $pkgname.conf
  $pkgname.sysusers
  $pkgname.tmpfiles
#  $pkgname.service.override
)

build() {
  local _meson_options=(
    -D documentation=enabled
    -D adplug=disabled
    -D sndio=disabled
    -D shine=disabled
    -D tremor=disabled
    -D systemd=disabled
    -D b_ndebug=true

  )

  # NOTE: sndio conflicts with alsa
  # TODO: package adplug
  # TODO: package shine
  arch-meson "${_meson_options[@]}" build $pkgname-$pkgver
  ninja -C build
}

check() {
  ninja -C build test
}

package() {
  depends+=(libbz2.so libFLAC.so libao.so libasound.so libaudiofile.so
  libavahi-client.so libavahi-common.so libavcodec.so libavformat.so
  libavutil.so libcurl.so libdbus-1.so libexpat.so libfaad.so libfluidsynth.so
  libfmt.so libicui18n.so libicuuc.so libid3tag.so libjack.so libmikmod.so
  libmpdclient.so libmpg123.so libogg.so libopenmpt.so libpipewire-0.3.so
  libpulse.so libsamplerate.so libsndfile.so libtwolame.so
  libupnp.so liburing.so libvorbis.so libvorbisenc.so libyajl.so libavfilter.so
  libchromaprint.so libixml.so)

  DESTDIR="$pkgdir" ninja -C build install
  install -vDm 644 $pkgname-$pkgver/doc/${pkgname}conf.example -t "$pkgdir/usr/share/doc/$pkgname/"
#  install -vDm 644 $pkgname.service.override "$pkgdir/usr/lib/systemd/system/mpd.service.d/00-arch.conf"
  install -vDm 644 $pkgname.conf -t "$pkgdir/etc/"
  install -vDm 644 $pkgname.sysusers "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
  install -vDm 644 $pkgname.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(GPL2)

validpgpkeys=('0392335A78083894A4301C43236E8A58C6DB4512') # Max Kellermann <max@blarg.de>

sha256sums=(b7fca62284ecc25a681ea6a07abc49200af5353be42cb5a31e3173be9d8702e7  # mpd-0.23.12.tar.xz
	e83b201df59ac89d3f0ab717350906787265dba087d5056873c523102d8411ff  # mpd-0.23.12.tar.xz.sig
	f40f68205834ca53cea3372e930bfe6c2f9ecc9df3b1605df2fec63a658b2e03  # mpd.conf
	0b74c6e5db08daab3091dc15a6b0c75210ba2f9e98fa074f6cfd605a461056b6  # mpd.sysusers
	2faa85c12449a5b3ca422ff1c1fa06d057c7e262a74bfa6298c914a92d6f2e7a) # mpd.tmpfiles

##  33e7a3f8be8a3b9917d3bb4fad1278e4f1e30aa68aca3a6a4bdb2d399f8ca7f2  mpd-0.23.12-03-x86_64.pkg.tar.lz


