# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=malcontent
pkgname=(
  malcontent
  libmalcontent
)
pkgver=0.12.0
pkgrel=1
pkgdesc="Parental control support for applications"
url="https://gitlab.freedesktop.org/pwithnall/malcontent"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(LGPL-2.1-or-later)
depends=(
  accountsservice
  appstream
  dbus
  flatpak
  gcc-libs
  glib2
  glibc
  gtk4
  hicolor-icon-theme
  libadwaita
  pam
  polkit
  python
  python-gobject
)
makedepends=(
  git
  gobject-introspection
  gtk-doc
  libglib-testing
  meson
  python-packaging
  yelp-tools
)
_commit=3ba80995bb25b7aeda7e21d547f9e39ff9a81736  # tags/0.12.0^0
source=("git+https://gitlab.freedesktop.org/pwithnall/malcontent.git#commit=$_commit")
b2sums=('6d0887476764bfd8b481bd42b8f5405227160c33026cdf8bdb6d83c3b0bad8e4831d5dea9ede44d7bcad7a0173e5ac7bec780e37e6577bf393054d01004018b4')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  arch-meson $pkgname build
  meson compile -C build
}

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

_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_malcontent() {
  depends+=("libmalcontent=$pkgver-$pkgrel")
  provides=(libmalcontent-ui-1.so)
  groups=(gnome)

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

  cd "$pkgdir"

  _pick libs usr/include/malcontent-0
  _pick libs usr/lib/girepository-1.0/Malcontent-0.typelib
  _pick libs usr/lib/libmalcontent-0.so*
  _pick libs usr/lib/pkgconfig/malcontent-0.pc
  _pick libs usr/share/gir-1.0/Malcontent-0.gir
}

package_libmalcontent() {
  pkgdesc="Parental control library"
  depends=(
    gcc-libs
    glibc
    libg{lib,object,io}-2.0.so
  )
  provides=(libmalcontent-0.so)

  mv libs/* "$pkgdir"
}

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