# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=eiwd
_realpkgname=iwd
pkgver=2.22
pkgrel=0
pkgdesc="Internet Wireless Daemon without dbus"
url="https://github.com/illiliti/eiwd"
arch="all"
license="LGPL-2.1-or-later"
depends="!iwd"
replaces="iwd"
options="!check" # doesn't work because of eapol issue
makedepends="linux-headers readline-dev"
checkdepends="coreutils"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/illiliti/eiwd/releases/download/$pkgver-1/iwd-$pkgver.tar.xz
	0001-resolving-service-none.patch
	fix-crash-in-the-RSSI-polling-fallback-workaround.patch

	eiwd.initd
	main.conf
	iwd_passphrase
	"
builddir="$srcdir/iwd-$pkgver"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-systemd-service \
		--disable-dbus
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -m750 -d "$pkgdir"/var/lib/$_realpkgname
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/main.conf \
		"$pkgdir"/etc/$_realpkgname/main.conf
	install -m755 -D "$srcdir"/iwd_passphrase \
		"$pkgdir"/usr/bin
}

sha512sums="
455ee65debe9ab2a2f9267e57d20aa8d4121771fa7e408a37acd6002c47fe14ab45c125edd5a1d1482df01e40153a9dafd4b0e7d721b4f3cab1c42d9d4a1e714  iwd-2.22.tar.xz
aff4cd6bf4ae72aa64f9f5485bd310633f5219eb71532a8c0fa9a05abaaf50f7636a70a63e533370cd12a702854340e18b27b0537b26ead846fa9c351ec03b42  0001-resolving-service-none.patch
5760182ef1b0a7f1e34643dd63d57513ebfc6764a57b9fb20884e3d4e3efe0514adf78df52ae080014f6f1cd9c2467f396c7723cdc9914eb5591cd6ca3b3a2b2  fix-crash-in-the-RSSI-polling-fallback-workaround.patch
b78d19f5a3ef5f12d33b4fab11ed348b1b2fe309310c33fe278d302cadf065dba72c13214bd760576ecb47f6681d012adcb4997e17a75778d41e3c4fd6a0eb01  eiwd.initd
33517c2c72c43440ed2e68e53bb937d7d557efdf19a6f7fa9cceb87be4b64499f8b9bd6f981f5e413dc3d724eb13ec08b50a129dd81cf64872c362fc5e1d1321  main.conf
06d0258e9e4d13a5cd7cb47cc30c122e2ea950c84b18352fef4982bef41961295316de396b7e6d0a33b949436da40d08fdd76230c7c228d8bdd0e33751cad26c  iwd_passphrase
"
