# Template file for 'upower0'
pkgname=upower0
version=0.9.23
revision=4
wrksrc="upower-${version}"
build_style=gnu-configure
configure_args="--disable-static --enable-deprecated --with-backend=linux --without-idevice --with-udevrulesdir=/usr/lib/udev/rules.d"
hostmakedepends="pkg-config intltool libxslt docbook-xsl"
makedepends="libusb-devel libgudev-devel dbus-glib-devel polkit-devel"
depends="pm-utils"
conf_files="/etc/UPower/UPower.conf"
make_dirs="/var/lib/upower 0755 root root"
short_desc="Abstraction for enumerating power devices"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
homepage="http://upower.freedesktop.org"
distfiles="${homepage}/releases/upower-${version}.tar.xz"
checksum=433252b0a8e9ab4bed7e17ee3ee5b7cef6d527b1f5401ee32212d82a9682981b

provides="upower-${version}_${revision}"
replaces="upower>=0"

# Package build options
build_options="gir"
# Disable gir for cross builds.
if [ -z "$CROSS_BUILD" ]; then
	build_options_default="gir"
fi

if [ "$build_option_gir" ]; then
	configure_args+=" --enable-introspection"
	hostmakedepends+=" gobject-introspection"
else
	configure_args+=" --disable-introspection"
fi

pre_configure() {
	# Fix path to pm-utils
	sed -e 's,/usr/sbin,/usr/bin,g' -i src/linux/up-backend.c
}

libupower-glib1_package() {
	replaces="upower0<0.9.23_4"
	short_desc+=" - runtime library"
	pkg_install() {
		vmove usr/lib/*.so.*
	}
}

upower0-devel_package() {
	provides="upower-devel-${version}_${revision}"
	replaces="upower-devel>=0"
	depends="dbus-glib-devel upower0>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0
		fi
		vmove "usr/lib/*.so"
	}
}
