# Maintainer: Bruno Pagani (a.k.a. ArchangeGabriel) <archange@archlinux.org>
# Contributor: Mirco Tischler <mt-ml at gmx dot de>

pkgname=fwupd
pkgver=dummy
pkgrel=1
pkgdesc='A simple daemon to allow session software to update firmware'
arch=('i686' 'x86_64')
url='https://github.com/fwupd/fwupd'
license=('GPL2')
depends=('libgusb' 'modemmanager' 'tpm2-tss')
makedepends=('meson' 'valgrind' 'gobject-introspection' 'gtk-doc' 'python-pillow' 'git'
             'python-cairo' 'noto-fonts' 'noto-fonts-cjk' 'python-gobject' 'vala'
             'curl' 'polkit' 'gcab')

pkgver() {
    cd ${pkgname}

    VERSION=$(git describe | sed 's/-/.r/;s/-/./')
    [ -z $VERSION ] && VERSION=$(head meson.build | grep ' version :' | cut -d \' -f2)

    echo $VERSION
}

build() {
    cd ${pkgname}
    if [ -n "$CI" ]; then
        export CI="--wrap-mode=default"
    fi
    arch-meson -D b_lto=false $CI ../build \
        -Defi_sbat_distro_id="arch" \
        -Defi_sbat_distro_summary="Arch Linux" \
        -Defi_sbat_distro_pkgname="${pkgname}" \
        -Defi_sbat_distro_version="${pkgver}" \
        -Defi_sbat_distro_url="https://archlinux.org/packages/community/x86_64/${pkgname}/" \
        -Dsupported_build=true

    ninja -v -C ../build
}

check() {
    ninja -C build test
}

package() {
    DESTDIR="${pkgdir}" ninja -C build install
}
