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

pkgbase=at-spi2-core
pkgname=(at-spi2-core) # at-spi2-core-docs) # uncomment the docs sections and modify this pkg list to build the docs documents
pkgver=2.48.0
pkgrel=02
#  Arch replaced makedependency from libsystemd to systemd, the reason for the rerun 2.44.0-2
#  Let's see if it makes a difference to us :)  :P
pkgdesc="Protocol definitions and daemon for D-Bus at-spi w/o systemd"
url="https://gitlab.gnome.org/GNOME/at-spi2-core"
depends=(dbus glib2 libxtst libx11 libxml2 gsettings-desktop-schemas)
makedepends=(gobject-introspection git meson gi-docgen python-sphinx)
checkdepends=(at-spi2-core)
_commit=d963aff7f6977e50517fb2ffe8b31f1db142107d  # tags/AT_SPI2_CORE_2_48_0^0
# options=(debug)  ##  uncomment this to have the debug package built
source=("git+$url.git#commit=$_commit")

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/^AT_SPI2_CORE_//;s/_/./g;s/-/+/g'
}

prepare() {
  cd $pkgbase
}

build() {
  local meson_options=(
    -D default_bus=dbus-broker
    -D docs=true
  )
  arch-meson at-spi2-core build "${meson_options[@]}"
  meson compile -C build
}

check() {
  # memory test fails without desktop
  # broker fails to launch without journald
  # # Aaahhh journald must be running for the check to pass --- yawn yawn and again!
  dbus-run-session meson test -C build --print-errorlogs
}

package_at-spi2-core() {
  optdepends=('dbus-broker: Alternative bus implementation')
  provides=(
    "at-spi2-atk=$pkgver-$pkgrel"
    "atk=$pkgver-$pkgrel"
    libatk-1.0.so
    libatk-bridge-2.0.so
    libatspi.so
  )
  conflicts=(
    'at-spi2-atk<=2.38.0-2'
    'atk<=2.38.0-2'
  )
  replaces=(
    'at-spi2-atk<=2.38.0-2'
    'atk<=2.38.0-2'
  )

   meson install -C build --destdir "$pkgdir"

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
  rm -rf $pkgdir/usr/lib/systemd/user/at-spi-dbus-bus.service
  rm -rf $pkgdir/usr/lib/systemd
}

#package_at-spi2-core-docs() {
#  pkgdesc+=" (documentation)"
#  depends=()
#
#  mv doc/* "$pkgdir"
#
#  meson install -C build --destdir "$pkgdir"
#}

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

arch=(x86_64)

license=(GPL2)

sha256sums=('SKIP')
 
##  b49d51de057aa34607559fb9f7242d52a03b3dc25ece7fc33709e363c52d2261  at-spi2-core-2.48.0-02-x86_64.pkg.tar.lz


