# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: György Balló <ballogy@freestart.hu>

pkgname=geoclue
pkgver=2.8.0
pkgrel=1
pkgdesc="Modular geoinformation service built on the D-Bus messaging system"
url="https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home"
arch=(x86_64 aarch64)
license=(
  LGPL-2.1-or-later
  GPL-2.0-or-later
)
depends=(
  avahi
  gcc-libs
  glib2
  glibc
  json-glib
  libmm-glib
  libsoup3
)
makedepends=(
  git
  glib2-devel
  gobject-introspection
  gtk-doc
  libnotify
  meson
  systemd
  vala
)
optdepends=('libnotify: Demo Agent')
provides=("geoclue2=$pkgver-$pkgrel")
conflicts=(geoclue2)
replaces=(geoclue2)
backup=(etc/geoclue/geoclue.conf)
source=(
  "git+https://gitlab.freedesktop.org/geoclue/geoclue.git#tag=$pkgver"
)
b2sums=('5995fad62e62c270622f32e9fa9ec089c78647c9d77ac173424dc00cb9c281bc6aac7f0f8a4851abac5fe341285fda9a8502d0444589074f2ddf25dd1ced71e1')

# Google API keys (see https://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Arch Linux use ONLY. For your own distribution, please
# get your own set of keys.
_google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM

prepare() {
  cd geoclue
}

build() {
  local meson_options=(
    -D dbus-srv-user=geoclue
    -D default-wifi-url="https://www.googleapis.com/geolocation/v1/geolocate?key=$_google_api_key"
  )

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

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

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

  echo 'd /var/lib/geoclue 0755 geoclue geoclue' |
    install -Dm644 /dev/stdin "$pkgdir/usr/lib/tmpfiles.d/geoclue.conf"
}

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