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

pkgbase=libgweather-4
pkgname=(
  libgweather-4
  libgweather-4-docs
)
pkgver=4.4.2
pkgrel=1
pkgdesc="Location and timezone database and weather-lookup library"
url="https://wiki.gnome.org/Projects/LibGWeather"
arch=(x86_64 aarch64)
license=(GPL-2.0-or-later)
depends=(
  dconf
  gcc-libs
  geocode-glib-2
  glib2
  glibc
  json-glib
  libsoup3
  libxml2
)
makedepends=(
  gi-docgen
  git
  gobject-introspection
  meson
  python-gobject
  vala
)
checkdepends=(python-pylint)
_commit=4b589e02df295b4932c122bf9328c5b2437b8d17  # tags/4.4.2^0
source=(
  "git+https://gitlab.gnome.org/GNOME/libgweather.git#commit=$_commit"
  disable-metar-test.diff
)
b2sums=('5403d04f881ef3234063b03286d8e584a17b752a7e74121fd485d4f7591327727bd3b66bfcd837e44a21d76bd91792c4b96cc4b0d0d0e6d02789f9bf51ab14a4'
        '3d920f17e3f82bd33791b1e9662242f90a13e3cb3832fea5b900046b0ad90f97c5cf8174a6e5905b134585f280706ab67d3b65c108ed99c8285e3f05293b2b73')

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

prepare() {
  cd libgweather

  # Disable metar test, depends on unstable online service
  git apply -3 ../disable-metar-test.diff
}

build() {
  local meson_options=(
    -D gtk_doc=true
  )

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

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

package_libgweather-4() {
  provides=(libgweather-4.so)

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

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
}

package_libgweather-4-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

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