# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=wpa_supplicant
pkgver=2.6
pkgrel=8
pkgdesc="A utility providing key negotiation for WPA wireless networks"
url="https://w1.fi/wpa_supplicant/"
arch="all"
license="BSD"
subpackages="$pkgname-doc"
makedepends="linux-headers libressl-dev dbus-dev libnl3-dev pcsc-lite-dev"
source="http://w1.fi/releases/$pkgname-$pkgver.tar.gz
	rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
	rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
	rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
	rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
	rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
	rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
	rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
	rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch

	wpa_supplicant.initd
	wpa_supplicant.confd
	libressl.patch
	eloop.patch

	config
	wpa_cli.sh"

# secfixes:
#   2.6-r7:
#     - CVE-2017-13077
#     - CVE-2017-13078
#     - CVE-2017-13079
#     - CVE-2017-13080
#     - CVE-2017-13081
#     - CVE-2017-13082
#     - CVE-2017-13086
#     - CVE-2017-13087
#     - CVE-2017-13088

builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd "$builddir"
	default_prepare

	# Copy our configuration file to the build directory
	cp "$srcdir"/config "$builddir"/wpa_supplicant/.config
}

build() {
	cd "$builddir"/wpa_supplicant
	make LIBDIR=/lib BINDIR=/sbin
	make eapol_test
}

package() {
	cd "$builddir"/wpa_supplicant
	make DESTDIR="$pkgdir" LIBDIR=/lib BINDIR=/sbin install
	install -Dm644 wpa_supplicant.conf \
		"$pkgdir"/usr/share/doc/wpa_supplicant/examples/wpa_supplicant.conf
	install -Dm755 "$srcdir"/wpa_cli.sh \
		"$pkgdir"/etc/wpa_supplicant/wpa_cli.sh

	local man=
	for man in doc/docbook/*.?; do
		install -Dm644 "$man" \
			"$pkgdir"/usr/share/man/man${man##*.}/${man##*/}
	done
	install -Dm755 eapol_test "$pkgdir"/sbin/eapol_test

	# dbus
	cd dbus
	install -d "$pkgdir"/etc/dbus-1/system.d
	install -m644 dbus-wpa_supplicant.conf \
		"$pkgdir"/etc/dbus-1/system.d/wpa_supplicant.conf
	install -d "$pkgdir"/usr/share/dbus-1/system-services
	install fi.epitest.hostap.WPASupplicant.service \
		"$pkgdir"/usr/share/dbus-1/system-services
	install -d "$pkgdir"/var/run/wpa_supplicant
	install -Dm755 "$srcdir"/wpa_supplicant.initd \
		"$pkgdir"/etc/init.d/wpa_supplicant
	install -Dm644 "$srcdir"/wpa_supplicant.confd \
		"$pkgdir"/etc/conf.d/wpa_supplicant
}

sha512sums="46442cddb6ca043b8b08d143908f149954c238e0f3a57a0df73ca4fab9c1acd91b078f3f26375a1d99cd1d65625986328018c735d8705882c8f91e389cad28a6  wpa_supplicant-2.6.tar.gz
f855fa792425f175ccc800eb49df42067b1c1f4b52ba2d24160af4dfbb74dcf8e81661b7e6c8d92fa408938b8a559fc74557d1677913e4a751bfd43706c14bb6  rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
b4e413aa815572ea0002d33d24b69cd499aebb5efebed8fcaade8b29324bb5853a5db64e8b1dfdf24478e02c66196238b81a6ec777a7a28610435dce4d2c344e  rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
a6382d8e84b4829be33c46bf2f4c6f3232c9d924a4547a21dfe023bf5be8ee1c635920295f52be285359efaae95bcc1f12b512659cfd1653b871dd0bea7e5ace  rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
51ed806f0d5b3f588e26d4db4dcfc6be2cfb12002e26893a6cedd62c7cad0d0de75aed4a666223c4877fc1854b08dce6ddf6f6c4cfd752a5d8d58ad4a968b553  rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
8707a123cd78149dfee9f5bd791761ee1eca605ef96580167044c2339c896920cf0e030b184a5afa9e310f5755afb30bef8ebd4522fc52753f3fbd6acead2cdf  rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
37d050b2e4a3598484912667d8b2705fbe84c5c562267f900d42b0c7b606fb1fed09ddca8b80e2131768baa8f3690aab6ba7a232dee6ff1e66150fdb8816c927  rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
111e655cfbb3a86e3792040e0ea375490d31c42c9d43cbe911290d54df5f4db437e4c8ad0e937c51729dcefeb0db0989b8ab55b9523398683abd08ebfec18076  rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
fc84edd8b30305cc42053c872554098f3f077292ec980ed6a442f37884087ff2f055738fd55977ed792bef1887dcc8c4626586465d78dd0258edb83dcd50a65a  rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch
11eed22f6e793f40c788d586c715deecae03c421d11761b7b4a376660bce812c54cc6f353c7d4d5da9c455aeffd778baefb9e76d380027a729574a756e54ddcc  wpa_supplicant.initd
29103161ec2b9631fca9e8d9a97fafd60ffac3fe78cf613b834395ddcaf8be1e253c22e060d7d9f9b974b2d7ce794caa932a2125e29f6494b75bce475f7b30e1  wpa_supplicant.confd
e98edc1ecec91335d515c50cac8816e3f6eef139aba574bcf0c6c20c131ef0de40aa657a33d07af09ab28245471a09cb6b3e29b306e48f46d335a0c47a0a56c4  libressl.patch
2be055dd1f7da5a3d8e79c2f2c0220ddd31df309452da18f290144d2112d6dbde0fc633bb2ad02c386a39d7785323acaf5f70e5969995a1e8303a094eb5fe232  eloop.patch
6707991f9a071f2fcb09d164d31d12b1f52b91fbb5574b70b8d6f9727f72bbe42b03dd66d10fcc2126f5b7e49ac785657dec90e88b4bf54a9aa5638582f6e505  config
44d33cfe419cdb65cc14f2ac05aa9f8a1b9f2f432181e498071e41ef835662db1e4c5142adf4cfab2475e7b606696169936bd159d1d711f803322db93f242361  wpa_cli.sh"
