parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

wpa_supplicant-2.10-r4.ebuild (12703B)


      1 # Copyright 1999-2023 Gentoo Authors
      2 # Distributed under the terms of the GNU General Public License v2
      3 
      4 EAPI=8
      5 
      6 inherit desktop linux-info qmake-utils readme.gentoo-r1 systemd toolchain-funcs
      7 
      8 DESCRIPTION="IEEE 802.1X/WPA supplicant for secure wireless transfers"
      9 HOMEPAGE="https://w1.fi/wpa_supplicant/"
     10 LICENSE="|| ( GPL-2 BSD )"
     11 
     12 if [ "${PV}" = "9999" ]; then
     13 	inherit git-r3
     14 	EGIT_REPO_URI="https://w1.fi/hostap.git"
     15 else
     16 	KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~loong ~mips ~ppc ppc64 ~riscv ~sparc x86"
     17 	SRC_URI="https://w1.fi/releases/${P}.tar.gz"
     18 fi
     19 
     20 SLOT="0"
     21 IUSE="ap broadcom-sta dbus eap-sim eapol-test fasteap +fils +hs2-0 macsec +mbo +mesh p2p privsep ps3 qt5 readline selinux smartcard tdls tkip uncommon-eap-types wep wimax wps"
     22 
     23 # CONFIG_PRIVSEP=y does not have sufficient support for the new driver
     24 # interface functions used for MACsec, so this combination cannot be used
     25 # at least for now. bug #684442
     26 REQUIRED_USE="
     27 	macsec? ( !privsep )
     28 	privsep? ( !macsec )
     29 	broadcom-sta? ( !fils !mesh !mbo )
     30 "
     31 
     32 DEPEND="
     33 	>=dev-libs/openssl-1.0.2k:=
     34 	dbus? ( sys-apps/dbus )
     35 	kernel_linux? (
     36 		>=dev-libs/libnl-3.2:3
     37 		eap-sim? ( sys-apps/pcsc-lite )
     38 	)
     39 	!kernel_linux? ( net-libs/libpcap )
     40 	privsep? ( acct-group/wpapriv )
     41 	qt5? (
     42 		dev-qt/qtcore:5
     43 		dev-qt/qtgui:5
     44 		dev-qt/qtsvg:5
     45 		dev-qt/qtwidgets:5
     46 	)
     47 	readline? (
     48 		sys-libs/ncurses:0=
     49 		sys-libs/readline:0=
     50 	)
     51 "
     52 RDEPEND="${DEPEND}
     53 	selinux? ( sec-policy/selinux-networkmanager )
     54 	kernel_linux? (
     55 		net-wireless/wireless-regdb
     56 	)
     57 "
     58 BDEPEND="virtual/pkgconfig"
     59 
     60 DOC_CONTENTS="
     61 	If this is a clean installation of wpa_supplicant, you
     62 	have to create a configuration file named
     63 	${EROOT}/etc/wpa_supplicant/wpa_supplicant.conf
     64 	An example configuration file is available for reference in
     65 	${EROOT}/usr/share/doc/${PF}/
     66 "
     67 
     68 S="${WORKDIR}/${P}/${PN}"
     69 
     70 Kconfig_style_config() {
     71 		#param 1 is CONFIG_* item
     72 		#param 2 is what to set it = to, defaulting in y
     73 		CONFIG_PARAM="${CONFIG_HEADER:-CONFIG_}$1"
     74 		setting="${2:-y}"
     75 
     76 		if [ ! $setting = n ]; then
     77 			#first remove any leading "# " if $2 is not n
     78 			sed -i "/^# *$CONFIG_PARAM=/s/^# *//" .config || echo "Kconfig_style_config error uncommenting $CONFIG_PARAM"
     79 			#set item = $setting (defaulting to y)
     80 			if ! sed -i "/^$CONFIG_PARAM\>/s/=.*/=$setting/" .config; then
     81 				echo "Kconfig_style_config error setting $CONFIG_PARAM=$setting"
     82 			fi
     83 			if [ -z "$( grep ^$CONFIG_PARAM= .config )" ] ; then
     84 				echo "$CONFIG_PARAM=$setting" >>.config
     85 			fi
     86 		else
     87 			#ensure item commented out
     88 			if ! sed -i "/^$CONFIG_PARAM\>/s/$CONFIG_PARAM/# $CONFIG_PARAM/" .config; then
     89 				echo "Kconfig_style_config error commenting $CONFIG_PARAM"
     90 			fi
     91 		fi
     92 }
     93 
     94 src_prepare() {
     95 	default
     96 
     97 	# net/bpf.h needed for net-libs/libpcap on Gentoo/FreeBSD
     98 	sed -i \
     99 		-e "s:\(#include <pcap\.h>\):#include <net/bpf.h>\n\1:" \
    100 		../src/l2_packet/l2_packet_freebsd.c || die
    101 
    102 	# Change configuration to match Gentoo locations (bug #143750)
    103 	sed -i \
    104 		-e "s:/usr/lib/opensc:/usr/$(get_libdir):" \
    105 		-e "s:/usr/lib/pkcs11:/usr/$(get_libdir):" \
    106 		wpa_supplicant.conf || die
    107 
    108 	# systemd entries to D-Bus service files (bug #372877)
    109 	echo 'SystemdService=wpa_supplicant.service' \
    110 		| tee -a dbus/*.service >/dev/null || die
    111 
    112 	cd "${WORKDIR}/${P}" || die
    113 
    114 	if use wimax; then
    115 		# generate-libeap-peer.patch comes before
    116 		# fix-undefined-reference-to-random_get_bytes.patch
    117 		eapply "${FILESDIR}/${P}-generate-libeap-peer.patch"
    118 
    119 		# multilib-strict fix (bug #373685)
    120 		sed -e "s/\/usr\/lib/\/usr\/$(get_libdir)/" -i src/eap_peer/Makefile || die
    121 	fi
    122 
    123 	# bug (320097)
    124 	eapply "${FILESDIR}/${PN}-2.6-do-not-call-dbus-functions-with-NULL-path.patch"
    125 
    126 	# bug (912315)
    127 	eapply "${FILESDIR}/${PN}-2.10-allow-legacy-renegotiation.patch"
    128 	eapply "${FILESDIR}/${P}-Drop-security-level-to-0-with-OpenSSL-3.0-wh.patch"
    129 
    130 	# bug (640492)
    131 	sed -i 's#-Werror ##' wpa_supplicant/Makefile || die
    132 }
    133 
    134 src_configure() {
    135 	# Toolchain setup
    136 	tc-export CC PKG_CONFIG
    137 
    138 	cp defconfig .config || die
    139 
    140 	# Basic setup
    141 	Kconfig_style_config CTRL_IFACE
    142 	Kconfig_style_config MATCH_IFACE
    143 	Kconfig_style_config BACKEND file
    144 	Kconfig_style_config IBSS_RSN
    145 	Kconfig_style_config IEEE80211W
    146 	Kconfig_style_config IEEE80211R
    147 	Kconfig_style_config HT_OVERRIDES
    148 	Kconfig_style_config VHT_OVERRIDES
    149 	Kconfig_style_config OCV
    150 	Kconfig_style_config TLSV11
    151 	Kconfig_style_config TLSV12
    152 	Kconfig_style_config GETRANDOM
    153 
    154 	# Basic authentication methods
    155 	# NOTE: we don't set GPSK or SAKE as they conflict
    156 	# with the below options
    157 	Kconfig_style_config EAP_GTC
    158 	Kconfig_style_config EAP_MD5
    159 	Kconfig_style_config EAP_OTP
    160 	Kconfig_style_config EAP_PAX
    161 	Kconfig_style_config EAP_PSK
    162 	Kconfig_style_config EAP_TLV
    163 	Kconfig_style_config EAP_EXE
    164 	Kconfig_style_config IEEE8021X_EAPOL
    165 	Kconfig_style_config PKCS12
    166 	Kconfig_style_config PEERKEY
    167 	Kconfig_style_config EAP_LEAP
    168 	Kconfig_style_config EAP_MSCHAPV2
    169 	Kconfig_style_config EAP_PEAP
    170 	Kconfig_style_config EAP_TEAP
    171 	Kconfig_style_config EAP_TLS
    172 	Kconfig_style_config EAP_TTLS
    173 
    174 	# Enabling background scanning.
    175 	Kconfig_style_config BGSCAN_SIMPLE
    176 	Kconfig_style_config BGSCAN_LEARN
    177 
    178 	if use dbus ; then
    179 		Kconfig_style_config CTRL_IFACE_DBUS
    180 		Kconfig_style_config CTRL_IFACE_DBUS_NEW
    181 		Kconfig_style_config CTRL_IFACE_DBUS_INTRO
    182 	else
    183 		Kconfig_style_config CTRL_IFACE_DBUS n
    184 		Kconfig_style_config CTRL_IFACE_DBUS_NEW n
    185 		Kconfig_style_config CTRL_IFACE_DBUS_INTRO n
    186 	fi
    187 
    188 	if use eapol-test ; then
    189 		Kconfig_style_config EAPOL_TEST
    190 	fi
    191 
    192 	# Enable support for writing debug info to a log file and syslog.
    193 	Kconfig_style_config DEBUG_FILE
    194 	Kconfig_style_config DEBUG_SYSLOG
    195 
    196 	if use hs2-0 ; then
    197 		Kconfig_style_config INTERWORKING
    198 		Kconfig_style_config HS20
    199 	fi
    200 
    201 	if use mbo ; then
    202 		Kconfig_style_config MBO
    203 	else
    204 		Kconfig_style_config MBO n
    205 	fi
    206 
    207 	if use uncommon-eap-types; then
    208 		Kconfig_style_config EAP_GPSK
    209 		Kconfig_style_config EAP_SAKE
    210 		Kconfig_style_config EAP_GPSK_SHA256
    211 		Kconfig_style_config EAP_IKEV2
    212 		Kconfig_style_config EAP_EKE
    213 	fi
    214 
    215 	if use eap-sim ; then
    216 		# Smart card authentication
    217 		Kconfig_style_config EAP_SIM
    218 		Kconfig_style_config EAP_AKA
    219 		Kconfig_style_config EAP_AKA_PRIME
    220 		Kconfig_style_config PCSC
    221 	fi
    222 
    223 	if use fasteap ; then
    224 		Kconfig_style_config EAP_FAST
    225 	fi
    226 
    227 	if use readline ; then
    228 		# readline/history support for wpa_cli
    229 		Kconfig_style_config READLINE
    230 	else
    231 		#internal line edit mode for wpa_cli
    232 		Kconfig_style_config WPA_CLI_EDIT
    233 	fi
    234 
    235 	Kconfig_style_config TLS openssl
    236 	Kconfig_style_config FST
    237 
    238 	Kconfig_style_config EAP_PWD
    239 	if use fils; then
    240 		Kconfig_style_config FILS
    241 		Kconfig_style_config FILS_SK_PFS
    242 	fi
    243 	if use mesh; then
    244 		Kconfig_style_config MESH
    245 	else
    246 		Kconfig_style_config MESH n
    247 	fi
    248 	# WPA3
    249 	Kconfig_style_config OWE
    250 	Kconfig_style_config SAE
    251 	Kconfig_style_config DPP
    252 	Kconfig_style_config DPP2
    253 	Kconfig_style_config SUITEB192
    254 	Kconfig_style_config SUITEB
    255 
    256 	if use wep ; then
    257 		Kconfig_style_config WEP
    258 	else
    259 		Kconfig_style_config WEP n
    260 	fi
    261 
    262 	# Watch out, reversed logic
    263 	if use tkip ; then
    264 		Kconfig_style_config NO_TKIP n
    265 	else
    266 		Kconfig_style_config NO_TKIP
    267 	fi
    268 
    269 	if use smartcard ; then
    270 		Kconfig_style_config SMARTCARD
    271 	else
    272 		Kconfig_style_config SMARTCARD n
    273 	fi
    274 
    275 	if use tdls ; then
    276 		Kconfig_style_config TDLS
    277 	fi
    278 
    279 	if use kernel_linux ; then
    280 		# Linux specific drivers
    281 		Kconfig_style_config DRIVER_ATMEL
    282 		Kconfig_style_config DRIVER_HOSTAP
    283 		Kconfig_style_config DRIVER_IPW
    284 		Kconfig_style_config DRIVER_NL80211
    285 		Kconfig_style_config DRIVER_RALINK
    286 		Kconfig_style_config DRIVER_WEXT
    287 		Kconfig_style_config DRIVER_WIRED
    288 
    289 		if use macsec ; then
    290 			#requires something, no idea what
    291 			#Kconfig_style_config DRIVER_MACSEC_QCA
    292 			Kconfig_style_config DRIVER_MACSEC_LINUX
    293 			Kconfig_style_config MACSEC
    294 		else
    295 			# bug #831369 and bug #684442
    296 			Kconfig_style_config DRIVER_MACSEC_LINUX n
    297 			Kconfig_style_config MACSEC n
    298 		fi
    299 
    300 		if use ps3 ; then
    301 			Kconfig_style_config DRIVER_PS3
    302 		fi
    303 	fi
    304 
    305 	# Wi-Fi Protected Setup (WPS)
    306 	if use wps ; then
    307 		Kconfig_style_config WPS
    308 		Kconfig_style_config WPS2
    309 		# USB Flash Drive
    310 		Kconfig_style_config WPS_UFD
    311 		# External Registrar
    312 		Kconfig_style_config WPS_ER
    313 		# Universal Plug'n'Play
    314 		Kconfig_style_config WPS_UPNP
    315 		# Near Field Communication
    316 		Kconfig_style_config WPS_NFC
    317 	else
    318 		Kconfig_style_config WPS n
    319 		Kconfig_style_config WPS2 n
    320 		Kconfig_style_config WPS_UFD n
    321 		Kconfig_style_config WPS_ER n
    322 		Kconfig_style_config WPS_UPNP n
    323 		Kconfig_style_config WPS_NFC n
    324 	fi
    325 
    326 	# Wi-Fi Direct (WiDi)
    327 	if use p2p ; then
    328 		Kconfig_style_config P2P
    329 		Kconfig_style_config WIFI_DISPLAY
    330 	else
    331 		Kconfig_style_config P2P n
    332 		Kconfig_style_config WIFI_DISPLAY n
    333 	fi
    334 
    335 	# Access Point Mode
    336 	if use ap ; then
    337 		Kconfig_style_config AP
    338 	else
    339 		Kconfig_style_config AP n
    340 	fi
    341 
    342 	# Enable essentials for AP/P2P
    343 	if use ap || use p2p ; then
    344 		# Enabling HT support (802.11n)
    345 		Kconfig_style_config IEEE80211N
    346 
    347 		# Enabling VHT support (802.11ac)
    348 		Kconfig_style_config IEEE80211AC
    349 	fi
    350 
    351 	# Enable mitigation against certain attacks against TKIP
    352 	Kconfig_style_config DELAYED_MIC_ERROR_REPORT
    353 
    354 	if use privsep ; then
    355 		Kconfig_style_config PRIVSEP
    356 	fi
    357 
    358 	if use kernel_linux ; then
    359 		Kconfig_style_config LIBNL32
    360 	fi
    361 
    362 	if use qt5 ; then
    363 		pushd "${S}"/wpa_gui-qt4 > /dev/null || die
    364 		eqmake5 wpa_gui.pro
    365 		popd > /dev/null || die
    366 	fi
    367 }
    368 
    369 src_compile() {
    370 	einfo "Building wpa_supplicant"
    371 	emake V=1 BINDIR=/usr/sbin
    372 
    373 	if use wimax; then
    374 		emake -C ../src/eap_peer clean
    375 		emake -C ../src/eap_peer
    376 	fi
    377 
    378 	if use qt5; then
    379 		einfo "Building wpa_gui"
    380 		emake -C "${S}"/wpa_gui-qt4
    381 	fi
    382 
    383 	if use eapol-test ; then
    384 		emake eapol_test
    385 	fi
    386 }
    387 
    388 src_install() {
    389 	dosbin wpa_supplicant
    390 	use privsep && dosbin wpa_priv
    391 	dobin wpa_cli wpa_passphrase
    392 
    393 	# baselayout-1 compat
    394 	if has_version "<sys-apps/baselayout-2.0.0"; then
    395 		dodir /sbin
    396 		dosym ../usr/sbin/wpa_supplicant /sbin/wpa_supplicant
    397 		dodir /bin
    398 		dosym ../usr/bin/wpa_cli /bin/wpa_cli
    399 	fi
    400 
    401 	if has_version ">=sys-apps/openrc-0.5.0"; then
    402 		newinitd "${FILESDIR}/${PN}-init.d" wpa_supplicant
    403 		newconfd "${FILESDIR}/${PN}-conf.d" wpa_supplicant
    404 	fi
    405 
    406 	exeinto /etc/wpa_supplicant/
    407 	newexe "${FILESDIR}/wpa_cli.sh" wpa_cli.sh
    408 
    409 	readme.gentoo_create_doc
    410 	dodoc ChangeLog {eap_testing,todo}.txt README{,-WPS} \
    411 		wpa_supplicant.conf
    412 
    413 	newdoc .config build-config
    414 
    415 	if [ "${PV}" != "9999" ]; then
    416 		doman doc/docbook/*.{5,8}
    417 	fi
    418 
    419 	if use qt5 ; then
    420 		into /usr
    421 		dobin wpa_gui-qt4/wpa_gui
    422 		doicon wpa_gui-qt4/icons/wpa_gui.svg
    423 		domenu wpa_gui-qt4/wpa_gui.desktop
    424 	else
    425 		rm "${ED}"/usr/share/man/man8/wpa_gui.8
    426 	fi
    427 
    428 	use wimax && emake DESTDIR="${D}" -C ../src/eap_peer install
    429 
    430 	if use dbus ; then
    431 		pushd "${S}"/dbus > /dev/null || die
    432 		insinto /etc/dbus-1/system.d
    433 		newins dbus-wpa_supplicant.conf wpa_supplicant.conf
    434 		insinto /usr/share/dbus-1/system-services
    435 		doins fi.w1.wpa_supplicant1.service
    436 		popd > /dev/null || die
    437 
    438 		# This unit relies on dbus support, bug 538600.
    439 		systemd_dounit systemd/wpa_supplicant.service
    440 	fi
    441 
    442 	if use eapol-test ; then
    443 		dobin eapol_test
    444 	fi
    445 
    446 	systemd_dounit "systemd/wpa_supplicant@.service"
    447 	systemd_dounit "systemd/wpa_supplicant-nl80211@.service"
    448 	systemd_dounit "systemd/wpa_supplicant-wired@.service"
    449 }
    450 
    451 pkg_postinst() {
    452 	readme.gentoo_print_elog
    453 
    454 	if [[ -e "${EROOT}"/etc/wpa_supplicant.conf ]] ; then
    455 		echo
    456 		ewarn "WARNING: your old configuration file ${EROOT}/etc/wpa_supplicant.conf"
    457 		ewarn "needs to be moved to ${EROOT}/etc/wpa_supplicant/wpa_supplicant.conf"
    458 	fi
    459 	if ! use wep; then
    460 		einfo "WARNING: You are building with WEP support disabled, which is recommended since"
    461 		einfo "this protocol is deprecated and insecure.  If you still need to connect to"
    462 		einfo "WEP-enabled networks, you may turn this flag back on.  With this flag off,"
    463 		einfo "WEP-enabled networks will not even show up as available."
    464 		einfo "If your network is missing you may wish to USE=wep"
    465 	fi
    466 	if ! use tkip; then
    467 		ewarn "WARNING: You are building with TKIP support disabled, which is recommended since"
    468 		ewarn "this protocol is deprecated and insecure.  If you still need to connect to"
    469 		ewarn "TKIP-enabled networks, you may turn this flag back on.  With this flag off,"
    470 		ewarn "TKIP-enabled networks, including mixed mode TKIP/AES-CCMP will not even show up"
    471 		ewarn "as available.  If your network is missing you may wish to USE=tkip"
    472 	fi
    473 
    474 	# Mea culpa, feel free to remove that after some time --mgorny.
    475 	local fn
    476 	for fn in wpa_supplicant{,@wlan0}.service; do
    477 		if [[ -e "${EROOT}"/etc/systemd/system/network.target.wants/${fn} ]]
    478 		then
    479 			ebegin "Moving ${fn} to multi-user.target"
    480 			mv "${EROOT}"/etc/systemd/system/network.target.wants/${fn} \
    481 				"${EROOT}"/etc/systemd/system/multi-user.target.wants/ || die
    482 			eend ${?} \
    483 				"Please try to re-enable ${fn}"
    484 		fi
    485 	done
    486 
    487 	systemd_reenable wpa_supplicant.service
    488 }