#!/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 |---------------------------------------

pkgname=dbus
# dbus-docs you can get from arch, dbus-daemon-units is a split
# of native systemd services if pkg is built with systemd
#pkgname=(dbus dbus-daemon-units # dbus-docs)
pkgver=1.14.10
pkgrel=02
pkgdesc="unFreedesktop.org message bus system w/o systemd"
url="https://wiki.freedesktop.org/www/Software/dbus/"
depends=(expat audit libcap-ng)
makedepends=(docbook-xsl doxygen 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"
source=(https://dbus.freedesktop.org/releases/dbus/dbus-$pkgver.tar.xz{,.asc}
	dbus.sysusers
	dbus.tmpfiles)

prepare() {
  cd $pkgname-$pkgver

#  # 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-$pkgver
  ./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-$pkgver -j1 check
}

#_pick() {
#  local p="$1" f d; shift
#  for f; do
#    d="$srcdir/$p/${f#$pkgdir/}"
#    mkdir -p "$(dirname "$d")"
#    mv "$f" "$d"
#    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
#  done
#}

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

  cd dbus-$pkgver
  DESTDIR="$pkgdir" make install

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

#   Since it is built without systemd there is nothing to "pick"
#  _pick unit "$pkgdir"/usr/lib/systemd/{system,user}/dbus.service
#  _pick docs "$pkgdir"/usr/share/doc

#  # We have a pre-assigned uid (81)
#  echo 'u dbus 81 "System Message Bus"' |
#  install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/dbus.conf"
#  install -Dt "$pkgdir/usr/share/libalpm/hooks" -m644 ../*.hook
  install -Dm644 "$srcdir/dbus.sysusers" "$pkgdir/usr/lib/sysusers.d/dbus.conf"
  install -Dm644 "$srcdir/dbus.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/dbus.conf"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

#package_dbus-daemon-units() {
#  pkgdesc+=" - Service units"
#  depends=(dbus)
#  provides=(dbus-units)
#  conflicts=(dbus-broker-units)
#
#  mv unit/* "$pkgdir"
# }

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

arch=(x86_64)

license=("AFL-2.1 OR GPL-2.0-or-later")

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

sha256sums=(ba1f21d2bd9d339da2d4aa8780c09df32fea87998b73da24f49ab9df1e36a50f  # dbus-1.14.10.tar.xz
	5f292cd0603c3d736026ed3f4d1c1937847981669c1f0a389083518f013e1081  # dbus-1.14.10.tar.xz.asc
	9bc34a20595df8869d43a8d9af74cbded999c9a004ec12ff8ce07d58d81018d8  # dbus.sysusers
	965cef20cce35819e89c65f06a931a38bea2119b0ae9c259b5d7f9cfc3edd6d7) # dbus.tmpfiles

##  fa4e0b01c7db3f9937bd03741fb29e834cd07a197fdda3fbb70f574280e9206e  dbus-1.14.10-02-x86_64.pkg.tar.lz

