# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgname=polkit
pkgver=127
pkgrel=3
pkgdesc="Application development toolkit for controlling system-wide privileges"
url="https://github.com/polkit-org/polkit"
arch=(x86_64 aarch64)
license=(LGPL-2.0-or-later)
depends=(
  duktape
  expat
  glib2
  glibc
  pam
  systemd # required by polkit.install
  systemd-libs
)
makedepends=(
  dbus
  git
  glib2-devel
  gobject-introspection
  gtk-doc
  meson
)
checkdepends=(python-dbusmock)
provides=(libpolkit-{agent,gobject}-1.so)
install=polkit.install
source=(
  "git+$url#tag=$pkgver"
  0001-meson-Support-explicit-GID.patch
  0002-meson-Detect-Arch-Linux-and-set-the-UID-and-GID.patch
  0003-meson-Enable-socket-activated-agent-helper-by-defaul.patch
  0004-agent-helper-Send-standard-error-to-journal.patch
)
b2sums=('6744385984906d97f79aedbfeb894ff274769212af44686b90f6c5ab7f3007d0e6db91b5439c95f344621aa447b570686d46eff7fac861854cfcd37fba5e73e5'
        '5549570ecce8db08263167a52211befda69eca2dd65020d132c3001b621e7b6db8a092eefb29ad0e50ab980b0158ed15a79ab7f23e1754e890b51c6ef827eb72'
        '6d4d435c8af82270fb6720ca00bab14492fbf6f0d73ba0eba0ac909cc192452a78de56ceb2fe224ac68fcc0f7c9decc01771aaa3f1956ccfae9747620986948c'
        '79ca31e536f236757d1d8774f7a6037826b7010e177675a95da8b131e7cfc61d1b08fc278fff6e6a5a06af443f37e32923c29754895c467eaffbacdd8d120803'
        '3d59bd7a7e41ed0c0de95992f3dbb34a3fce10cd29beaf7309839b0ef113398f94f5ef602ccc2c4b608e151ced2b84067ab604098e9d9fd851ef334e54c1f8d6')

prepare() {
  cd polkit

  # Arch-specific adjustments
  git apply -3 ../0001-meson-Support-explicit-GID.patch
  git apply -3 ../0002-meson-Detect-Arch-Linux-and-set-the-UID-and-GID.patch
  git apply -3 ../0003-meson-Enable-socket-activated-agent-helper-by-defaul.patch

  # https://github.com/polkit-org/polkit/issues/622
  git apply -3 ../0004-agent-helper-Send-standard-error-to-journal.patch
}

build() {
  local meson_options=(
    -D examples=true
    -D gettext=true
    -D gtk_doc=true
    -D man=true
    -D tests=true
  )

  arch-meson polkit build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs -t 3
}

package() {
  meson install -C build --destdir "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
