# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ipmitool
_pkgname=IPMITOOL
pkgver=1.8.19
_pkgver=${pkgver//./_}
pkgrel=1
pkgdesc="Command-line interface to IPMI-enabled devices"
url="https://github.com/ipmitool/ipmitool"
arch="all"
license="MIT"
makedepends="automake autoconf libtool readline-dev openssl-dev>3 ncurses-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ipmitool/ipmitool/archive/${_pkgname}_$_pkgver.tar.gz
	$pkgname-fix-downloaded-iana-file.patch::https://github.com/ipmitool/ipmitool/commit/1edb0e27e44196d1ebe449aba0b9be22d376bcb6.diff
	ipmievd.initd
	ipmievd.confd
	"
builddir="$srcdir/$pkgname-${_pkgname}_$_pkgver"

# secfixes:
#   1.8.18-r9:
#     - CVE-2020-5208

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--bindir=/usr/sbin \
		--enable-ipmievd \
		--enable-ipmishell \
		--enable-intf-lan \
		--enable-intf-lanplus \
		--enable-intf-open \
		--disable-intf-free \
		--disable-intf-imb \
		--disable-intf-lipmi \
		--disable-intf-bmc \
		--disable-internal-md5 \
		--with-kerneldir=/usr
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m755 "$srcdir"/ipmievd.initd "$pkgdir"/etc/init.d/ipmievd
	install -D -m644 "$srcdir"/ipmievd.confd "$pkgdir"/etc/conf.d/ipmievd
}

sha512sums="
2d91706e9feba4b2ce4808eca087b81b842c4292a5840830001919c06ec8babd8f8761b74bb9dcf8fbc7765f028a5b1a192a3c1b643f2adaa157fed6fb0d1ee3  ipmitool-1.8.19.tar.gz
c4ac8f8b6d15ced7ae2127b2b40fdb86ef2a85e7ee026d2f34692702a380910f4ee0feff3da7717647c95eca52819ce14c304770d65353d7dcb62989c041ff65  ipmitool-fix-downloaded-iana-file.patch
665adc32529df8d5f6598d33ba92175c46e8a5b74094d22553b0265fe817b023c909688af2b02041a37b7cfd3805e6ae74b943fad48970d45564ea8d08309fa6  ipmievd.initd
4cace868f1776a96736b7460c84f525d63d6f53531f1f3e62f0337741dc36fb5b2ee9706fdae6a7b853e98d3894376949797ddc254248bd42dc79d85742c1744  ipmievd.confd
"
