Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

最近嘗試使用 Miraclecast 搭建一個 WiFi 投屏的服務。沒有什麼成效,不過也收穫了一些東西。

其中需要用到支援 WiFi Direct 的 wpa_supplicant,據我所知默認情況下發行版的二進制編譯是不會帶很多特別功能的。手動構建就成了首選(這麼各種編譯下去我遲早都得 gentoo 大法了 XD)

構建依賴

根據查詢到的文章,在 ubuntu 下構建需要依賴一些包。我這裏爲了方便使用 docker 容器作構建環境。

1
2
3
4
5
6
7
8
9
10
11
from ubuntu:jammy

WORKDIR '/opt'

RUN apt update && \
DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai \
apt-get install -y -q --force-yes libssl-dev build-essential curl tar \
checkinstall pkg-config dbus libdbus-1-dev libdbus-glib-1-2 \
libdbus-glib-1-dev libreadline-dev libncurses5-dev \
libnl-genl-3-dev libnl-3-dev && \
apt clean

開始構建

創建鏡像

1
docker build -t cattenlinger/wpa_supplicant_build:latest .

然後就可以跑去 (http://w1.fi/wpa_supplicant/)[http://w1.fi/wpa_supplicant/] 下載最新版本的原始碼了。截至目前原始碼版本是 2.10。

1
2
3
4
5
@> docker run --rm -it --host network cattenlinger/wpa_supplicant_build -v $(pwd):/opt bash
#> cd /opt
#> curl -O -L http://w1.fi/releases/wpa_supplicant-2.10.tar.gz
#> tar -xvf wpa_supplicant-2.10.tar.gz
#> cd wpa_supplicant-2.10

編譯之前需要先設置編譯參數。在 wpa_supplicant 檔案夾下創建 .config 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
CONFIG_BACKEND=file
CONFIG_CTRL_IFACE=y
CONFIG_DEBUG_FILE=y
CONFIG_DEBUG_SYSLOG=y
CONFIG_DEBUG_SYSLOG_FACILITY=LOG_DAEMON
CONFIG_DRIVER_NL80211=y
CONFIG_DRIVER_WEXT=y
CONFIG_DRIVER_WIRED=y
CONFIG_EAP_GTC=y
CONFIG_EAP_LEAP=y
CONFIG_EAP_MD5=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_OTP=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_TLS=y
CONFIG_EAP_TTLS=y
CONFIG_IEEE8021X_EAPOL=y
CONFIG_IPV6=y
CONFIG_LIBNL32=y
CONFIG_PEERKEY=y
CONFIG_PKCS12=y
CONFIG_READLINE=y
CONFIG_SMARTCARD=y
CONFIG_WPS=y
# 一些 WIFI P2P 相關的設定
CONFIG_P2P=y
CONFIG_WIFI_DISPLAY=y
# dbus 設定
CONFIG_CTRL_IFACE_DBUS_NEW=y
CONFIG_CTRL_IFACE_DBUS=y
CONFIG_CTRL_IFACE_DBUS_NEW=y
CONFIG_CTRL_IFACE_DBUS_INTRO=y

CFLAGS += -I/usr/include/libnl3

安裝

在 wpa_supplicant 目錄下執行 make。成功後執行 sudo checkinstall 即可安裝並打包軟件。因爲在 docker 環境下打的包,所以需要拎到外面再 dpkg -i 一次。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#> make
#> checkinstall
checkinstall 1.6.3, Copyright 2010 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: y

Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>> wpa_supplicant 2.10 with wifi p2p and display # 這裏隨便輸入一點包的說明
>>

*****************************************
**** Debian package creation selected ***
*****************************************

*** Warning: The package name "wpa_supplicant" contains illegal
*** Warning: characters. dpkg might not like that so I changed
*** Warning: them to dashes.

This package will be built according to these values:

0 - Maintainer: [ root@nuc7 ]
1 - Summary: [ wpa_supplicant 2.10 with wifi p2p and display ]
2 - Name: [ wpa-supplicant ]
3 - Version: [ 20220626 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ wpa_supplicant ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Recommends: [ ]
12 - Suggests: [ ]
13 - Provides: [ wpa-supplicant ]
14 - Conflicts: [ ]
15 - Replaces: [ ]

Enter a number to change any of them or press ENTER to continue:

......... # 中間省略

**********************************************************************

Done. The new package has been installed and saved to

/opt/wpa_supplicant-2.10/wpa_supplicant/wpa-supplicant_20220626-1_amd64.deb

You can remove it from your system anytime using:

dpkg -r wpa-supplicant

**********************************************************************
#> exit
#> dpkg -i wpa_supplicant-2.10/wpa_supplicant/wpa-supplicant_20220626-1_amd64.deb

大功告成。

如果系統中已經安裝了 wpa_supplicant 的話得先卸載掉。

1
sudo apt autoremove --purge wpasupplicant

评论