# Copyright     : Obarun
#------------------------
# Maintainer    : Eric Vidal <eric@obarun.org>
# Maintainer    : Jean-Michel T.Dydak <jean-michel@obarun.org>
#----------------
# Pkgbuild Src  : https://git.obarun.org/pkg/obextra/upower
#--------------------------------------------------------------
# DESCRIPTION ]

pkgname=upower
pkgver=0.99.19
pkgrel=2
pkgdesc="Abstraction for enumerating power devices, listening to device events and querying history and statistics"
url='http://upower.freedesktop.org'

track="commit"
target=e9d73a31154dab202ac9438a24fa2a67c34f686d  # tags/v0.99.19^0
source=(
    "git+https://gitlab.freedesktop.org/upower/upower.git#${track}=${target}"
    0001-build-Fix-default-udevrulesdir.patch
    0002-build-Fix-version-macros.patch
)

#----------------------
# BUILD CONFIGURATION ]

makedepends=(
    'docbook-xsl'
    'gobject-introspection'
    'python'
    'git'
    'gtk-doc'
    'meson'
)

checkdepends=(
    'python-dbus'
    'python-dbusmock'
    'python-gobject'
)   #'umockdev'

#------------------------
# INSTALL CONFIGURATION ]

depends=(
    'libimobiledevice'
    'libgudev'
)

backup=(
    'etc/UPower/UPower.conf'
)

#--------------------
# BUILD PREPARATION ]

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

prepare() {
    cd $pkgname

    ## meson fixes
    git apply -3 ../0001-build-Fix-default-udevrulesdir.patch
    git apply -3 ../0002-build-Fix-version-macros.patch
}

#--------
# BUILD ]

build() {
    arch-meson upower build -D systemdsystemunitdir=no
    meson compile -C build
}

#--------
# CHECK ]

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

#----------
# PACKAGE ]

package() {
    depends+=(
        'libglib-2.0.so'
        'libgobject-2.0.so'
        'libgio-2.0.so'
    )
    provides+=(
        'libupower-glib.so'
    )

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

#--------------------
# ARCH LICENSE AUTH ]

arch=(x86_64)
license=(GPL)

sha512sums=('')