1SUMMARY = "Client for Wi-Fi Protected Access (WPA)"
2HOMEPAGE = "http://w1.fi/wpa_supplicant/"
3DESCRIPTION = "wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2 (IEEE 802.11i / RSN). Supplicant is the IEEE 802.1X/WPA component that is used in the client stations. It implements key negotiation with a WPA Authenticator and it controls the roaming and IEEE 802.11 authentication/association of the wlan driver."
4BUGTRACKER = "http://w1.fi/security/"
5SECTION = "network"
6LICENSE = "BSD-3-Clause"
7LIC_FILES_CHKSUM = "file://COPYING;md5=5ebcb90236d1ad640558c3d3cd3035df \
8                    file://README;beginline=1;endline=56;md5=e3d2f6c2948991e37c1ca4960de84747 \
9                    file://wpa_supplicant/wpa_supplicant.c;beginline=1;endline=12;md5=76306a95306fee9a976b0ac1be70f705"
10DEPENDS = "dbus libnl"
11RRECOMMENDS:${PN} = "wpa-supplicant-passphrase wpa-supplicant-cli"
12
13PACKAGECONFIG ??= "openssl"
14PACKAGECONFIG[gnutls] = ",,gnutls libgcrypt"
15PACKAGECONFIG[openssl] = ",,openssl"
16
17inherit pkgconfig systemd
18
19SYSTEMD_SERVICE:${PN} = "wpa_supplicant.service"
20SYSTEMD_AUTO_ENABLE = "disable"
21
22SRC_URI = "http://w1.fi/releases/wpa_supplicant-${PV}.tar.gz \
23           file://defconfig \
24           file://wpa-supplicant.sh \
25           file://wpa_supplicant.conf \
26           file://wpa_supplicant.conf-sane \
27           file://99_wpa_supplicant \
28           "
29SRC_URI[sha256sum] = "20df7ae5154b3830355f8ab4269123a87affdea59fe74fe9292a91d0d7e17b2f"
30
31CVE_PRODUCT = "wpa_supplicant"
32
33S = "${WORKDIR}/wpa_supplicant-${PV}"
34
35PACKAGES:prepend = "wpa-supplicant-passphrase wpa-supplicant-cli "
36FILES:wpa-supplicant-passphrase = "${bindir}/wpa_passphrase"
37FILES:wpa-supplicant-cli = "${sbindir}/wpa_cli"
38FILES:${PN} += "${datadir}/dbus-1/system-services/* ${systemd_system_unitdir}/*"
39CONFFILES:${PN} += "${sysconfdir}/wpa_supplicant.conf"
40
41do_configure () {
42	${MAKE} -C wpa_supplicant clean
43	install -m 0755 ${WORKDIR}/defconfig wpa_supplicant/.config
44
45	if echo "${PACKAGECONFIG}" | grep -qw "openssl"; then
46        	ssl=openssl
47	elif echo "${PACKAGECONFIG}" | grep -qw "gnutls"; then
48        	ssl=gnutls
49	fi
50	if [ -n "$ssl" ]; then
51        	sed -i "s/%ssl%/$ssl/" wpa_supplicant/.config
52	fi
53
54	# For rebuild
55	rm -f wpa_supplicant/*.d wpa_supplicant/dbus/*.d
56}
57
58export EXTRA_CFLAGS = "${CFLAGS}"
59export BINDIR = "${sbindir}"
60
61do_compile () {
62	unset CFLAGS CPPFLAGS CXXFLAGS
63	sed -e "s:CFLAGS\ =.*:& \$(EXTRA_CFLAGS):g" -i ${S}/src/lib.rules
64	oe_runmake -C wpa_supplicant
65}
66
67do_install () {
68	install -d ${D}${sbindir}
69	install -m 755 wpa_supplicant/wpa_supplicant ${D}${sbindir}
70	install -m 755 wpa_supplicant/wpa_cli        ${D}${sbindir}
71
72	install -d ${D}${bindir}
73	install -m 755 wpa_supplicant/wpa_passphrase ${D}${bindir}
74
75	install -d ${D}${docdir}/wpa_supplicant
76	install -m 644 wpa_supplicant/README ${WORKDIR}/wpa_supplicant.conf ${D}${docdir}/wpa_supplicant
77
78	install -d ${D}${sysconfdir}
79	install -m 600 ${WORKDIR}/wpa_supplicant.conf-sane ${D}${sysconfdir}/wpa_supplicant.conf
80
81	install -d ${D}${sysconfdir}/network/if-pre-up.d/
82	install -d ${D}${sysconfdir}/network/if-post-down.d/
83	install -d ${D}${sysconfdir}/network/if-down.d/
84	install -m 755 ${WORKDIR}/wpa-supplicant.sh ${D}${sysconfdir}/network/if-pre-up.d/wpa-supplicant
85	cd ${D}${sysconfdir}/network/ && \
86	ln -sf ../if-pre-up.d/wpa-supplicant if-post-down.d/wpa-supplicant
87
88	install -d ${D}/${sysconfdir}/dbus-1/system.d
89	install -m 644 ${S}/wpa_supplicant/dbus/dbus-wpa_supplicant.conf ${D}/${sysconfdir}/dbus-1/system.d
90	install -d ${D}/${datadir}/dbus-1/system-services
91	install -m 644 ${S}/wpa_supplicant/dbus/*.service ${D}/${datadir}/dbus-1/system-services
92
93	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
94		install -d ${D}/${systemd_system_unitdir}
95		install -m 644 ${S}/wpa_supplicant/systemd/*.service ${D}/${systemd_system_unitdir}
96	fi
97
98	install -d ${D}/etc/default/volatiles
99	install -m 0644 ${WORKDIR}/99_wpa_supplicant ${D}/etc/default/volatiles
100}
101
102pkg_postinst:${PN} () {
103	# If we're offline, we don't need to do this.
104	if [ "x$D" = "x" ]; then
105		killall -q -HUP dbus-daemon || true
106	fi
107
108}
109