# Contributor: Ivan Tham <pickfire@riseup.net>
# Contributor: Nero <nero@w1r3.net>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=tlp
pkgver=1.7.0
pkgrel=0
pkgdesc="Linux Advanced Power Management"
url="https://linrunner.de/en/tlp/tlp.html"
arch="noarch"
license="GPL-2.0-or-later"
options="!check"  # no test suite
depends="perl usbutils grep" # /usr/share/tlp/tlp-readconfs uses perl (see #11181)
subpackages="
	$pkgname-doc
	$pkgname-openrc
	$pkgname-rdw
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/linrunner/TLP/archive/$pkgver.tar.gz
	tlp.initd
	"
builddir="$srcdir/TLP-$pkgver"

build() {
	make
}

package() {
	make TLP_WITH_SYSTEMD=0 DESTDIR="$pkgdir" install-tlp

	install -Dm644 man/*.1 -t "$pkgdir"/usr/share/man/man1
	install -Dm644 man/*.8 -t "$pkgdir"/usr/share/man/man8
	install -Dm755 "$srcdir"/tlp.initd "$pkgdir"/etc/init.d/$pkgname
}

rdw() {
	pkgdesc="Linux Advanced Power Management - Radio Device Wizard"
	depends="$pkgname=$pkgver-r$pkgrel"

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

sha512sums="
db6777dff1b253f63941271d39b3785646ad15b4351a4a647ec748d9beabcc891b70d4070d0ce5b01919024e7560eac6ee858b720f8ec0a5535c51513ccf7a3d  tlp-1.7.0.tar.gz
e6de216b2540413812711b3304cdc29c8729d527080cfd747ba382db50166dd21c6c27ff467f9f2a967e92007c7a311b00e88262952c34a22f417578c66cf4e7  tlp.initd
"
