# Contributor: Ivan Tham <pickfire@riseup.net>
# Maintainer: Ivan Tham <pickfire@riseup.net>
pkgname=tlp
_pkgname=TLP
pkgver=0.9
pkgrel=1
pkgdesc="Linux Advanced Power Management"
url="http://linrunner.de/en/tlp/tlp.html"
arch="noarch"
license="GPL-2.0"
subpackages="$pkgname-doc $pkgname-rdw:rdw $pkgname-bash-completion:bashcomp"
source="$_pkgname-$pkgver.tar.gz::https://github.com/linrunner/${_pkgname}/archive/${pkgver}.tar.gz
	$pkgname.initd"
builddir="$srcdir/"$_pkgname-$pkgver

build() {
	cd "$builddir"
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install-tlp
	install -dm755 "$pkgdir"/usr/share/man/man1
	install -m644 man/*.1 "$pkgdir"/usr/share/man/man1
	install -dm755 "$pkgdir"/usr/share/man/man8
	install -m644 man/*.8 "$pkgdir"/usr/share/man/man8
	install -m755 "$srcdir"/tlp.initd "$pkgdir"/etc/init.d/$pkgname
}

rdw() {
	depends="tlp"
	pkgdesc="Linux Advanced Power Management - Radio Device Wizard"

	cd "$builddir"
	make DESTDIR="$subpkgdir" install-rdw
}

bashcomp() {
        depends=""
        pkgdesc="Bash completions for $pkgname"
        install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

        mkdir -p "$subpkgdir"/usr/share
        mv "$pkgdir"/usr/share/bash-completion "$subpkgdir"/usr/share
}

sha512sums="126d11739f2438eb9cf8c496fc7d8cecfb05b578c2ae99264ee53d9fb85dfeab59456483867f21c621d0db6793468f7b0bd77868e999801115e157e1ba383610  TLP-0.9.tar.gz
e6de216b2540413812711b3304cdc29c8729d527080cfd747ba382db50166dd21c6c27ff467f9f2a967e92007c7a311b00e88262952c34a22f417578c66cf4e7  tlp.initd"
