# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=appstream
pkgname=(appstream
         appstream-qt5
         appstream-qt)
pkgver=1.0.4
pkgrel=1
pkgdesc='Provides a standard for creating app stores across distributions'
arch=(x86_64)
url='https://distributions.freedesktop.org/wiki/AppStream'
license=(LGPL-2.1-or-later)
depends=(cairo
         curl
         fontconfig
         freetype2
         gcc-libs
         gdk-pixbuf2
         glib2
         glibc
         librsvg
         libstemmer
         libxml2
         libxmlb
         libyaml
         pango
         systemd-libs
         zstd)
makedepends=(gi-docgen
             git
             glib2-devel
             gobject-introspection
             gperf
             itstool
             meson
             qt5-tools
             qt6-tools
             vala
             xmlto)
source=(git+https://github.com/ximion/appstream#tag=v$pkgver?signed
        update-appstream-cache.hook)
sha256sums=('0b36ca33687e7ab8613cdde647fe2f71d943321e880c4d55e42544ecf859ac21'
            'edc632e4a76ebe5efc76a56fe5f797e5c981cca6f2f0111c7ce0170d1330c788')
validpgpkeys=(D33A3F0CA16B0ACC51A60738494C8A5FBF4DECEB) # Matthias Klumpp <matthias@tenstral.net>

build() {
  meson build appstream \
    --prefix=/usr \
    --libexecdir=lib \
    -Dqt=true \
    -Dqt-versions=5,6 \
    -Dvapi=true \
    -Dcompose=true
  meson compile -C build
}

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

# provided by -qt subpackage
  rm -r "$pkgdir"/usr/{include/AppStreamQt{,5},lib/cmake,lib/libAppStreamQt{,5}.*}

  install -Dm644 update-appstream-cache.hook "$pkgdir"/usr/share/libalpm/hooks/90-update-appstream-cache.hook
}

package_appstream-qt5() {
  pkgdesc='Qt5 interface for AppStream'
  depends=(appstream
           gcc-libs
           glib2
           glibc
           qt5-base)
  conflicts=('appstream-qt<1')
  replaces=('appstream-qt<1')

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

# provided by appstream
  rm -r "$pkgdir"/usr/{bin,include/appstream{,-compose},lib/{appstreamcli-compose,girepository-1.0,libappstream*,pkgconfig},share}
# provided by appstream-qt
  rm -r "$pkgdir"/usr/{include/AppStreamQt,lib/{libAppStreamQt.so*,cmake/AppStreamQt}}
}

package_appstream-qt() {
  pkgdesc='Qt6 interface for AppStream'
  depends=(appstream
           gcc-libs
           glib2
           glibc
           qt6-base)

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

# provided by appstream
  rm -r "$pkgdir"/usr/{bin,include/appstream{,-compose},lib/{appstreamcli-compose,girepository-1.0,libappstream*,pkgconfig},share}
# provided by appstream-qt5
  rm -r "$pkgdir"/usr/{include/AppStreamQt5,lib/{libAppStreamQt5.so*,cmake/AppStreamQt5}}
}
