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

#pkgbase=dbus
pkgname=(dbus) # dbus-docs)
pkgver=1.14.8
pkgrel=01
pkgdesc="unFreedesktop.org message bus system w/o systemd"
url="https://wiki.freedesktop.org/www/Software/dbus/"
depends=(expat audit)
makedepends=(xmlto docbook-xsl python yelp-tools doxygen git autoconf-archive automake)
makedepends=(autoconf-archive docbook-xsl doxygen git python xmlto yelp-tools)
#options=(debug)  ##  uncomment this to have the dbus-debug pkg produced
source=("git+https://gitlab.freedesktop.org/dbus/dbus.git?signed#tag=dbus-$pkgver"
	dbus.sysusers
	dbus.tmpfiles)

prepare() {
  cd $pkgname

  # Allow us to enable checks without them being fatal
#  patch -Np2 -i ../no-fatal-warnings.patch
#  git apply -3 ../no-fatal-warnings.diff

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib/dbus-1.0 \
    --runstatedir=/run \
    --with-console-auth-dir=/run/console/ \
    --with-dbus-user=dbus \
    --with-system-pid-file=/run/dbus/pid \
    --with-system-socket=/run/dbus/system_bus_socket \
    --with-systemdsystemunitdir=no \
    --enable-inotify \
    --enable-libaudit \
    --disable-systemd \
    --disable-user-session \
    --disable-xml-docs \
    --disable-doxygen-docs \
    --disable-ducktype-docs \
    --disable-static \
    --disable-asserts \
    --disable-x11-autolaunch \
    --disable-checks \
    --without-x
  make
}

check() {
  make -C dbus -j1 check
}

package() {
  depends+=(libaudit.so)
  provides=(libdbus libdbus-1.so)
  conflicts=(libdbus)
  replaces=(libdbus)

  DESTDIR="$pkgdir" make -C dbus install

  rm -r "$pkgdir"/{etc,var}

#  # We have a pre-assigned uid (81)
#  echo 'u dbus 81 "System Message Bus"' |
#  install -D -m0644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/dbus.conf"
  install -D -m0644 "$srcdir/dbus.sysusers" "$pkgdir/usr/lib/sysusers.d/dbus.conf"
  install -D -m0644 "$srcdir/dbus.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/dbus.conf"

#  install -Dt "$pkgdir/usr/share/libalpm/hooks" -m644 *.hook

  # Split docs
  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 dbus/COPYING
}

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

arch=(x86_64)

license=(GPL custom)

validpgpkeys=('DA98F25C0871C49A59EAFF2C4DE8FF2A63C7CC90') # Simon McVittie <simon.mcvittie@collabora.co.uk>

sha256sums=(SKIP
	9bc34a20595df8869d43a8d9af74cbded999c9a004ec12ff8ce07d58d81018d8 # dbus.sysusers
	965cef20cce35819e89c65f06a931a38bea2119b0ae9c259b5d7f9cfc3edd6d7) # dbus.tmpfiles

##  e6460aff62cacc298be0345f39712c627bf7d5b4c03ffb8a05700a51859b7d96  dbus-1.14.8-01-x86_64.pkg.tar.lz
